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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

SWITCH statement not working properly

I have the following SWITCH statement as a new column:

 

teperatureTrendChar =
VAR Down = UNICHAR ( 11167 )
VAR Up = UNICHAR ( 11165 )
VAR equal = UNICHAR ( 61 )

RETURN
SWITCH (
TRUE (),
BMSState[temperatureTrend] = "Down", Down,
BMSState[temperatureTrend] = "Up", Up,
        BMSState[temperatureTrend] = "Steady", equal)
 
This should return a DOWN ARROW, EQUALS SIGN, UP ARROW based on the value of [temperatureTrend].  However, you can see from the image below that regardless of whether the value is "Down" or "Up" it returns the same value. Don't quite know what is going on here?
 
 pbi1.gif
1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

It can work correctly on my side.

3.png

Please check which version you use(there may be an issue with the previous version).

To make it works on your side, i would suggest you updating the lastest version.

https://docs.microsoft.com/en-us/power-bi/desktop-latest-update

 

 There is a workaround as below if you use the current version:

Create measures

Measure 1 = SWITCH(MAX(Table2[Trend]),"Up",1,"Down",-1,"Steady",0)

Measure 2 = 
VAR Down = UNICHAR (11167)
VAR Up = UNICHAR (11165)
VAR Equal = UNICHAR (61 )

RETURN
SWITCH (
TRUE(),
[Measure 1]<0, Down,
[Measure 1]>0, Up&" ",
[Measure 1]=0, Equal)

4.png

or create columns

Column 1 = SWITCH(Table2[Trend],"Up",1,"Down",-1,"Steady",0)

Column 2 = 
VAR Down = UNICHAR (11167)
VAR Up = UNICHAR (11165)
VAR Equal = UNICHAR (61 )

RETURN
SWITCH (
TRUE(),
[Column 1]<0, Down,
[Column 1]>0, Up&" ",
[Column 1]=0, Equal)

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Is this problem sloved? 

If it is sloved, could you kindly accept it as a solution to close this case?

If not, please let me know.

 

Best Regards

Maggie

Anonymous
Not applicable

Thanks - had to use the workaround as I am running latest version of PowerBI Desktop already. BTW - can you tell me why you add a space for the Up check? Up&" "
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

It can work correctly on my side.

3.png

Please check which version you use(there may be an issue with the previous version).

To make it works on your side, i would suggest you updating the lastest version.

https://docs.microsoft.com/en-us/power-bi/desktop-latest-update

 

 There is a workaround as below if you use the current version:

Create measures

Measure 1 = SWITCH(MAX(Table2[Trend]),"Up",1,"Down",-1,"Steady",0)

Measure 2 = 
VAR Down = UNICHAR (11167)
VAR Up = UNICHAR (11165)
VAR Equal = UNICHAR (61 )

RETURN
SWITCH (
TRUE(),
[Measure 1]<0, Down,
[Measure 1]>0, Up&" ",
[Measure 1]=0, Equal)

4.png

or create columns

Column 1 = SWITCH(Table2[Trend],"Up",1,"Down",-1,"Steady",0)

Column 2 = 
VAR Down = UNICHAR (11167)
VAR Up = UNICHAR (11165)
VAR Equal = UNICHAR (61 )

RETURN
SWITCH (
TRUE(),
[Column 1]<0, Down,
[Column 1]>0, Up&" ",
[Column 1]=0, Equal)

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@Anonymous - That looks like it should work - can you provide a sample table or pbix? 

Thanks,

Nathan

Anonymous
Not applicable

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors