Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Breezy
Creator II
Creator II

How to change button color based on selection?

Hello, below I have three buttons. I need it to be so that when I click a button the color will change to demonstrate it is clicked. In the example below I clicked 2022 and the button changed to gray. 

Breezy_0-1673282088241.png

 

Labels (1)
10 Replies
salonicdk28
Creator II
Creator II

Firstly you need to create variables, say for example

salonicdk28_0-1673334787099.png

For Chart button, you have to set the chart variable vChart action as 1, then under the properties ->appearance ,set the background color by expression and write like this if(vChart=1,'#009845','#DDDDDD') and to change the font color of the text, there also you can set the font styling by expression and write if(vChart=1,RGB(255, 255, 255),'#595959')

 

Same way you have to set for data button as well assign that button action as 0

Font Styling- if(vChart=0,RGB(255, 255, 255),'#595959')

Background color- if(vChart=0,'#009845','#DDDDDD')

 

Hope this helps in your case

 

Thanks,

Saloni

salonicdk28
Creator II
Creator II

Firstly you need to create variables, say for example

salonicdk28_1-1673335159657.png

 

For Chart button, you have to set the chart variable vChart action as 1, then under the properties ->appearance ,set the background color by expression and write like this if(vChart=1,'#009845','#DDDDDD') and to change the font color of the text, there also you can set the font styling by expression and write if(vChart=1,RGB(255, 255, 255),'#595959')

 

Same way you need to set for data button as well-

like background color-  if(vChart=0,'#009845','#DDDDDD')

font styling-  if(vChart=0,RGB(255, 255, 255),'#595959')

 

Hope this helps in your case

 

Thanks,

Saloni

salonicdk28
Creator II
Creator II

Firstly you need to create variables, say for example

 

salonicdk28_0-1673335344136.png

For Chart button, you have to set the chart variable vChart action as 1, then under the properties ->appearance ,set the background color by expression and write like this if(vChart=1,'#009845','#DDDDDD') and to change the font color of the text, there also you can set the font styling by expression and write if(vChart=1,RGB(255, 255, 255),'#595959')

Same way set for data button as well where vChart =0 in each of the above expressions

Thanks,

Saloni

 

Breezy
Creator II
Creator II
Author

Hi, 

I used the chart button:

Breezy_0-1673635311703.png

However, I had my action/navigation like this:

I don't understand what you mean by "you have to set the chart variable vChart action as 1." Can you please clarify?

Breezy_4-1673635518820.png

 

 

 

 

salonicdk28
Creator II
Creator II

I meant instead of action you have set instead use set variable value and insert variable which is designed for this and in value, write 1 or 0 as per the condition like below-

salonicdk28_0-1673854543652.png

 

 

Lemac
Contributor III
Contributor III

I would do it like this: In the background property of your button you define:

 

=if(GetCurrentSelections(Year)='Year: 2022', '#DDDDDD', '#FF0000')

 

 

Breezy
Creator II
Creator II
Author

Hi  - follow-up question, 

Now I'm trying to figure this out if I used, instead of Year,  two words, such as 'New Year' . It's giving me an error message though. Am I putting the  ' ' in the wrong places? 

 

Lemac recommendation: 

=if(GetCurrentSelections(Year)='Year: 2022', '#DDDDDD', '#FF0000')

 

My recommendation

=if(GetCurrentSelections([New Year])='[New Year]: 2022', '#006580', '#906086')

 

neerajthakur
Creator III
Creator III

Change your recommendation to this 

=if(GetCurrentSelections([New Year])='New Year: 2022', '#006580', '#906086')

Thanks & Regards,
Please Accepts as Solution if it solves your query.
Breezy
Creator II
Creator II
Author

Alas, that does not work either. I also tried the following and it did not work either. 

 

=if(([New Year]=2022), '#006580', '#906086')