Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
wallerjc
Partner - Contributor III
Partner - Contributor III

Variable fails when contains "/":

Hi, I'm trying to create a variable like so:

Let vTest = sum(Sales)/5

can you tell me why this would produce a script error?

The actual variable I want to create it much more complex, and works fine in the Variables window, but when I try and port to the LOAD script, it will always fail whilst using "/" in it.

1 Solution

Accepted Solutions
awhitfield
Partner - Champion
Partner - Champion

Hi James, try SET instead,

see simple example attached

SET vTest = sum(Sales)/5;

DATA:
Load * Inline
[
Sales
1000
]
;

Text box with expression =$(vTest) give a result of 200

HTH Andy

View solution in original post

5 Replies
MayilVahanan

Hi

Try like this

Set vTest = sum(Sales)/5;


In front end, try like this

= $(vTest)

In back end also , u can try like

Load $(vTest) , ID resident tablename group by ID;

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
awhitfield
Partner - Champion
Partner - Champion

Hi James, try SET instead,

see simple example attached

SET vTest = sum(Sales)/5;

DATA:
Load * Inline
[
Sales
1000
]
;

Text box with expression =$(vTest) give a result of 200

HTH Andy

wallerjc
Partner - Contributor III
Partner - Contributor III
Author

Thanks for your response


Set vTest = sum(Sales)/5;


Produces "Script Line Error" when I RELOAD the document

My exact code loosk like this, if it matters: let vSI_CPC = sum(Comps.SpendDollers)/5;



wallerjc
Partner - Contributor III
Partner - Contributor III
Author

This is the correct answer, I don't suppose you know WHY it's like this? Surely it can evaluate a divide by at runtime?

awhitfield
Partner - Champion
Partner - Champion

LET will tin effect try and evaluate the expression when the variable's created and the sales data won't exist until the reload is completed.

See the attached link

https://community.qlik.com/thread/47712

Andy