Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Usage of variables defining expressions in charts

I am planning to use the following approach:

Define variables for the set expressions and calculation:

vSet1 = '{<Year={only(Year)},Month=>}

vCalc1 = '[cost]*[units]-[discount]'

and then use something like this (not for simple calculation formulas).

SUM(TOTAL $(vSet1) $(vCalc1))

to define the expressions in charts.

I first experience is that the set definition are reused very often in one shhet.

My questions as I am new to QlikView:

Will this approach have impact on the performance compared to direct definition of the expression?

Is this "too much" usage of variable already?

What is you opinion?

Any feedback is appreciated.

Thanks

Norbert

4 Replies
Not applicable
Author

I beleive best practice is to use variables to calculate a value on fly and get it into expression. By using variable to define strings sound like a good idea if you have large number (20+) spots where you use these. However, as far as performance goes, i do not think it would carry a lag. If I were you, I would do direct coding unless I wanted to keep flexibility of editing the variables at later stage. Please share results if you do any performance testing on this,

Anonymous
Not applicable
Author

Your idea by making variables for reuse reasons is best pratice.

I dont think it will slow performance either, cause i belive that the syntax is done on expression level and not on row level.

So go for it!

You should think of a naming convention for you variables, cause you can end up with a lot of them. I use this standard:

v(variablename) for variables used in scripts.

uv(variablename) for variables used in the frontend. uv stands for user variable.

gv(variablename) for variables that is generic in my qlikview enviroment.

Never use spaces, undersscore is ok.

Henrik

jagan
Luminary Alumni
Luminary Alumni

Hi,

Please check attached file for the same you required in variables. 

I think using variables does have very very very small impact on the performance compared to direct definition of the expression.  Below URL explains you the same

http://www.qlikfix.com/2011/06/21/testing-the-performance-implications-of-variables-and-label-refere...

Hope this helps you.

Anonymous
Not applicable
Author

I want to share my recent experience that is somewhat relevant.
Variables used in expressions used in "show sheet" conditions do slow the opening of the QV document.  I think the reason is that all these variables have to be calculated every time document opens.

Regards,
Michael