Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Partner
Partner

Conditional Listbox

Hi,

I have a listbox which contains many values but there are values that I want to exclude based on a condition.

The condition itself is:

=COUNT({$<FIELD_1 = {7,8,9,14,19}>} FIELD_2) > 0 

I then have a listbox for FIELD_3. I only want values in the listbox to be visible if the above condition is true for that selection in FIELD_3. In other words for each value in the listbox, I want to only include selections in FIELD_3 that yield COUNT({$<FIELD_1 = {7,8,9,14,19}>} FIELD_2) > 0, and exclude all other values.

Does anybody know how I could achieve this? I've had a look around the forums and tried to make an expression but to no avail. I've tried the following expression as a listbox but it doesn't work at all:

IF(COUNT({$<FIELD_1= {7,8,9,14,19}>} FIELD_2) > 0, FIELD_3)

Labels (4)
5 Replies
Highlighted

Use this as the listbox expression:

=Aggr(If(COUNT({$<FIELD_1 = {7,8,9,14,19}>} FIELD_2) > 0, FIELD_3), FIELD_3)

 

 

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

Aggregate functions won't work in listbox using Sum(), Count() and Avg() .. without Aggr() on field from that measure. For ex, If you have measure called Sum(Sales) where You want to show field which holds in between 2 and 20. That case, You must need Aggr() function like

If(Aggr(Sum(Sales), Field)>=2 and Aggr(Sum(Sales), Field)<=20, FieldName)

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Highlighted
Partner
Partner

Thank you! That worked very nicely, as an aside - is there a way of keeping the values where this condition isn't satisfied but as greyed out options?

Highlighted
Contributor III
Contributor III

You can use "background colors" for the dimensions and expressions ( click on the "+" and choose background color)
Highlighted
Partner
Partner

Hmmm I'm not sure that that will work as I don't have an expression, just an expression as the field for the listbox.

I guess is there a way to define the state of each value in the listbox by the previous constraint.

i.e. 

=Aggr(If(COUNT({$<FIELD_1 = {7,8,9,14,19}>} FIELD_2) > 0, FIELD_3), FIELD_3)

If this is true then the "State" should be active, if it's false then the "State" should be inactive, but it should still display in the listbox as inactive.