Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
mrichman
Creator II
Creator II

How to reuse LET/SET variables to (re)calculate on the backend?

Hi Community! 

 

Is it possible to reuse LET/SET variables on the backend to (re)calculate and use the results again as new LET/SET variables? 

 

Example: 

 

LET  vVariable1 = 1+1  ;
LET vVariable2 = 3+3; 

LET vTotal = $(vVariable1) + $(vVariable2)  

or 

LET vTotal = vVariable1 + vVariable2

or 

LET vTotal = $(vVariable1 + vVariable2)

I have tried the 3 options and have expected to get 8, however I'm getting an error on the frontend. 

 

Could someone please help? Thanks in advance! 

Labels (2)
5 Replies
NZFei
Partner - Specialist
Partner - Specialist

What is the error?

jonathandienst
Partner - Champion III
Partner - Champion III

These statements are all legal, except the last. Did you include semi-colons at the end of

LET vTotal = $(vVariable1) + $(vVariable2);
LET vTotal = vVariable1 + vVariable2;

I prefer the latter myself as the expansion is not necessary here.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
mrichman
Creator II
Creator II
Author

Thanks for the reply. hmm wierd, I have tried both but still getting null as error even though my data has values. I'll check it further.
mrichman
Creator II
Creator II
Author

I'm getting null even though my values are filled 😞
NZFei
Partner - Specialist
Partner - Specialist

Working for me:

Variable in Script.PNG

 

 

22.PNG

 

 

 

 

 

 

33.PNG