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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Cumulative sum

Hi,

I have a question regarding cumulative sum of the data. I want to realize the following function:

original table:

a
1
1
1

Output table:

aobsCum
111
21
132
143
53

Anyone can help?

Thanks!

10 Replies
Not applicable
Author

can you post some sample data please. Not sure how the dimension is segregated when it has just 1 unique value.

er_mohit
Master II
Master II

try this in expression side

for obs fieldname write rowno()

rangesum(above(sum(Fieldname),0,rowno()))

Not applicable
Author

You could also try this (assuming that your original table has some sort of 'key' field), it will allow you to make a selection and still see the cumulative value.

sum(aggr(rangesum(above(total sum({<key=>} a),0,RowNo())),key))

I recommend this tutorial:

Calculating rolling n-period totals, averages or other aggregations

http://community.qlik.com/docs/DOC-4252

Cheers,

Paul

MK_QSL
MVP
MVP

Please check enclosed file..

Not applicable
Author

can you post the code cause i am not able to access that qvw file.

Thank you    

MK_QSL
MVP
MVP

Script..

Load  * Inline

[

  ID,a

  1, 1

  2,

  3, 1

  4, 1

  5,

];

Create a straight table

Dimension = ID

Expression

1) RowNo()

2) RangeSum(Above(Sum(a),0,RowNo()))

Not applicable
Author

How can I write this all in the script? I was trying to write them in the script but it doesn't recognize the "Above" function...

anbu1984
Master III
Master III

Cumulative_sum:

Load  * Inline

[

  ID,a

  1, 1

  2,

  3, 1

  4, 1

  5,

];

table:

load

RowNo() as Sequence1,

RangeSum(a, Peek('CumSum')) AS CumSum,

*

Resident Cumulative_sum

order by ID, a;

MK_QSL
MVP
MVP

You need to create a straight table...!!!

Script..

Load  * Inline

[

  ID,a

  1, 1

  2,

  3, 1

  4, 1

  5,

];

Create a straight table

Dimension = ID

Expression

1) RowNo()

2) RangeSum(Above(Sum(a),0,RowNo()))