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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
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 (2)
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