Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
mahendragaur
Contributor

Select a listbox value based on a variable's value

Hello All,

I have a variable which has multiple values let say (a,b) and I want to select my listbox values based on variable value. 

If variable contains single value then listbox is filtering values for that variable that is fine

but if variable have multiple values then listbox shows total values instead of multiple values (a,b).

Expected:- Listbox should select values based on values stored in variable 

like if a,b,c is stored in variable then listbox should show values only for a,b,c.

6 Replies
MVP & Luminary
MVP & Luminary

Re: Select a listbox value based on a variable's value

You need to replace the comma with a pipe, adding double-quotes around each item in case they contain spaces or any special chars and wrapping the whole in brackets. Your result for your example should be look like: ("a"|"b"|"c")

But why using variables to select field-values - it could be easily done within the listbox iself.

- Marcus

mahendragaur
Contributor

Re: Select a listbox value based on a variable's value

Hi Marcus,

I have 4 listboxes l1, l2, l3 and l4 and based on selection of l1 values I am storing it in a variable and passing that variable values in listboxes l2, l3 and l4.

Is it direct method that I can update the values of l2, l3 and l4 directly based on l1 value?

 

MVP & Luminary
MVP & Luminary

Re: Select a listbox value based on a variable's value

If the fields behind your listboxes are associated with each other in the datamodel it would be just enough to select their fieldvalues to create the wanted views.

- Marcus

mahendragaur
Contributor

Re: Select a listbox value based on a variable's value

Field is not connected in data model and because of some reasons I don't want to connect them as well.

These listboxes are from different data sources but the listboxes contains same values and I don't want to show all the 4 listboxes in a single dashboard that's why I used this work around to update the dashboard with single click on any of the listbox.

MVP & Luminary
MVP & Luminary

Re: Select a listbox value based on a variable's value

At first I would look within the datamodel if there are not sensible/pratically ways to associate the data so that normal selections would be enough to create all needed views. If this isn't possible I would really consider to provide the users all needed fields because they should understand what happens with the data if they click here and there - and often the best way for it is to display it with the listboxes, see also: Let-the-User-Select.

If there are really good reasons not to go in the direction of my above suggestion I would probably use set analysis to transfer the selection-states, for example with something like this:

sum({< F1 = p(F2) > * < F1 = p(F3) >} Value)

The use of any actions/macros would be quite probably my last measurement to solve such a task whereby I'm not sure if I would use variables as an intermediate step else I think I would use direct expressions in the search-value of the actions with concat() or getfieldselections().

- Marcus

mahendragaur
Contributor

Re: Select a listbox value based on a variable's value

Any other way of doing that? I mean to select same values in other 2 listboxes on selection of 1st listbox.