Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
March 11, 2PM EST: Do More with Qlik - Getting Started wtih Qlik Sense SaaS - Redux. REGISTER NOW
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
xufei123
Partner
Partner

What is the error?

jonathandienst

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

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

I'm getting null even though my values are filled 😞
xufei123
Partner
Partner

Working for me:

Variable in Script.PNG

 

 

22.PNG

 

 

 

 

 

 

33.PNG