Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Set Analysis with function Variable

Hi everyone,

Is it possible use set analysis with function Variable.

Other words,

vVar1=sum(Variable)

in expression: sum({<Variable2={'...'}>} vVar1)

Thanks,

1 Solution

Accepted Solutions
vgutkovsky
Master II
Master II

You're right, you can't pass set analysis into a variable while evaluating the variable as an expression because the expression $(myVar) is already an evaluation. But the solution above should work just as well.

Regards,

Vlad

View solution in original post

7 Replies
dt_g_tsar
Partner - Contributor II
Partner - Contributor II

Hello Vladimir,

You can indeed. Just make sure that your variable holds the expression without a '=' if you are defining it in Settings-Variable Overview and inside single quotes if you define in the loading script.

vVar1='sum(Variable)';

You then refer to it in your expression in the following manner.

sum({<Variable2={'...'}>} $(vVar1))

George

vgutkovsky
Master II
Master II

If I understand you correctly, you're asking if it's possible to separately store the expression variable and the set analysis variable. Indeed it is, and it makes life a lot easier in terms of management. However, you can only assign a field value in set analysis, not a variable value. So something like this:

vVar1 (make sure this does not start with an = sign)

sum($(vVar2) myfield)

vVar2 (make sure this does start with an = sign)

='{<' & 'myfilter={' & chr(39) & 'ABC' & chr(39) & '}>}'

Expression

$(vVar1)

Hope this helps,

Vlad

Anonymous
Not applicable
Author

Hi Vlad,

Thank for your help.

I have expression like this

myVar:

Round ((Count({<[Overall experience]={'9-10'}>}[Overall experience])-Count({<[Overall experience]={'0-6'}>}[Overall experience]))/

count(TOTAL [Overall experience]),0.001)*100

I want to use it depended on variable-Country.

round(SET ANALYSIS Country) myVar)

I think conditional and myVar don`t work together.

Am I right

Regards,

vgutkovsky
Master II
Master II

How about something like this:

Round ((Count({<[Overall experience]={'9-10'},Country={$(vCountry)}>}[Overall experience])-Count({<[Overall experience]={'0-6'},Country={$(vCountry)}>}[Overall experience]))/

count({<Country={$(vCountry)}>}TOTAL [Overall experience]),0.001)*100

This assumes that your field is called Country and your variable that contains the relevant country is called vCountry.

Vlad

Anonymous
Not applicable
Author

It should work.

the question was possible to use Variable and SET ANALYSIS.

I think it doesnt work

Thanks,

vgutkovsky
Master II
Master II

You're right, you can't pass set analysis into a variable while evaluating the variable as an expression because the expression $(myVar) is already an evaluation. But the solution above should work just as well.

Regards,

Vlad

Anonymous
Not applicable
Author

Thank you for confirmation