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

Colour changing button

Hi All,

I have made multiple buttons, one for each month and I want them to light up when they're selected. 

I can make them change colour when a single month is selected but when selecting multiple months they all return to default colour. How do I make them change colour when multiple months are selected?

Currently using :  - Toggle Field Selection (Action)

Appearance Expression: =IF([Reporting Period (Month)]='01 JAN',Green(),)     02 FEB, 03 MAR, 04 APR....etc

 

Many thanks

Labels (5)
1 Solution

Accepted Solutions
justISO
Specialist
Specialist

If you want to highlight specific month only, you need for each button make separate expression to check, does month exist in selection. It can be done with something like this:

if(index(GetFieldSelections([Reporting Period (Month)]), 'JAN')>0, green())

'JAN' in other buttons should be changed to 'FEB', 'MAR' etc

View solution in original post

7 Replies
justISO
Specialist
Specialist

Hi, try

if(GetSelectedCount([Reporting Period (Month)])>0, green())

CBoardy
Contributor III
Contributor III
Author

Thanks for your help. It sort of works, however it changes the colour of the button even if that current month isnt selected. In the picture below March is selected but Jan is changing colour without it being selected.

CBoardy_0-1680168370202.png

 

justISO
Specialist
Specialist

If you want to highlight specific month only, you need for each button make separate expression to check, does month exist in selection. It can be done with something like this:

if(index(GetFieldSelections([Reporting Period (Month)]), 'JAN')>0, green())

'JAN' in other buttons should be changed to 'FEB', 'MAR' etc

CBoardy
Contributor III
Contributor III
Author

Thats perfect thanks!

CBoardy
Contributor III
Contributor III
Author

Just another small thing - When I select over half of the filters the colour swaps to as if they're not selected when they are. Do you know why?  In the second photo all the blue are selected do you know how to keep them green instead of swapping for what ever reason

CBoardy_0-1680170173606.png

CBoardy_1-1680170190268.png

 

justISO
Specialist
Specialist

hmm, this is nuance of this getfieldselection(). If you select more than half possible values it shows not 'jan, feb, mar...' but 'NOT sep, oct, nov, dec'. I didn't know that until now too 🙂

Lets make 'string' if month is selected:

if(GetSelectedCount([Reporting Period (Month)])>0, Concat(total [Reporting Period (Month)]))

so a bit modified expression could look like

if(index(if(GetSelectedCount([Reporting Period (Month)])>0, Concat(total [Reporting Period (Month)])), 'JAN')>0, green())

CBoardy
Contributor III
Contributor III
Author

Thats excellent fix this issue thank you very much!