Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
ZoeM
Specialist
Specialist

Conditional Formatting with If Expression

Hi Community,

I have created buttons that use the Action "Select in Field'.  

The first button is when '1' is selected, the second when '2' is selected, and the third when >2 is selected. The data range in this field is 1 - 10.

Now I would like to conditionally format those buttons to change color when clicked. For 1 and 2 they are working well but for >2 I am having difficulty getting it to work. 

 

These are the expressions I use:

If(GetFieldSelections([Range])=1,RGB(5,66,117)) for value 1

If(GetFieldSelections([Range])=2,RGB(5,66,117)) for value 2

If(GetFieldSelections([Range])>2,RGB(5,66,117)) and is meant to capture anything greater than 2.

But the third color formatting is not working. 

 

Any ideas on how I can reconstruct the expression?

 

Thanks in advance!

 

 

 

Labels (3)
1 Solution

Accepted Solutions
Taoufiq_Zarra

Hi Zoe,

attached a second version that you can improve if you want.

So the idea is :

1- I have created several variables to identify the active button

Capture.PNG

2- then for Button Actions i add a Set variable action that allows to save the  variable state

Capture2.PNG

then for the function :

If(GetFieldSelections(Range)=1 and B1=1,RGB(5,66,117),RGB(0,0,0))

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

3 Replies
Taoufiq_Zarra

Hi,

can you check the attached file.

I didn't find any problems with the formatting.

 

Sans titre.png

If(GetFieldSelections(Range)=1,RGB(5,66,117),If(GetFieldSelections(Range)=2,RGB(50,66,230),If(GetFieldSelections(Range)>2,RGB(50,0,230))))

notice that you put the same RGB color code

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
ZoeM
Specialist
Specialist
Author

Hi Taoufiq,

Thanks for the quick response.

So the idea is to have three different buttons that when not active they are a neutral color. 

When the first button is clicked (value 1), its color changes to show that it is active.

When the second button is clicked (value 2), its color changes to show it is active, and the other two buttons remain in the neutral color.

When the third button is clicked (value >2), its color changes to show it is active, and the other two buttons remain in the neutral color.

 

Hope that helps. 

Taoufiq_Zarra

Hi Zoe,

attached a second version that you can improve if you want.

So the idea is :

1- I have created several variables to identify the active button

Capture.PNG

2- then for Button Actions i add a Set variable action that allows to save the  variable state

Capture2.PNG

then for the function :

If(GetFieldSelections(Range)=1 and B1=1,RGB(5,66,117),RGB(0,0,0))

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉