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

How to check which values in a field are selected

I have a bar chart which shows data over a country dimension. I am using set analysis to ignore the country selection, so that all countries always appear. What I want to have happen is when a user selects countries from a list box the relevant bars in the chart change color. For example, if all the bars are blue and I select USA, the USA bar becomes green. If they Ctrl+Click on Canada so they have two countries selected, those two bars would be green.

What's throwing me is the need to check against multiple selected values. I was thinking that I'd put an if statement in the background color expression of the expression in the chart, but I'm not sure how to do it to check against all selected values. if(country = ???, RGB(0,255,0), RGB(0,0,255))

1 Solution

Accepted Solutions
Not applicable

Hi,

I did not try but following may work:

=if(SubStringCount(Concat(Distinct Country), Country)>0, Green(), Blue())

Regards,

http://quickdevtips.blogspot.com/

View solution in original post

5 Replies
perumal_41
Partner - Specialist II
Partner - Specialist II

Hi,

use this Exprsssion

=if(country= Concat(Getcurrentselections(country),','), RGB(0,255,0), RGB(0,0,255)).

this is helps to solve ur problem.

Regards

Perumal A

Not applicable

Hi,

I did not try but following may work:

=if(SubStringCount(Concat(Distinct Country), Country)>0, Green(), Blue())

Regards,

http://quickdevtips.blogspot.com/

Not applicable

Hi Bilge Aydin,

your expression is working properly... Cn you explain how you used SubString in the expression??

- yojas

Not applicable

Hi,

SubStringCount function takes 2 parameters and it searches how many times the 'Parameter 2', appears in 'Parameter 1'. For example:

SubStringCount('GermanyFranceNetherlandsFrance', 'France') --> returns 2.

So, in the expression, I compared the COUNTRY with the list of selected countries.

"Concat(Distinct Country)" returns the list of selected countries as a concatenated string (e.g. 'GermanyFranceItalySpain'). And the IF statement checks if the COUNTRY is in the list of selected countries. If the COUNTRY is in the list, then the IF statements returns GREEN else it returns BLUE.

Pls. let me know if it is not clear.

Regards,

Not applicable

Thanks for explanation...