Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
suparnadas121
Contributor II
Contributor II

How to calculate cumulative sum on a weekly basis

Hi Folks,

My requirement over here is , I have a weekly set of data. Each weeks 'Total Weekly data' should be added with previous weeks 'Cumulative total data' and and to be displayed in that weeks 'Cumulative total data'.  

I need to do this in sheet, not in script. Refer to this below example.

  week6 week7 week8 week9 week10
Total Weekly data 10 20 30 40 50
Cumulative total data 10 30 60 100 150
Labels (3)
2 Replies
suparnadas121
Contributor II
Contributor II
Author

Hi @sunny_talwar , can you help ?

 

SBDataspark
Creator
Creator

Hi there,

I've just come across your question and was able to create this in a Qlik Sense pivot table.

Sebb_0-1645103632293.png

Please have a look at the attached qvd.

This has the following inline table.

[Transactions]:
LOAD * Inline
[PlanningID,PlannedDate,Amount
1,5-1-2022,1000
2,15-2-2022,-200
3,31-3-2022,-300
4,20-4-2022,-400
5,3-5-2022,200
6,11-6-2022,-100
7,25-7-2022,-300
8,18-8-2022,-250
9,6-9-2022,500
10,31-10-2022,-400
11,24-11-2022,-400
12,31-12-2022,-400
];

With a master calendar attached to it.

The sheet has a pivot table with only one dimension.

Sebb_1-1645103785184.png

The column is "Week".

Sebb_2-1645103813588.png

And the only measurement is the following expression:

If(Dimensionality() = 0 // being the "Total row" in the pivot table
, Aggr(RangeSum(Above(Sum(Amount),0,RowNo())), [PlannedDate.Calendar.Week])
, Sum(Amount)
)

Hopefully this still comes in handy for you.

Kind regards,

Sebb