Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
jcarpenter9
Partner - Creator
Partner - Creator

Using a variable in the script when it contains an = expression

I have a variable that contains an expression to calculate a date. In the background of this screenshot you can see a text box that correctly evaluates the expression as a date.

Picture1.png

But when I use the same variable in a load script, QlikView insists on inserting the expression itself into the script, not the evaluated results. What gives? The reference manual says that if the first character of a variable value is "=", QlikView will try to evaluate the value as a formula and insert the result.

I found that the script will evaluate the variable only if I remove the "=", but sheet objects evaluate the variable only if I include the "=" -- the exact opposite.

Am I missing something here?

3 Replies
erichshiino
Partner - Master
Partner - Master

Hi,

maybe you can create two versions of the same variable. One with the = and other without it.

Or you can call the variable on the sheet objects forcing a =

something like $(=variable1)

Hope it helps,

Erich

Not applicable

Are you using the keyword LET instead of SET?   If your loadscript statement is something like   LET myvar=YEARSTART(TODAY(2)-2);  then QlikView will evaluate the expression to the right of the equal sign and put the result into the variable. If you write the same statement using SET then QlikView will store the expression text in the variable without evaluating it.

jcarpenter9
Partner - Creator
Partner - Creator
Author

I understand the LET/SET distinction. However, the variable already contains the expression text starting with "=", so I thought the load script would replace the variable with the evaluated result. Instead, it inserts the expression itself into the script, which causes a syntax error.

I ended up coding LET vARCHIVE_DATE=YEARSTART(TODAY(2)-2); and then placing $(vARCHIVE_DATE) into the code later.

But this is not consistent with the way the reference manual says variables should operate.

Thanks for everyone's feedback.

James