Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Coming your way, the Qlik Data Revolution Virtual Summit. October 27-29. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor III
Contributor III

How to Calculate Cumulative Sum in the Script ?

Hello Everyone ,

I need help creating the cumulative Sum  column (in red) is script,  as shown in the table below.

How to write a script to get cumulative Sum column?

Thanks

ROW_NUMORDER_DATEORDER_AMOUNTCumulative Sum
123/02/2017260260
223/02/2017100360
325/06/201750410
417/08/2017495905
517/08/20171001005
624/10/201701005
724/10/20171751180
817/01/201801180
918/01/20183951575
1024/01/20181001675
1113/02/20181001775
1212/03/20181001875
1318/04/20181752050
1410/05/20181002150
1510/05/20187802930
1610/05/20181003030
1729/05/20181503180

 

1 Solution

Accepted Solutions
Highlighted
Creator II
Creator II

Hi @adimiz123,

In load editor you can use RangeSum() and Peek(). 

 

 

TABLE:
LOAD ROW_NUM,ORDER_DATE, ORDER_AMOUNT, RangeSum(peek('Cumulative') , ORDER_AMOUNT) AS Cumulative INLINE [
ROW_NUM,	ORDER_DATE,	ORDER_AMOUNT,	
1,	23/02/2017,	260,
2,	23/02/2017,	100,
3,	25/06/2017,	50,
4,	17/08/2017,	495,
5,	17/08/2017,	100,
6,	24/10/2017,	0,
7,	24/10/2017,	175,
8,	17/01/2018,	0,
9,	18/01/2018,	395,
10,	24/01/2018,	100,
11,	13/02/2018,	100,
12,	12/03/2018,	100,
13,	18/04/2018,	175,
14,	10/05/2018,	100,
15,	10/05/2018,	780,
16,	10/05/2018,	100,
17,	29/05/2018,	150
];

 

 

 

I hope helps you.

 

Regards

 

Ezir

View solution in original post

2 Replies
Highlighted
Creator II
Creator II

Hi @adimiz123,

In load editor you can use RangeSum() and Peek(). 

 

 

TABLE:
LOAD ROW_NUM,ORDER_DATE, ORDER_AMOUNT, RangeSum(peek('Cumulative') , ORDER_AMOUNT) AS Cumulative INLINE [
ROW_NUM,	ORDER_DATE,	ORDER_AMOUNT,	
1,	23/02/2017,	260,
2,	23/02/2017,	100,
3,	25/06/2017,	50,
4,	17/08/2017,	495,
5,	17/08/2017,	100,
6,	24/10/2017,	0,
7,	24/10/2017,	175,
8,	17/01/2018,	0,
9,	18/01/2018,	395,
10,	24/01/2018,	100,
11,	13/02/2018,	100,
12,	12/03/2018,	100,
13,	18/04/2018,	175,
14,	10/05/2018,	100,
15,	10/05/2018,	780,
16,	10/05/2018,	100,
17,	29/05/2018,	150
];

 

 

 

I hope helps you.

 

Regards

 

Ezir

View solution in original post

Highlighted
Contributor III
Contributor III

Thanks !!!