Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Partner
Partner

Are expressions smartly handled (calculate each subcomponent once)?

Consider (without putting too much mind into it) the following Value Growth expression:

=$(=

'num(SUM({$<'

& if(vSelectFiscalFlag=0,'ccy','fcy')

& '={1}>} [Value])/SUM({$<'

& if(vSelectYTDFlag=0,if(vSelectFiscalFlag=0,'cpy','fpy'),if(vSelectFiscalFlag=0,'cpytd','fpytd'))

& '={1}>} [Value])-1,PercentageFormat)'

)

In practice, this is sum(current year value)/sum(previous year value-1.

This works well. The point is, that it is a respectably large to the eye AND the CPU calculation.

Now, if I want to concatenate a nice little unicode arrow to the end that shows whether it was positive or negative, I add this:

&

pick(

2+ sign

(

THE_ENTIRE_CALCULATION_FORMULA_AGAIN

),Chr(9660),'=',Chr(9650)

)


My question is: Is QV/QS smart enough to detect the same code twice....or, for the sake of displaying a simple arror, I am paying DOUBLE the cpu cost?


If the answer is the latter, is there any way to circumvent this?


1 Solution

Accepted Solutions
Highlighted
MVP
MVP

Qlik engine is smart enough to detect only if you write the same expression exactly same. I.e. sum(sales) and Sum(sales) would be different while it comes to detection and caching of the result. To avoid this confusion, you could define a variable for the expression and use it at multiple places.

View solution in original post

3 Replies
Highlighted
MVP
MVP

Qlik engine is smart enough to detect only if you write the same expression exactly same. I.e. sum(sales) and Sum(sales) would be different while it comes to detection and caching of the result. To avoid this confusion, you could define a variable for the expression and use it at multiple places.

View solution in original post

Highlighted
Partner
Partner

This is good! Is there any way that I can test this? Maybe, for example, I need to add a space or something in order to make them identical (and I want to avoid the variable solution, as I am drawing expression formulas from my database and keep the script mostly clean).

Highlighted
MVP
MVP

You can check the calculation time for each scenario. Sheet->Properties->Object-> 'Calc Time'  for the object.