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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
UNICODE
Frequent Visitor

SWITCH function for changing UNICODE values not working correctly.

Hello Everyone, I have one that has stumped me.  

I have written a switch statement that will change the UNICODE values of in a calculated column.  I would like it to display the LAST value in a card visual to indicate the last state.   What I am finding is that it is showing the UNICODE value with the highest value.  

 

I have attached a screen shot Unicode switch.jpg

I was hoping for it to select the face at the 0.75 value (128531 unicode value)  instead it picks the 0.5 value (128532) as the Last Value.  If I pick a higher UNICODE value (128533 for example) then the card will display this value.  

 

Here is the source code for the switch statement.   I will attatch the BI file if I can figure out how. 

Face Changer Column = 
VAR WUCL=UNICHAR(128531)
VAR UCL=UNICHAR(128530)
VAR sigma=UNICHAR(128532)
VAR good=UNICHAR(128513)
VAR UCLV=0.875
VAR WUCLV=0.625
VAR sigmaV=0.5
Var goodV=0.3
VAR SWITCHER=
Switch(TRUE(),
'Example Data'[Value]>=UCLV,UCL,
'Example Data'[Value]>=WUCLV,WUCL,
'Example Data'[Value]>=sigmaV,sigma,good)

Return SWITCHER

 

1 ACCEPTED SOLUTION

This appears to be working now.  I did two things. 

1. I moved it to a measure. 
2. I changed the code, adding the MAX function. 

FCMES = 
VAR WUCL=UNICHAR(128531)
VAR UCL=UNICHAR(128530)
VAR sigma=UNICHAR(128532)
VAR good=UNICHAR(128513)
VAR UCLV=0.875
VAR WUCLV=0.625
VAR sigmaV=0.5
Var goodV=0.3
VAR SWITCHER=
Switch(TRUE(),
Max('Example Data'[Value])>=UCLV,UCL,
MAX('Example Data'[Value])>=WUCLV,WUCL,
Max('Example Data'[Value])>=sigmaV,sigma,good)

Return SWITCHER

 

View solution in original post

4 REPLIES 4
UNICODE
Frequent Visitor

Moved this to a reply 

amitchandak
Super User
Super User

@UNICODE , You need to create this face change measure on the measure, I doubt you are creating a column based on column

 

example

 

Switch(TRUE(),
sum('Example Data'[Value]) >=UCLV,UCL,
sum('Example Data'[Value])>=WUCLV,WUCL,
sum('Example Data'[Value])>=sigmaV,sigma,good)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Initially I had did this as a calculated column. 
Unicode switch3.jpg

 


Using the Sum makes sense to conver it over to a measure, ie it needing a single value to compute.   The problem with using SUM is it starts adding the 
Example Data'[Value] together and gives the incorrect results.  

MIN returns the UNICODE with the smallest code value.  
MAX always returns the one with the largest code value

This appears to be working now.  I did two things. 

1. I moved it to a measure. 
2. I changed the code, adding the MAX function. 

FCMES = 
VAR WUCL=UNICHAR(128531)
VAR UCL=UNICHAR(128530)
VAR sigma=UNICHAR(128532)
VAR good=UNICHAR(128513)
VAR UCLV=0.875
VAR WUCLV=0.625
VAR sigmaV=0.5
Var goodV=0.3
VAR SWITCHER=
Switch(TRUE(),
Max('Example Data'[Value])>=UCLV,UCL,
MAX('Example Data'[Value])>=WUCLV,WUCL,
Max('Example Data'[Value])>=sigmaV,sigma,good)

Return SWITCHER

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.