Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
jonathandienst
Partner - Champion III
Partner - Champion III

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
Anil_Babu_Samineni

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)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

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?

ahmed_hassan
Contributor III
Contributor III

You can use "background colors" for the dimensions and expressions ( click on the "+" and choose background color)
Anonymous
Not applicable
Author

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.