I have a situation below in Power BI and DAX language.
I have 2 simple tables:
CountryTable
YearTable
There is a 1-M relationship between YearTable and CountryTable.
The latter (Year) is used to feed values into a slicer.
The former (Country) is the main table, with just 4 rows.
These two tables are related via the Year column.
The Year slicer always has EXACTLY 2 values chosen in my Power BI report.
I need the Maximum of these two values of the year slicer as a measure, for each row of my visual.
At the same time, these two year values of the slicer must remove the unwanted rows in my report visual, based on the slicer selection of year values.
For example, when the slicer has 2019 and 2020 chosen, I need the value as in the DesiredOutput1 page.
Similarly, you can see DesiredOutput2 (Slicer values are 2020 and 2022); DesiredOutput3 (Slicer values are 2019 and 2022) pages.
I tried something like this:
Max_Year_Measure = MAXX(
ALLSELECTED(YearTable),
YearTable[Year]
)
One main requirement: the Year column of my main visual must come from YearTable, not from CountryTable; hence both the Year columns (one in the slicer, the other in the visual) are from YearTable only; this is a requirement, because I am using some RANKX function to filter out all rank values after 1, based on the slicer selection.
You can see this below:
Rank_FF_ASC_Measure = IF(
HASONEVALUE(YearTable[Year]) = TRUE,
VAR Ranking = RANKX(
ALLSELECTED(YearTable[Year]),
CALCULATE(MAX(YearTable[YearOrder])),
,
1,
SKIP
)
RETURN Ranking,
BLANK()
)
Note:
In my client dataset, the Year values are prefixed with values such as Q1-2022, Q2-2022, etc. Hence I need to use YearTable[YearOrder] as the main sort column.
My eventual goal is to attain this visual below (when 2019 and 2020 are chosen in the slicer):
Or can [Rank_FF_ASC_Measure] be modified to meet my requirement ?
Any suggestion.
Please use the .pbix file in this posting. Feel free to reach out if you have questions.









