Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Referencing Expression in SET ANALYSIS

 

I am trying to reference an Expression within SET ANALYSIS, but I am having some difficulties.

 

I have an expressions as follows:

SET IRRAdverseCase =

IF(Region = 'Canada Region',
'Scenario I',
IF(Region = 'US Region',
'Scenario I',
'Scenario II')) ;

I then have an equation, which references the previous expression:

 

SUM(
{<
Scenario = {'$(IRRAdverseCase)'}
>}
[ParCr])

 

When I try to evaluate the expression, it comes up as zero (0). However, if I hard code the Scenario as follows, it produces the correct result:

 

SUM(
{<
Scenario = {'Scenario I'}
>}
[ParCr])

 

I am wondering if anyone knows why this is happening. I would appreciate some help with referencing the Scenario, as opposed to hard coding it because it could change.

 

17 Replies
Anonymous
Not applicable
Author

Please note that I have updated the description to include the equation.

I am thinking that the issue is because I already have quotes in the IF statement for the variable 'IRRAdverseCase ', but I could be wrong

sunny_talwar

So you will have only one region selected when you plan to look at this?

Anonymous
Not applicable
Author

I think we need to see what your variable really is.  And see what it is evaluating to.

Sounds like the issue may not be in your set analysis expression but in your variable evaluation.

sunny_talwar

May be try this

=SUM(

{<

Scenario = {'$(=$(IRRAdverseCase))'}

>}

[ParCr])

When US Region or Canada Region is selected

Capture.PNG

When Asia Region is selected

Capture.PNG

Anonymous
Not applicable
Author

Please note that when I look at the Variable Overview, it just has the equation:

IF(Region = 'Canada Region',
'Scenario I',
IF(Region = 'US Region',
'Scenario I',
'Scenario II'))

sunny_talwar

Try this (sample attached in one of the below posts)

=SUM(

{<

Scenario = {'$(=$(IRRAdverseCase))'}

>}

[ParCr])

Anonymous
Not applicable
Author

Thank you very much! This worked perfectly.

For my own knowledge, why would I have to put in a double $?

sunny_talwar

I guess the issue is that your variable isn't defined with an equal sign, so it needs to be evaluated before it can bed used in the set analysis syntax...

So inner set analysis evaluates it to 'Scenario I' and outer one is used for set analysis...

Alternatively you can define your variable like this

SET IRRAdverseCase = =IF(Region = 'Canada Region', 'Scenario I', IF(Region = 'US Region', 'Scenario I', 'Scenario II'));

And then this should work

=SUM(

{<

Scenario = {'$(=IRRAdverseCase)'}

>}

[ParCr])

Inner dollar sign expansion is not needed because you have an equal sign in your set statement.