cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mrothschild
Helper V
Helper V

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
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Get Ready for Power BI Dev Camp

Power BI Dev Camp - June 24th

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors