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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
bookhouseboy
Helper I
Helper I

Using SWITCH in a table to evaluate only one row at a time

Hi, so we're trying to visualize changes in a table by adding little arrows, indicating whether an item has moved up or down since yesterday. We have a measure called #arrow that is supposed to indicate whether the arrow should point up, down or sideways. But the arrow always points up, and we suspect this is because the code evaluates the whole table, not just the one row it's on.

bookhouseboy_0-1738321267290.png


The strange thing is that #Test, which is also a measure, does show the correct value for just the one row. We can't figure out why it acts for one row for #Test, but for the entire table for #arrow. We've tried SELECTEDVALUE, VALUES, and SUM for #arrow.

#Test = SUM(X[DeltaRang])
#arrow =
SWITCH(
TRUE(),
SUM(X[DeltaRang]) < 0, UNICHAR(9207), // Negativ
SUM(X[DeltaRang]) = 0, UNICHAR(9205), // Null
SUM(X[DeltaRang]) > 0, UNICHAR(9206), // Positiv
UNICHAR(9210) 
)


Help please?

5 REPLIES 5
johnt75
Super User
Super User

I think that this is a bug in Power BI. When I run the below code either in DAX Query View in Power BI Desktop, or in DAX Studio connected to a semantic model in the service, I get output showing all the codes with the same symbol. When I run in on dax.do ( https://dax.do/zA2kV4Detv6kqx/  ) I get the correct results.

johnt75_0-1738329783139.png

Its probably worth raising a bug report with Microsoft support.

And Microsoft support says they cannot replicate the issue. Oh well.

That's discouraging... but thank you for going to that effort!

bhanu_gautam
Super User
Super User

@bookhouseboy , Try using 

 

#arrow =
SWITCH(
TRUE(),
SELECTEDVALUE(X[DeltaRang]) < 0, UNICHAR(9207), // Negative
SELECTEDVALUE(X[DeltaRang]) = 0, UNICHAR(9205), // Null
SELECTEDVALUE(X[DeltaRang]) > 0, UNICHAR(9206), // Positive
UNICHAR(9210)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thanks but, no, we tried that -- no change. ☹️

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.