
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 Variables to Filter Same Dimension
Hello. I am new to Qlik Sense but have developed in other dashboard tools. I have 2 variables that are set by making a selection from a dropdown list. I want to use these 2 values to filter a dimension in a table to compare the data for 2 different units - members of the same dimension. How do I accomplish this in Qlik? If user selects Unit A and Unit D, how do I display only those 2 units in the table? Thanks in advance.
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My suggestion is to use the set in the measure rather than the dimension. The measure would look like (warning not syntax checked):
sum({<Unit={'$(var1)','$(var2)'}>} Cost * Qty)
If you were going to create a calculated dimension, the dimension expression would be:
=aggr(only({<Unit={'$(var1)','$(var2)'}>} Unit), Unit)
If it's not working, please post the full text of your expression or dimension.
-Rob


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm confirming that you do mean actual variables, not fields. And that you have a field named "Unit" for example.
If my understanding is correct, you could reference the variables in a set expression in your chart. The set expression would be:
{<Unit={'$(var1)','$(var2)'}>}
Then you would use that set in a measure or a calculated dimension. For example, if your chart Dimension was "Unit" and you wanted to count the "Event" field associated with each Unit your measure would be:
Count({<Unit={'$(var1)','$(var2)'}>} Event)
-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for the reply. I am not sure I am getting this to work. Here is what I am attempting to do:
I would like to use the 2 variables to populate a table object which would only display the 2 Units selected. When I try to implement your suggestion, I get an error - invalid dimension. Also, I would like to use Set Analysis to get the CostxQty amounts.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Those "variables". Are they truly variables or are they fields? Can you post a screenshot of your table model from the data model viewer?
-Rob

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the variables are set by selecting an entry from a drop down list. Hence I have 2 values 'A' and 'D' which correspond to values in the Unit field of my data. So, in a table, I would like to list only Unit A and Unit D (on separate rows) for Unit and the corresponding calculation results for CostxQty. When I attempt to create a Dimension using {<Unit={'$(var1)','$(var2)'}>}, I get an Invalid Dimension error. I am able to create a table with one row representing one variable, but not using 2 variables. Thanks again for the help.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My suggestion is to use the set in the measure rather than the dimension. The measure would look like (warning not syntax checked):
sum({<Unit={'$(var1)','$(var2)'}>} Cost * Qty)
If you were going to create a calculated dimension, the dimension expression would be:
=aggr(only({<Unit={'$(var1)','$(var2)'}>} Unit), Unit)
If it's not working, please post the full text of your expression or dimension.
-Rob

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Rob,
Thank you for your help! It works using the Aggr as a calculated Dimension. If I could tip you I would, but please accept my appreciation for your assistance. You have saved me from turning my laptop into a Frisbee.....
