Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
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;
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
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;
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?
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