Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
alec1982
Specialist II
Specialist II

Variable and Set analysis

hi all,

trying to set a variable with the following expression

Set vYFactor = if(GetSelectedCount([X_Factor.Location])=0, only({<[X_Factor.Location]={"=$(vAverage)"}>}[X_Factor.Storage Paid]), only([X_Factor.Storage Paid]);

when I try to present it in a text box I dont get any value

any idea?

Labels (1)
13 Replies
sunny_talwar
MVP
MVP

Are you doing this in the script?

You might need to replace $ with something else (#) before and replace # with $ again in the script:

SET vYFactor = Replace('If(GetSelectedCount([X_Factor.Location])=0, only({<[X_Factor.Location]={"=#(vAverage)"}>}[X_Factor.Storage Paid]), only([X_Factor.Storage Paid])', '#', '$');

alec1982
Specialist II
Specialist II
Author

thank you Sunny..

here is how my two variables looks like now on the script:

set vAverage= '=Average';

SET vYFactor = Replace('If(GetSelectedCount([X_Factor.Location])=0, only({<[X_Factor.Location]={"=#(vAverage)"}>}[X_Factor.Storage Paid]), only([X_Factor.Storage Paid])', '#', '$');

do they look right to you?

Also what should i use inside the text box?

sunny_talwar
MVP
MVP

To tell you the truth, I know $() in script variables give problem because they get evaluated. So replace is the solution to get around that, but I have never tried it on my own. I have seen Stefan providing solution to this on various occasions, let me see if I can find one of his responses.

sunny_talwar
MVP
MVP

sunny_talwar
MVP
MVP

So try something like this instead:

LET vYFactor = 'If(GetSelectedCount([X_Factor.Location])=0, only({<[X_Factor.Location]={"=$' & '#(vAverage)"}>}[X_Factor.Storage Paid]), only([X_Factor.Storage Paid])', '#', '$')';

alec1982
Specialist II
Specialist II
Author

i think your solution is fine. the only issue on it is the value inside the set analysis to be 'Average'...

alec1982
Specialist II
Specialist II
Author

but not sure how I can do that...

sunny_talwar
MVP
MVP

What is the Average used for?

alec1982
Specialist II
Specialist II
Author

just want to pass the value which is 'Average' in set analysis