Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Coming Aug. 9: New Simplified Authoring for Qlik Sense SaaS – For Details, CLICK HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

variables within variables in load script

Hi everybody,

I'm in trouble with variables. I would like to load both chart expressions and set expressions in load script,

smth like this:

set vSet=2; // or  1, or '<=3';

set vExpr=sum({$<klient ={$(vSet)}>} käive);

Then the variable vSet should change it's value according to user selection- f.e.  klient=1, 2 , less than 3.

The variable change has to be made by button or other  action, not field selection. Variable vSet can if fact contain some kind of syntax as well, as its value will not be directly visible to user.

The problem is - when i enter vExpr into Variables Overview window, and create the input box with vSet, it works as needed, i can enter 1,2 or '<=3'.

But when i load the same expr from load script, it evaluates $(vSet) at load time and writes f.e value 1 into the expression.

so i get

sum({$<klient ={1}>} käive) as vExpr.

I tried all possible combinations of syntax but it gets evaluated, and later changes in vSet value from UI do not change the expression and chart. Can someone point me to the right direction, plz!




1 Solution

Accepted Solutions
sunny_talwar

Just a thought, but what if you try this?

Let vExpr1 = Replace('Sum({$<klient={@(vSet)}>} käive)', '@', Chr(36));

View solution in original post

6 Replies
sunny_talwar

May be this:

set vSet=2; // or  1, or '<=3';

set vExpr=sum({$<klient ={@(vSet)}>} käive);

set vExpr2 = Replace($(vExpr), '@', Chr(36));

Not applicable
Author

Thanks,

i got it work like this:

set vSet=1;

set vExpr1 = "sum({$<klient={@(vSet)}>} käive)";

let vExpr = replace(vExpr1,'@',Chr(36));

but it takes 2 lines in script and 2 variables where i have 20+ expressions and growing, sharing the vSet but different expressions. Perhaps it is possible to reduce it to 1 variable?

sunny_talwar

Just a thought, but what if you try this?

Let vExpr1 = Replace('Sum({$<klient={@(vSet)}>} käive)', '@', Chr(36));

Not applicable
Author

yep. Than you.

I spent 2 days on this.

Perhaps someone knows the shorter way?

sunny_talwar

Hahahaha no problem

I am glad I was able to help.

Best,

Sunny

zanoni_fercam
Contributor
Contributor

i solved with:

Let vExpr1 = 'Sum({$<klient={'&Chr(36)&'(vSet)}>} käive)';