Forum Discussion

Joseph_Hchaime's avatar
Joseph_Hchaime
Helper III
3 years ago
Solved

Conditional Formatting on Cell based on two conditions

Hi

 

I have the below data example that I'm trying to apply conditional formatting on but I'm not able to do it. I tried creating two different rules but it didnt work. 

 

Basically I want the same color to show in the background of the cell but for different Values of the Amount column based on the Location chosen. 

 

i.e.
if I chose Location NY, highlight all instances of Amount greater than or equal to 4,000 for values corresponding to that location.

if I chose Location London, highlight all instances of Amount greater than or equal to 10,000 for values corresponding to that location.

if I chose Location Dubai, highlight all instances of Amount greater than or equal to 6,000 for values corresponding to that location.

 

LocationAmount
New York4000
London10000
Dubai6000
  
 Conditional formatting:
Highlight in specific color when Location = NY, amount >=4,000
Highlight in specific color when Location = London, amount >=10,000
Highlight in specific color when Location = Dubai, amount >=6,000
  • Joseph_Hchaime you can add a measure for the color and then use that in the conditional formatting:

     

    Color = 
    VAR __Amount = SUM ( Table[Amount] )
    VAR __Location = SELECTEDVALUE ( Table[Location] )
    RETURN
    SWITCH ( TRUE (),
       __Location = "NY" && __Amount >= 4000, "Green",
       __Location = "London" && __Amount >= 10000, "Red",
       __Location = "Dubai" && __Amount >= 6000, "Yellow"
    )
    
     

3 Replies

  • Joseph_Hchaime can you provide more information? Just saying that it didn't work, it doesn't help. Share some screenshots of what you have done and how you are applying the solution.

  • Joseph_Hchaime you can add a measure for the color and then use that in the conditional formatting:

     

    Color = 
    VAR __Amount = SUM ( Table[Amount] )
    VAR __Location = SELECTEDVALUE ( Table[Location] )
    RETURN
    SWITCH ( TRUE (),
       __Location = "NY" && __Amount >= 4000, "Green",
       __Location = "London" && __Amount >= 10000, "Red",
       __Location = "Dubai" && __Amount >= 6000, "Yellow"
    )
    
     
  • How would that work? I tried creating it and adding it as a conditional formatting

    rule to the Amount measure. it didnt work