Forum Discussion

TDisco's avatar
TDisco
Helper I
4 years ago
Solved

Using Switch in an If Statement

I've seen this solution, but when I try it, the table[column] name can't be added to the measure. I'm just... so confused.   I have two swtiches that are adding unicharacter up/down/null arrows tha...
  • AllisonKennedy's avatar
    4 years ago

    TDisco  You're doing this as a measure, so you have no row context for the current value in the column. You can get the current value from that column by using SELECTEDVALUE:

     

    IF('SELECTEDVALUE(HI Team Metrics Details'[MasterID]) IN {"24","31","9","32"}, // if the items equal this...
    SWITCH(                                                                ///use this switch
    TRUE(),
    [m_difference%_filter]>0, UNICHAR(11014), //up
    [m_difference%_filter]<0, UNICHAR(11015), //down
    [m_difference%_filter]=0, UNICHAR(11020), //side
    "" //empty
    ),
    SWITCH(                                                                        //if not, use this one
    TRUE(),
    [m_difference%_filter]<0, UNICHAR(11014), //up
    [m_difference%_filter]>0, UNICHAR(11015), //down
    [m_difference%_filter]=0, UNICHAR(11020), //side
    "" //empty
    )
    )