cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mrothschild
Responsive Resident
Responsive Resident

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 Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

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

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors
Users online (491)