Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
TDisco
Helper I
Helper I

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 that are used to display an up/down/vertical arrows. The trick is, some results are good (up arrow), while some are bad (down arrow).... (example: good is +10% increase in users, but +10% in query time is bad) I have two switch statements that work on their own, but I'd like the data to show in a single row, using the ID of known 'bad' items being measured.

 

The issue I'm having is the Switch DAX measure won't accept the 'table'[column] name. Just gives me the sqiggle red-line of death.

 

Statement

IF('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
)
)

 

error: (Column does not exist)

- I tried to build another measure to use in this If Statement to filter the ID's, but I'm still not able to add the column name.

 

TDisco_2-1632780028120.png

 

 

 

 

 

1 ACCEPTED SOLUTION
AllisonKennedy
Super User
Super User

@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
)
)


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

2 REPLIES 2
AllisonKennedy
Super User
Super User

@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
)
)


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

That is sheer sorcery. Thank you.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors