Forum Discussion
Using Range of Values with SWITCH(TRUE Function
Greetings All -
Acknowlegement: Yes, I could probably do this using Cell Elements and using a function to define font colors and icons, however, I'm experimenting with using unicharacters because of the wider range of icons available.
I'm building a KPI style matrix and wanting to add some conditions to expand the results. Currently, I have a matrix which compares year to date sales between FY25 and FY26. It's working as expected - numbers greater than 0 are in a green font color with a unicharacter up arrow, while numbers less than 0 are in red with a unicharacter down arrow.
I have two measures that achieve this. The first one establishes the conditional logic defining the unicharacter symbols I want to use:
Hi rbowen,
In DAX, you must define ranges using logical operators (&&) and remember that percentages are decimal values (50% = 0.5). Your middle condition should be written like this:
_perc >= 0 && _perc < 0.5
That will fix the syntax error and correctly evaluate the range inside SWITCH(TRUE()).
Savio Ferraz | Microsoft Learning Consulting | Google Certified Trainer and Microsoft Certified Educator
Did my answer help? Mark my post as a solution or like it if you found it useful.
2 Replies
- SavioFerrazSuper User
Hi rbowen,
In DAX, you must define ranges using logical operators (&&) and remember that percentages are decimal values (50% = 0.5). Your middle condition should be written like this:
_perc >= 0 && _perc < 0.5
That will fix the syntax error and correctly evaluate the range inside SWITCH(TRUE()).
Savio Ferraz | Microsoft Learning Consulting | Google Certified Trainer and Microsoft Certified Educator
Did my answer help? Mark my post as a solution or like it if you found it useful.
- rbowenHelper III
I knew the && had to figure in there somehow. The piece I was missing was using the _perc after the &&. That worked perfectly, many thanks Savio!