Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
tobias_klett
Partner
Partner

SET Variable evaluates "$()" Statement

Hello,

my problem is that any Statement using "$(...)" is evaluated within a SET Variable line.

For multiusage purposes I put a chart expression into a variable/constant. I do this already in the script like this:

SET vTestVariable = sum( { < MONTHNUM = {"$(=max(MONTH))"} > } VALUE)

QlikView tries to evaluate the "$(=max(MONTH))" part even though it's a SET Statement. The evaluation failes and throws an internal error.

Thanks for any advice

Tobias

1 Solution

Accepted Solutions
Not applicable

If you can't use a subsitute character and replace it later, then another option is to put the expression in a csv file, and load the csv file, and set the variable in the script.

Say you have a csv file:

VariableName, VariableValue

vTestVariable, sum( { < MONTHNUM = {"$(=max(MONTH))"} > } VALUE)

Then load the file into a table and set the variable in the script:

LET var = peek('VariableName', 0, 'VariableTable');

LET $(var) = peek('VariableValue', 0, 'VariableTable');

View solution in original post

8 Replies
jsn
Master
Master

Hm, that's a bit annoying..

You can work around it like this but it's not very elegant:

SET vTestVariable = sum( { < MONTHNUM = {"@(=max(MONTH))"} > } VALUE);

LET vTestVariable = replace(vTestVariable, '@', '$');

whiteline
Master II
Master II

Hi.

LET vTestVariable = 'sum( { < MONTHNUM = {' & chr(36) & '(=max(MONTH))' & '} > } VALUE)';

tobias_klett
Partner
Partner
Author

Hi whiteline,

thanks for your suggestion. But it is not helpful for me since the original expression is very long and has many highcommas which would force me to make it very complicated.

whiteline
Master II
Master II

In this case you could use Ctrl+H to replace $ with some other unique symbol as Johannes suggested.

Not applicable

If you can't use a subsitute character and replace it later, then another option is to put the expression in a csv file, and load the csv file, and set the variable in the script.

Say you have a csv file:

VariableName, VariableValue

vTestVariable, sum( { < MONTHNUM = {"$(=max(MONTH))"} > } VALUE)

Then load the file into a table and set the variable in the script:

LET var = peek('VariableName', 0, 'VariableTable');

LET $(var) = peek('VariableValue', 0, 'VariableTable');

View solution in original post

whiteline
Master II
Master II

In this case isn't it easier to use inline load ?

tobias_klett
Partner
Partner
Author

Hi vhuynh,

that is an excellent idea, because I have a excel configuration file already. And this way I will maintain my variables on a sheet of the configuration file and read them into the application looping over the lines of the variabletable.

Not applicable

The $() syntax will evaluate in an inline table (actually, the dollar sign expansion will occur whenever it is found in the qvs script). Since $(=) has no meaning in a load script, $(=) will expand to an error.