Forum Discussion

BIBRO's avatar
BIBRO
Frequent Visitor
4 years ago
Solved

Switch measures based on column value

I want to use a different measure based on the year. If Year = max(year) then use measure 1 else use measure 2.

 

In the example below measure 3 uses measure 1 for Max(Year) and measure 2 for the rest of the years.

This dax isn't working for me for some reason. It only returns Measure 1

Measure 3 =
if(SELECTEDVALUE(table[year]) = MAX(table[year]),[measure 1],[measure 2])

 

  • BIBRO , In such case the selected value has come from an independent year table

     

    if(SELECTEDVALUE(year[year]) = MAX(table[year]),[measure 1],[measure 2])

     

    Measure =

    var _max  =maxx(allselected(year), year[year])

    return

    if(_max = MAX(table[year]),[measure 1],[measure 2])

     

    Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

1 Reply

  • BIBRO , In such case the selected value has come from an independent year table

     

    if(SELECTEDVALUE(year[year]) = MAX(table[year]),[measure 1],[measure 2])

     

    Measure =

    var _max  =maxx(allselected(year), year[year])

    return

    if(_max = MAX(table[year]),[measure 1],[measure 2])

     

    Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI