Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlikuser09
Creator II
Creator II

Creating 2 depending variable drop down in Qliksense

Is there a way to create 2 variable drop-down box? Such that the output of the second variables drop-down depends on the first variable input.

1 Solution

Accepted Solutions
Andrei_Cusnir
Specialist
Specialist

Hello,

 

If my understanding is correct. You want to created 2 Variable inputs charts (drop-down) where the options of the second one are depended on the selection of the first one. There is a way to achieve that as follows:

  1. Lets assume that we want to create 1 Variable input for Country and another one for City. The list of cities is updated based on the selected country in Variable input 1.
  2. First create variable: varSelectedCountry and set the value to the default selection e.g 1
  3. Now created another variable: varSelectedCity and set the value to the default selection e.g. 1
  4. Now you have to created the first Variable input object. Under Appearance > Values set the option to "Dynamic"
  5. Under Dynamic values set the expression ='1~Spain | 2~Cyprus | 3~Greece'
  6. Under Appearance > Variable select the variable "varSelectedCountry" and Show as Drop down
  7. Now you have a fully functioning Variable input, that gives you 3 countries as option and as soon as you choose one of them, it will update the value of varSelectedCountry to the value that you have selected.
  8. Create another Variable input object. 
  9. Under Appearance > Variable select the variable "varSelectedCity" and Show as Drop down
  10. Under Appearance > Values set the option to "Dynamic"
  11. Under Dynamic values set the expression:

=Pick( 
   '$(varSelectedCountry)'
   'Madrid~Madrid | Valencia~Valencia | Barcelona~Barcelona',
   'Larnaca~Larnaca | Nicosia~Nicosia | Limassol~Limassol'
   'Athens~Athens | Thessalonki~Thessalonki | Patra~Patra' 
)

 

This expression is using the function Pick() [1], which selects and returns one of the expressions based on the value that is stored in the variable varSelectedCountry. The result is:

 

As you can see the options for the second Variable input object are changing based on the selection of the first Variable input object. I hope that this information was helpful.  

 

---

[1] https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/ConditionalF...

Help users find answers! Don't forget to mark a solution that worked for you! 🙂

View solution in original post

5 Replies
Digvijay_Singh

Can you share one sample example and output image( may be manually drawn)  to understand exactly what you are looking for?

Qlikuser09
Creator II
Creator II
Author

Qlikuser201_0-1633056010542.png

Something like this. If I select a specified state, respective cities should be displayed.

Digvijay_Singh

Normally the required behavior is automatically achieved if the state and city are properly associated in the data model. I would still want to confirm if the State and City are the fields in your data model? You mentioned them as 'variable' in the initial question so got confused. 'Variables' have different usage in Qlik so need more details.

Andrei_Cusnir
Specialist
Specialist

Hello,

 

If my understanding is correct. You want to created 2 Variable inputs charts (drop-down) where the options of the second one are depended on the selection of the first one. There is a way to achieve that as follows:

  1. Lets assume that we want to create 1 Variable input for Country and another one for City. The list of cities is updated based on the selected country in Variable input 1.
  2. First create variable: varSelectedCountry and set the value to the default selection e.g 1
  3. Now created another variable: varSelectedCity and set the value to the default selection e.g. 1
  4. Now you have to created the first Variable input object. Under Appearance > Values set the option to "Dynamic"
  5. Under Dynamic values set the expression ='1~Spain | 2~Cyprus | 3~Greece'
  6. Under Appearance > Variable select the variable "varSelectedCountry" and Show as Drop down
  7. Now you have a fully functioning Variable input, that gives you 3 countries as option and as soon as you choose one of them, it will update the value of varSelectedCountry to the value that you have selected.
  8. Create another Variable input object. 
  9. Under Appearance > Variable select the variable "varSelectedCity" and Show as Drop down
  10. Under Appearance > Values set the option to "Dynamic"
  11. Under Dynamic values set the expression:

=Pick( 
   '$(varSelectedCountry)'
   'Madrid~Madrid | Valencia~Valencia | Barcelona~Barcelona',
   'Larnaca~Larnaca | Nicosia~Nicosia | Limassol~Limassol'
   'Athens~Athens | Thessalonki~Thessalonki | Patra~Patra' 
)

 

This expression is using the function Pick() [1], which selects and returns one of the expressions based on the value that is stored in the variable varSelectedCountry. The result is:

 

As you can see the options for the second Variable input object are changing based on the selection of the first Variable input object. I hope that this information was helpful.  

 

---

[1] https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/ConditionalF...

Help users find answers! Don't forget to mark a solution that worked for you! 🙂
Qlikuser09
Creator II
Creator II
Author

Thanks !!! It Worked