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.

Reply
Anonymous
Not applicable

VAR syntax question on SWICTH

Hi 

I have a newbie question about using VAR and Switch.  I am trying to create a RAG report based on the last update age  bracket to records in a data table.

I have created a custom column in query editor as = Table.AddColumn(#"Added Custom2", "UpdateAgeBracket", each if [Daysfromupdate] <30 then "<30 Days" else
if [Daysfromcreated]>=30 and [Daysfromupdate] <90 then "30 to 90 Days" else ">90 Days")

 

I then created 2 DAX measures in PowerBI desktop

LU >90 = COUNTROWS(FILTER(Toolkit,Toolkit[Daysfromupdate]>=90 && Toolkit[ActiveClosed]="Active"))-0
LU 30 to 60 = COUNTROWS(FILTER(Toolkit,Toolkit[Daysfromupdate]>=30 && Toolkit[Daysfromupdate]<60 && Toolkit[ActiveClosed]="Active"))-0
Then I created the Measure to created the rag using custom icons
RAG =
    VAR GreenIcon = UNICHAR(9989)
    VAR AmberIcon = UNICHAR(128992)
    VAR RedIcon = UNICHAR(10060)
    VAR Green = 0.29
    VAR Amber = 0.30
    VAR Red = 0.90
    RETURN
        SWITCH(TRUE(),
        [LU >90] > Red, RedIcon,
        [LU 30 to 90] = Amber, AmberIcon,GreenIcon)
 
When I create a table of RAG, Toolkit and Last UpdateAgeBracket the >90 shows the red icon and the <30 shows the Green but the 30 to 90 shows as green too. i want the 30 - 90to show the amber icon.
 
Help!

 

3 REPLIES 3
amunshi
Frequent Visitor

Hi @triciablakeyequ , 
Would u please mind sharing the sample data. I did not really follow the question based on the information provided. 

v-xiaoyan-msft
Community Support
Community Support

Hi @Anonymous ,

 

I don't quite understand what you mean, like:

VAR Green = 0.29
VAR Amber = 0.30
VAR Red = 0.90

Do you mind providing some sample data that does not contain sensitive information?

 

Hope it helps,


Community Support Team _ Caitlyn Yan

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

AlexisOlson
Super User
Super User

It looks like you are comparing row counts with decimal values less than 1. That doesn't make much sense to me.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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