Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have big document and many variables defined in it and I have some charts that use variables in expressions. For example in one chart I use expression "$(var1)/$(var2)" in few places (expression, calculated color etc). I'd like to make another variable containing this expression - will it be then calculated once and used in all this places, or it will be calculated each time again?
When I have so many complicated variables - are they calculated every time I select something, or only just before display?
I have few variables that are used in other variables, that are used in some expressions/variables... for example:
var1=fnc(xval);
var2=fncx(var1)*y;
expression=var2*fncy(varxx);
How QV handles such constructions? Is there any way to do an INLINE variable? (like inline functions in C++) So when I write such expression as above, QV will see it directly as "exploded" form "fncx(fnc(xval))*y*fncy(varxx);" ? It is easier to maintain the variables when they are splitted to smaller ones (and used in many other expressions), but the performance of the document is verry poor...
Borys
QlikView will wait to evaluate the expression until it needs to be calculated. If you create a variable (var3) for your first example, you can set it's value to: "=var1/var2"
Then in an expression, use: "$(var3)" and whenever the overall expression is evaluated, your variable expression will be evaluated based on context.
I guess what I'm trying to say is that QlikView variables can work how you describe. I haven't heard anything about performance issues when using nested variables.
Yeah, I can't imagine why using variables would ever cause performance issues. I do expect that var3 will be expanded and evaluated separately every time QlikView sees it. However, given that the expansion should be a trivial task, and QlikView would have to evaluate the resulting expression whether it came from a variable or not, I don't see how being a variable would cause problems. But I've been wrong about QlikView's internals and expected performance before. 🙂
I also didn't thought that nested variables could make performance problems... till I saw it on live application...
I use Memory Statistics to check the time of calculation of objects (but in this case I also can see it with my eyes) - I have a chart with "formula" using variables used in expression, colour calculation and "text in chart" - simmilar formula, using the same variables (some of this variables are also calculated from other variables). When I compare calculation time of the formulas in short form (using defined variables) with "exploded" ones, the second chart has calculation time even 20 times less than in first form.... strange, but true (I'm sorry, but I cannot give You the working example of it...)
Borys.
... and I'll be wrong again. I find it very disturbing that it can be significantly slower with variables. It certainly doesn't seem like it should be. I may have to experiment, and maybe send something to support if I can come up with a good example.