Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

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

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

  • Anonymous's avatar
    Anonymous
    Not applicable

    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.

  • Anonymous's avatar
    Anonymous
    Not applicable

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