Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
HeatherC
Contributor II
Contributor II

Limit available selections based on a variable

I have a variable vDashboard that is either 0 or 1 (I have a button that toggles this). If it is 0, I want the user to be able to make selections in a list box from the complete dataset.  However, if it is 1, I want to limit the available selections. In both cases, the user can only select one of the values.  

For example: my dataset has a field called Division with values A, B, C, D, E, F.  If vDashboard = 0, the listbox shows A,B,C,D,E,F as available for selection.  However, if vDashboard = 1, I want the list box to only show B,C,F as available for selection.  

I've added another field in my dataset call is (Dash) that has a 1 for any rows of data where Division in (B,C,F), so I can use that field to define the subset of available selections.  I could also envision doing this through a variable in my load statement.

How do I limit the selections available in the list box based on vDashboard?

Labels (1)
1 Solution

Accepted Solutions
NitinK7
Specialist
Specialist

Hi,

create variable  then take two button and 

first button add action set variable value 0

1.JPG

second button add action set variable value 1

2.JPG

then take listbox object and select last option Expression

exr.JPG

and write below expression 

if(vDash=0,division,
if(vDash=1,Pick(Match(division,'B','C','F'),'B','C','F'))).

it is working fine and may be helpful to you

 

Regards,

Nitin.

View solution in original post

2 Replies
sunny_talwar

If you can use a field instead of a variable, I would create a link table in your script like this

LOAD * INLINE [
    Division, Dashboard
    A, 0
    B, 0
    C, 0
    D, 0
    E, 0
    F, 0
    B, 1
    C, 1
    F, 1
];

Once you do this... selection of 0 in Dashboard will show all Division, but selection of 1 will only give B, C, and F

NitinK7
Specialist
Specialist

Hi,

create variable  then take two button and 

first button add action set variable value 0

1.JPG

second button add action set variable value 1

2.JPG

then take listbox object and select last option Expression

exr.JPG

and write below expression 

if(vDash=0,division,
if(vDash=1,Pick(Match(division,'B','C','F'),'B','C','F'))).

it is working fine and may be helpful to you

 

Regards,

Nitin.