Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Cbhuvi27
Contributor III
Contributor III

Conditional formatting based on button Variable

Hello All,

I have created a switch to apply conditional formatting in table  and trying to enable both at a same time. but one switch is not working if I enable the other one.

 

eg :

Cbhuvi27_0-1702025303702.png

 

 

For 1st switch it is blue() and for 2nd switch it is grey, even I enabled both I am unable to see the conditional formatting for 2nd switch.

 

If($(vSwitch1)='Switch1',IF(SUM(Sales)>0 AND SUM(Sales)<100, RGB(201,218,248)),
IF($(vSwitch2)='Switch2',IF(SUM(Sales)=0,RGB(192,192,192))))

 

Labels (3)
1 Reply
F_B
Specialist
Specialist

Hi @Cbhuvi27 ,

the current expression is evaluating vSwitch1 and, if it is 'Switch1', it applies the first condition, but it doesn't leave room for the second condition to be evaluated unless the first one fails. You need to adjust the logic so that both conditions can be evaluated independently.

 

Try this:

IF(
$(vSwitch1) = 'Switch1' AND SUM(Sales) > 0 AND SUM(Sales) < 100,
RGB(201,218,248),
IF(
$(vSwitch2) = 'Switch2' AND SUM(Sales) = 0,
RGB(192,192,192),
// Default color if no conditions are met
'black'
)
)