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
mrothschild
Continued Contributor
Continued Contributor

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
Super User

@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

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@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

Thanks!

 

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.