Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
jduluc12
Creator
Creator

Cumulative sum in pivot table.

Hi,

My data set looks like this

IDNameItemdebitCreditperc
1custAItemA10020.01
1custAItemB4020.07
1custBItemA3016.08
2CustAItemC208.05
2CustCItemB3010.06
3CustBItemA3015.03
3CustAItemB2010.06
3CustCItemC2010.08

My pivot table should look like this

IdNameItem(debit-credit) * perc
1custAItemA((100 -20) * .01) = 0.8
ItemB((40-20) * .07) =  1.4
CustBItemA ((30-16) * .08) = 1.12
Total((100 -20) * .01) + ((40-20) * .07) + ((30-16) * .08)=  0.8+ 1.4 + 1.12 = 3.32

and so on.

it is not a simple sum((debit-credit) * perc).

It requires, may rangesum and aggr.

I am trying but i am not able to get the right expression.

Please help.

Thanks,

Jean

2 Replies
vishsaggi
Champion III
Champion III

Try this as your expr in your pivot and in presentation tab check Show Partial sums for the dimensions ID and Name.

= Sum(Aggr(Sum(debit - Credit) * perc, ID, Name, Item))

Capture.PNG

jduluc12
Creator
Creator
Author

do you think this can also work out

= Sum(Aggr((Sum({<Tran={1}>}debit) - Sum({<Tran={2}>}Credit) )* perc, ID, Name, Item))

If we add Tran as one column?