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: 
fj11
Contributor
Contributor

Set analysis

Hi,

I have below data:

Class1 = 11

Class2 = 15

Note : sum of values of class1 must be multiplied by 1

And sum of values of class2 must be multiplied by -1

Currently  I am using set analysis expression as below to get the desired data:

Sum({< class = class1 >} value) + (sum({< class = class2>} value))*-1

How do I merge this two sets into one set analysis expression ?

Labels (3)
1 Solution

Accepted Solutions
sunny_talwar

Set analysis within a single expression won't work because set analysis within a single expression cannot dictate if a range needs to be multiplied by 1 and the other range by -1... Either you have to use the if statement provided by @StarinieriG  or use it as 2 set analysis expression like you have listed.

View solution in original post

5 Replies
StarinieriG
Partner - Specialist
Partner - Specialist

Hi

 

try to use 

Sum(If(class='class1',1,-1)*value)

instead of set analysis

fj11
Contributor
Contributor
Author

Hi,

I need to add the sum for both the classes. This expression won't work in
my case.
It will work only for one class.
I need this in set expression itself
fj11
Contributor
Contributor
Author

Let me elaborate more on this:

I have dynamic set parameters passed in my set analysis.

Abv thing which i had mentioned is just for illustration purpose.

I have set analysis expression as

Sum({< class = { $(class1), $(class2)} , year  = max(year), version=  15>}, value)

But this gives me wrong value since this expression directly sums up two classes .

But my requirement is to multiply first passed classby 1 and second one by -1.

Class1 and class2 are variable and are dynamic

sunny_talwar

Set analysis within a single expression won't work because set analysis within a single expression cannot dictate if a range needs to be multiplied by 1 and the other range by -1... Either you have to use the if statement provided by @StarinieriG  or use it as 2 set analysis expression like you have listed.

fj11
Contributor
Contributor
Author

Ok. Thanks