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

Check multiple selection in a list box

I have a year list box which shows 2001, 2002, ... 2015. In a chart, I want to control the display by the selection in this year filters. e.g. A chart is shown only when users select certain years.

I can do this for single year by putting this expression in "Conditional" field of Expressions tab in a chart:

if(Year='2005', 1, 0)

However, if I want to display a chart only when user select TWO or more years, (e.g., select 2005 AND 2006), the function doesn't work:

if(Year='2005' and Year='2006', 1, 0)

How can I make this work? Thanks.

1 Solution

Accepted Solutions
arulsettu
Master III
Master III

hi try this example

sum({<Year={'2005','2006'}>}field)

View solution in original post

9 Replies
arulsettu
Master III
Master III

hi try this example

sum({<Year={'2005','2006'}>}field)

maxgro
MVP
MVP

GetPossibleCount(Year)

or

GetSelectedCount(Year)

or

if(match(Concat(DISTINCT Year, '-', Year), '2013-2014'),1,0)

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

you need:

if(Year='2005' Or Year='2006', 1, 0)

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Michiel_QV_Fan
Specialist
Specialist

Don't add it to your expression.

"A chart is shown only when users select certain years"

Add to your chart properties in Layout - Show: getselectedcount(year) > 1 (or getselected count >= 2 )

Anonymous
Not applicable
Author

Hi in your chart's properties select Layout then Show -> Conditional. Enter the following code. The chart will only be displayed when more than 2 years are selected by the user.

=If(GetSelectedCount(Year)>2,1,0)

Anonymous
Not applicable
Author

Thanks but some of my selections are "AND" case, e.g. "2005" AND "2010".

Anonymous
Not applicable
Author

The match looks like the one I need. Thanks.

Anonymous
Not applicable
Author

This is also helpful, but sometimes I need to check whether the users have chosen the exact years I need, but this function can only check how many years have been chosen.

Michiel_QV_Fan
Specialist
Specialist

I think you need this solution:

sum({year = {'$(=GetFieldSelections(year))'}>} <your measure>)