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

Announcements
AWS Degraded - You may experience Community slowness, timeouts, or trouble accessing: LATEST HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Storing list-box selection into a variable for use in calculated dimension

Hi guys. I have a very complicated chart I'm trying to build. To ensure the numbers come out right, I need to ignore the user selections using Set Analysis. I created a calculated dimension, and I want to use the selection of one list box in the calculation. Is there a way to store the selection for a single list box (if only one item is selected) into a variable and then refer to it in the if-statement in my calculated dimension? Let me know if that makes sense. When the user picks an item in a list box, I want it to update a variable. In my chart, I want to refer to that variable in the calculation and update when the user chooses an item in the list-box.

Thanks!

Eric

1 Reply
Not applicable
Author

To get the selected value of a field, use:

GetFieldSelections(FIELD)
If only one value is selected, that value will be the result, otherwise, you get a comma separated list. You can set your variable to that expression and it will evaluate to the value.

You could also use Max(FIELD) to do something similar. That will always give you one value. If the user has made one selection in the FIELD, setting your variable to that expression will give you the selection.

To refer to a variable in an expression, use a dollar sign expansion. I'm not sure what type of expression you are going for using the variable, but if you give an example, someone should be able to give you the expression you need.

For example, if you have a field containing different fact fields (Sales, Profit, Revenue), then you can use an expression like this to evaluate based on the selection:

Sum($(vFact))