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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
ramonarcusa36
Contributor III
Contributor III

Caching variables

Hey guys.

I have a simple question about performance and variable caching. Let's suppose I have these two expressions:

Expr1: Sum(Units)

Expr2: Sum(Dollars)

Now, let's suppose I want to calculate a third expressión: Price.

Expr3: Sum(Dollars) / Sum(Units)

As far as I'm concerned, if I want optimum performance I would write the third expression like this:

Expr3: Column(2) / Column(1)

And then, QlikView would just use the previously calculated expressions (Expr1 and Expr2), optimizing performance (labeled aliases would also do the trick).

But what happens if I use variables? Let's suppose this:

Expr1: $(vAmountOfUnits)

Expr2: $(vDollars)

Expr3: $(vDollars) / $(vAmountOfUnits)


In the third expression, would QlikView use the previously cached $(vAmountOfUnits) and $(vDollars)? Or since it's a totally different expression (even if it contains parts of previous ones) it would have to calculate units and dollars again? (Obviously, I know I could go with the Column(x) approach here too, but my real situation is far more complex than this; this is just a very simple example to find out how QlikView deals with variables and caches).


Thanks in advance!

Labels (1)
1 Reply
mikevwang
Contributor III
Contributor III

In your example, Expr3: $(vDollars) / $(vAmountOfUnits) will have the same caching as Expr3: Sum(Dollars) / Sum(Units).


When you use dollar expansion on a variable, the expansion itself does not get cached. Once it is expanded, everything is treated as normal. So basically the result of Sum(Units) and Sum(Dollars) will be cached and Sum(Dollars) / Sum(Units) will involve 2 cache lookups. Using variables to store the expressions do not change how caching will be done.