Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
kevpickering
Contributor III
Contributor III

Expression Variables - Performance comparison

Hi All,

I've created a variable called, say, eAllSales and defined it as =Sum(Sales).

There are 2 ways of using this variable in other expressions and both return the same answer:-

$(=eAllSales) and eAllSales.

My question is do with performance.

Every time I click and change list box values the value of the expression variable changes, as expected. But, what I'm needing to know is what is happening under the hood when I use $(=eAllSales) and eAllSales.

Whenever a change is made, the expression Sum(Sales) gets re-calculated and the variable eSumSales gets updated with this result.

If I use eAllSales, does the current value in eAllSales get returned (or does the expression Sum(Sales) have to be calculated again before returning the result).

Similarly with $(=eAllSales), does the current value itself get returned (or does the expression Sum(Sales) have to be calculated again before returning the result).

I use this in a number of places within the same sheet and I'm hoping the variable gets updated only once, whenever changes are made, and calling the variable doesn't incur any overhead of having to re-evaluate every time it is referenced.

Thanks for any help in this.

1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

It depends on the defintion eAllSales. If the def is

sum(Sales)

it will be evaluated in the chart expression.

If the def is

=sum(Sales)

it will be evaluated once and the value 123 will be substitued in the expression.

There is a performance difference, but also a logic difference. If you want to evaluate per dimension, you need to define it without the = and evaluate in the  chart.

-Rob

View solution in original post

3 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If the "=" is part of the variable defintion, it will be evaluated only once -- each time selections change. The value of the variable will then be a number, like 123.

If you use the variable reference directly:

eAllSales

you are just substituting 123 into the expression.

If you reference the var with an = like:

=eAllSales

you are causing =123 to be evaluated. That's an unnecessary evaluation, but may not be enough to notice.

-Rob

kevpickering
Contributor III
Contributor III
Author

Thanks Rob, very quick reply, appreciated.

Just to be clear.....

In Set modifiers I have to use syntax Max({$<Sales={$(eAllSales)}> field)

With this syntax, 123 is returned but is it after evaluating Sum(Sales) again (which is how the variable eAllSales is defined), or does it simply reference the variable and return it's content without evaluating Sum(Sales).

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

It depends on the defintion eAllSales. If the def is

sum(Sales)

it will be evaluated in the chart expression.

If the def is

=sum(Sales)

it will be evaluated once and the value 123 will be substitued in the expression.

There is a performance difference, but also a logic difference. If you want to evaluate per dimension, you need to define it without the = and evaluate in the  chart.

-Rob