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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Nested variable - sum of variables

Hi,

I've been trying to do some research on the forums but I was unable to find something similar.

Is it possible to define a variable to be the sum of two other variables or the result of any kind of math operation between two variables?

Thanks for your help.

1 Solution

Accepted Solutions
m_woolf
Master II
Master II

Define vVarSum as:

=$(vVar1)+$(vVar2)

View solution in original post

4 Replies
m_woolf
Master II
Master II

Define vVarSum as:

=$(vVar1)+$(vVar2)

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

From the script you can have something like this

LET vSumTest_1 = 2;

LET vSumTest_2 = 10;

LET vFinal_Sum = vSumTest_1 + vSumTest_2;

petter
Partner - Champion III
Partner - Champion III

Variables can reference each other just like cells in a spreadsheet application can reference each other. QlikView will parse and recalculate all dependent variables for every recalculation which is done - usually at every click or selection or change of selections.

If variable v1 has the value 45 and v2 has the value 56  nd v3 has the value (expression)   =v1+v2

Then the variable v3 when it is used in any kind of expression will return 101. I think you can reference variables in any number of levels and it will recalculate correctly - just like a modern spreadsheet - no big deal.

The $-sign expansion is needed when you need to force an evaluation - but many Qlik developers use it more than needed when a simple direct reference to the variable is sufficient.

Not applicable
Author

Thanks everyone for your help.

Petter, great explanation. Thanks for your time.