Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello dear, I leave the following query
Why when I add an expression as a variable in the script, does it give me an error and if I do it from the variable panel is it ok?
The inconvenience I have with the expressions that contain set analysis, is it possible to do it?
Issue:
Any suggestion?
Thanks!
I found an interesting solution:
with this script you can load expressions from excel, since there are no problems with single quotes, it is also much easier to administer
Variable Table:
LOAD Variable,
Expression
DESDE
[C: \ Nube \ Wicham \ EQonomia \ Variables.xlsx]
(ooxml, embedded labels, table is Sheet1);
let CantVariables = NoOfRows ('Variable Table');
for i = 0 to (CantVariables-1)
let vVariable = Peek ('Variable', i, 'TableVariables');
let $ (vVariable) = Peek ('Expression', i, 'TableVariables');
NEXT
Thanks both!
It would help if you posted the part of the script that generated that. Most of use can't mind-read qlikview documents on other peoples computers.
What is going wrong are the single quotes. You need to either escape using double single quotes or chr(39) or another placeholder character that you later replace with the single quote
SET vMyVar = sum({<B={ @C@ }>} A);
LET vMyVar = Replace($(vMyVar), '@', chr(39));
But you're not done yet because $(...something...) will be evaluated in the script too and you don't want that. So you can use the replace trick again
LET vMyVar = 'sum({<B={ @C@ }, D={"<=%(=max(E))"}>} A)';
LET vMyVar = Replace(Replace($(vMyVar), '@', chr(39)),'%','$');
the problem is the single quote which tells the script that it is at the start or the end of a piece of text, so you need to swap that for a chr() reference such as:
VariableName = 'Sum({$<DistributionID={' & chr(39) & '143.3 etc etc etc
It can become quite long winded doing this in the script, but its the only way I've found to make it work.
I found an interesting solution:
with this script you can load expressions from excel, since there are no problems with single quotes, it is also much easier to administer
Variable Table:
LOAD Variable,
Expression
DESDE
[C: \ Nube \ Wicham \ EQonomia \ Variables.xlsx]
(ooxml, embedded labels, table is Sheet1);
let CantVariables = NoOfRows ('Variable Table');
for i = 0 to (CantVariables-1)
let vVariable = Peek ('Variable', i, 'TableVariables');
let $ (vVariable) = Peek ('Expression', i, 'TableVariables');
NEXT
Thanks both!