Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sum only when the sum of two rows is positive

Hi all..

I have a table with this layout

Id
dateNum1
Num 2Total
1xx1011-1
2xx14104
3xx20614
total


18 (-1 shouldn't be sum)

I want a table that only show the sum where num1 is greater than num2. The total would be the sum of that condition. Can this be achieved on any type of table?

Thanks

3 Replies
Gysbert_Wassenaar

Try:

if(Dimensionality()=0,

sum(aggr(if(sum(Num1-[Num 2])>0,sum(Num1-[Num 2]),0),Id,date))

,sum(Num1-[Num 2]))


talk is cheap, supply exceeds demand
Not applicable
Author

It almost did the job. this example maybe didn't help a lot, but with a little change to:

sum(num1)-sum(num2) did the trick. thanks!

Not applicable
Author

Try this,

Sum({<Total={">0"}>}Total)