Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Husky_Bab12
Contributor
Contributor

Using two conditions in set analysis

Hi,

I'm trying to implement two conditions in set analysis as below,

=sum({<[Arrived Run Total]={">=0"} , [RunTot_Quantity]={"<0"}>} Quantity).

I need to sum all the quantities when the corresponding [Arrived_run Total] >=0 and [RunTot_Quantity]>0.

I'm trying to do it but unable to achieve the expected result.

I'm just able to add the quantities which has [Arrived Run Total] >=0 leaving out quantites which has [RunTot_quantity]>0.


Can someone help here?


Labels (1)
1 Solution

Accepted Solutions
Digvijay_Singh

Do you want to add whichever has total sum positive?

=sum({<[Arrived Run Total]={"= Sum([Arrived Run Total])>= 0"} > +

<[RunTot_Quantity]={"= Sum([RunTot_Quantity])>= 0"}>} Quantity)

View solution in original post

10 Replies
luizcdepaula
Creator III
Creator III

Hi, 

Try the below:

=sum({<[Arrived Run Total]={"= Sum([Arrived Run Total])> 0"} , [RunTot_Quantity]={"= Sum([RunTot_Quantity])> 0"}>} Quantity)

Cheers,

Luiz

Husky_Bab12
Contributor
Contributor
Author

I tried its not working.

Sorry i should have explained properly.

I need to sum quantity even when either of field is 0 values.

The above gives me sum of both arrived run total and run total quantity.

But its not giving total sum when either of the field is not present.

Expected,
arrived = 100, run total=50 , total  150

arrived = 0. run = 150 ,  total  150

arrived = 15, run = 0, total  15

Your formula,

total= 150

total=0

total=0

 

luizcdepaula
Creator III
Creator III

=sum({<[Arrived Run Total]={"= Sum([Arrived Run Total])>= 0"} , [RunTot_Quantity]={"= Sum([RunTot_Quantity])>= 0"}>} Quantity)

Digvijay_Singh

Do you want to add whichever has total sum positive?

=sum({<[Arrived Run Total]={"= Sum([Arrived Run Total])>= 0"} > +

<[RunTot_Quantity]={"= Sum([RunTot_Quantity])>= 0"}>} Quantity)

Husky_Bab12
Contributor
Contributor
Author

Yes, thank you for sharing the answer.

Husky_Bab12
Contributor
Contributor
Author

Now, I need to add the sum of quantity which don't have total sum positive. How can i modify the above formula?

Digvijay_Singh

not sure if this is what expected - 

=sum({<[Arrived Run Total]={"= Sum([Arrived Run Total])< 0"} > +

<[RunTot_Quantity]={"= Sum([RunTot_Quantity])< 0"}>} Quantity)

Husky_Bab12
Contributor
Contributor
Author

I tried that it gives me entire sum of quantity. expected - we have total sum negative only values

luizcdepaula
Creator III
Creator III

Is that an issue or the negative values on the sum is expected as well?