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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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