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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variables in Chart Expressions

I would like to assign an expression value to a variable for a pivot object and then use an if condition to assign a qmem image based on the expression value computed. In pseudo code here is what I am thinking for the chart expression:

result = <SET ANALYSIS AGGREGATION>

if($result > 0.2, 'img1', if($result < 0.2, 'img2', 'img3'))

Where result is a variable that I will SET in the main script. There are 2 reason I would like to do this:

1. Perform the set analysis calculation only once and then use the result for conditional match, instead of recomputing the result for every IF condition that fails ie. if(<SET ANALYSIS AGGREGATION> > 0.2, 'img1', if(<SET ANALYSIS AGGREGATION> < 0.2, 'img2', 'img3'))

2. Avoid repeating the expression for every IF condition, I believe this can be achieved using 'functions' but my primary concern is performance hit for invoking the set analysis aggregation multiple times (#1)

1 Reply
prieper
Master II
Master II

You may have a variable created in the application, which contains the result of your calculations. It might be a bit easier for maintenance, as you do not need to fiddle in the script in case of changes. You then can refer to this variable as you have described (think you need to refer to it with the syntax $(Variable), think it will not work without the brackets.

HTH
Peter