Forum Discussion
Using Switch in an If Statement
- 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
)
)
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
)
)
- TDisco4 years agoHelper I
That is sheer sorcery. Thank you.