cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mrothschild
Post Patron
Post Patron

SWITCH ( TRUE(). . . seeking a value AND a conditional color

Hi, 

 

I have the following SWITCH coded in DAX where "Score" comes from a VAR that's based on slicers.  The below is working as intended.

 

SWITCH(
    TRUE(),
    Score <= 0.5,       1 ,
    Score <= 0.8,       2 ,  
    Score <= 1.1,       3 ,
    Score <= 1.4,       4 ,
    Score <= 1.7,       5 ,
    Score <= 2.0,       6 ,
    7
)

 

I'd like to conditionally format the output [ = 1 or 2 or 3 or 4. .  .) with the following colors, but the code below doesn't work.  

 

Any ideas on how to correct?

 

SWITCH(
    TRUE(),
    Score <= 0.5,       1 && "#207ECC" ,
    Score <= 0.8,       2 && "#82BAE8" ,  
    Score <= 1.1,       3 && "#BBDBF4" ,
    Score <= 1.4,       4 && "#FFFFFF" ,
    Score <= 1.7,       5 && "#FFBEA8" ,
    Score <= 2.0,       6 && "#FF8913" ,
    7 && "#FF4B13"
)

 

Thanks!

 

1 ACCEPTED SOLUTION
amitchandak
Super User IV
Super User IV

@mrothschild , Prefebally a measure assuming score is a measure

 

Color = SWITCH(
    TRUE(),
    Score <= 0.5,       "#207ECC" ,
    Score <= 0.8,        "#82BAE8" ,  
    Score <= 1.1,       "#BBDBF4" ,
    Score <= 1.4,        "#FFFFFF" ,
    Score <= 1.7,        "#FFBEA8" ,
    Score <= 2.0,        "#FF8913" ,
    "#FF4B13"
)

 

Use this in conditional formatting with "Field value" option



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

2 REPLIES 2
amitchandak
Super User IV
Super User IV

@mrothschild , Prefebally a measure assuming score is a measure

 

Color = SWITCH(
    TRUE(),
    Score <= 0.5,       "#207ECC" ,
    Score <= 0.8,        "#82BAE8" ,  
    Score <= 1.1,       "#BBDBF4" ,
    Score <= 1.4,        "#FFFFFF" ,
    Score <= 1.7,        "#FFBEA8" ,
    Score <= 2.0,        "#FF8913" ,
    "#FF4B13"
)

 

Use this in conditional formatting with "Field value" option



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

Thanks!

 

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors