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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Bug using switch() function with unichar()

Hello to all! I try to display 2 different symbols in a table depending on a status - here is the small dax function:

 

test status = SWITCH(TRUE();
    [Projectstatus] = 0; UNICHAR(9940);
    [Projectstatus] = 1; UNICHAR(9989);
    "")

Code works for different unichar-values - it seems to be a problem with the number range that i'm in. It ends in the result that the unichar(9989) is displayed for all rows:

 

switch - unicode.PNG

Selecting only the status "0" the result is correct:

 

switch - unicode II.png

Selecting other values the result is correct:

 

switch - unicode III.PNG

 

The current work around is adding a additional character to one of the 2 unichar() expressions:

 

status char = SWITCH(TRUE();
    AVERAGE(Testtabelle[Status]) = 1; UNICHAR(9989);
    AVERAGE(Testtabelle[Status]) = 0; UNICHAR(9940)&" "; 
    ""
)

Howerver not perfect and seems to me like a bug - in case you have any questions feel free to contact me!

 

Best regards & thx for the fix!

Stephan

 

 

Status: New
Comments
v-qiuyu-msft
Community Support

Hi @sfuhr ,

 

I have tested in the latest Power BI desktop version and your first DAX is working. I would suggest you update your Power BI desktop to the latest version 2.66.5376.2521 as ours then test again. 

 

q4.PNGq5.PNG

 

 

Best Regards,
Qiuyun Yu 

sfuhr
Frequent Visitor

Hello Quiyun -

 

that is exactly what i'm using - so happy to know, that this works for you - might be a issue with country settings!?

 

switch - unicode IV.PNG

Kind regards,

Stephan

v-qiuyu-msft
Community Support

Hi @sfuhr ,

 

Both Power BI desktop regional settings and OS regions are English (United States). Please try to change your regional settings as ours then test again to see if the issue occurs? 

 

Or may I know what's your Power BI desktop and OS regions? 

 

Best Regards,

Qiuyun Yu 

JoaoMS
Helper III

Hi, currently I'm having the same problems when using 3 unichar codes as you can see in the following picture:

Case2.png

My version of PI Desktop is from December 2019 . Any idea of solution?

Versión: 2.76.5678.782 64-bit (diciembre de 2019)

 

Regards,

Joao

Nolock
Resident Rockstar

The general recommendation is always having the current version of Power BI Desktop. Both earlier mentioned scenarios for calculated columns in DAX work in the PBI Desktop March 2020.

 

Btw. you don't need to use the UNICHAR function with these UNICODE codes, use UNICODE characters instead of it (https://emojipedia.org/)

 

Capture.PNG

Capture2.PNG

JoaoMS
Helper III

Hi, it worked with the UNICODE icons!

Thanks

 

Case1.png

gck02
Frequent Visitor

Hi,

 

Two years later and the bug is still present. To solve this issue I used your solution @sfuhr (adding some characters after the UNICHAR function: https://community.powerbi.com/t5/Desktop/problems-using-switch-function-with-unichar/m-p/631666/high...)

 

Thanks for your solution.

Best regards.