Power Pivot: Cumulative Total

jajatidev

Board Regular
Joined
Jul 29, 2016
Messages
78
Office Version
  1. 365
Platform
  1. Windows
Hi,
Looking for assistance with an issue I'm facing with cumulative total.
The function I have used is;
Excel Formula:
CALCULATE(SUMX('Ageing_Trend_Report',[Unconfirmed_Qty.]), FILTER(ALL(Ageing_Trend_Report),Ageing_Trend_Report[Report_Week]<= MAX(Ageing_Trend_Report[Report_Week])))

and the result I'm getting is;
Report_WeekAge_GroupUnconfirmed_Qty.Total Unconfirmed% By Group% Running Total (DESC) by Report_Week
01/22/2024[ > 120]14063,637
01/22/2024[0 - 5]3,32463,637
01/22/2024[11 - 20]1,21963,637
01/22/2024[21 - 30]4,17563,637
01/22/2024[31 - 60]89963,637
01/22/2024[6 - 10]7,76063,637
01/22/2024[61 - 90]3,25763,637
01/22/2024[91 - 120]23263,637
01/29/2024[ > 120]15463,637
01/29/2024[0 - 5]4,18563,637
01/29/2024[11 - 20]8,43663,637
01/29/2024[21 - 30]1,91063,637
01/29/2024[31 - 60]2,56563,637
01/29/2024[6 - 10]1,04163,637
01/29/2024[61 - 90]3,25463,637
01/29/2024[91 - 120]22063,637
02/05/2024[ > 120]13163,637
02/05/2024[0 - 5]3,39463,637
02/05/2024[11 - 20]7,77163,637
02/05/2024[21 - 30]88363,637
02/05/2024[31 - 60]3,84863,637
02/05/2024[6 - 10]2,23363,637
02/05/2024[61 - 90]2,47063,637
02/05/2024[91 - 120]13663,637


However, shared below is the result I'm expecting so that %age of the age group can be calculated by date. Then a running total of the percentage can be generated by week date in descending order.
I also need guidance with the Dax function for the running total of the percentage.

Report_WeekAge_GroupUnconfirmed_Qty.Total Unconfirmed% By Group% Running Total (DESC) by Report_Week
01/22/2024[ > 120]14021,0060.67%
01/22/2024[0 - 5]3,32421,00615.82%
01/22/2024[11 - 20]1,21921,0065.80%
01/22/2024[21 - 30]4,17521,00619.88%
01/22/2024[31 - 60]89921,0064.28%
01/22/2024[6 - 10]7,76021,00636.94%
01/22/2024[61 - 90]3,25721,00615.51%
01/22/2024[91 - 120]23221,0061.10%
01/29/2024[ > 120]15421,7650.71%
01/29/2024[0 - 5]4,18521,76519.23%
01/29/2024[11 - 20]8,43621,76538.76%
01/29/2024[21 - 30]1,91021,7658.78%
01/29/2024[31 - 60]2,56521,76511.78%
01/29/2024[6 - 10]1,04121,7654.78%
01/29/2024[61 - 90]3,25421,76514.95%
01/29/2024[91 - 120]22021,7651.01%
02/05/2024[ > 120]13120,8660.63%
02/05/2024[0 - 5]3,39420,86616.27%
02/05/2024[11 - 20]7,77120,86637.24%
02/05/2024[21 - 30]88320,8664.23%
02/05/2024[31 - 60]3,84820,86618.44%
02/05/2024[6 - 10]2,23320,86610.70%
02/05/2024[61 - 90]2,47020,86611.84%
02/05/2024[91 - 120]13620,8660.65%
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
First add an index column. Call it "IndexCol"

Excel Formula:
=COUNTROWS(FILTER(Table1, EARLIER([Report_Week]) =  [Report_Week] && EARLIER([Age_Group]) >= [Age_Group]))

Then you can use this formula to get your %ByGroup (also call the column "%ByGroup")

Excel Formula:
=[Unconfirmed_Qty.]/CALCULATE(SUM([Unconfirmed_Qty.]),FILTER(ALL(Table1),EARLIER([Report_Week]) = [Report_Week]))

For running total afterwards

Excel Formula:
=CALCULATE(SUM([%ByGroup]),FILTER(Table1,EARLIER([Report_Week]) = [Report_Week] && EARLIER([IndexCol]) >= [IndexCol]))


1707247057093.png




If you want Descending running totals, you have to write your running total like

Excel Formula:
=CALCULATE(SUM([%ByGroup]);FILTER(Table1;EARLIER([Report_Week]) = [Report_Week] && EARLIER([IndexCol]) <= [IndexCol]))
 
Last edited:
Upvote 0
Solution
First add an index column. Call it "IndexCol"

Excel Formula:
=COUNTROWS(FILTER(Table1, EARLIER([Report_Week]) =  [Report_Week] && EARLIER([Age_Group]) >= [Age_Group]))

Then you can use this formula to get your %ByGroup (also call the column "%ByGroup")

Excel Formula:
=[Unconfirmed_Qty.]/CALCULATE(SUM([Unconfirmed_Qty.]),FILTER(ALL(Table1),EARLIER([Report_Week]) = [Report_Week]))

For running total afterwards

Excel Formula:
=CALCULATE(SUM([%ByGroup]),FILTER(Table1,EARLIER([Report_Week]) = [Report_Week] && EARLIER([IndexCol]) >= [IndexCol]))


View attachment 106433
Thanks, @JEC, appreciate the quick response.
One adjustment is needed with the indexing sequence. "[0 - 5]" needs to be indexed as 1 and "[ > 120]" needs to be indexed as 8.
 
Upvote 0
See my last post below. I was already assuming this.
I have ";" as seperator, you need to change this to ","

Could not change it anymore...

PS: the %ByGroup could be written like

Excel Formula:
=[Unconfirmed_Qty.]/[Total Unconfirmed]
 
Last edited:
Upvote 0
For indexing as you desire you could use this formula

Excel Formula:
=SWITCH([Age_Group],
   "[ > 120]",8,
   "[0 - 5]",1,
   "[11 - 20]",2,
   "[21 - 30]",3,
   "[31 - 60]",4,
   "[6 - 10]",5,
   "[61 - 90]",6,
   "[91 - 120]",7
   )
 
Upvote 0
For indexing as you desire you could use this formula

Excel Formula:
=SWITCH([Age_Group],
   "[ > 120]",8,
   "[0 - 5]",1,
   "[11 - 20]",2,
   "[21 - 30]",3,
   "[31 - 60]",4,
   "[6 - 10]",5,
   "[61 - 90]",6,
   "[91 - 120]",7
   )
Thanks again @JEC.

Can this also be executed in the power query editor without using group by?
 
Upvote 0
not without group by…why do you not want to use it?
After grouping and executing these steps, you can easily extract the complete table again
 
Last edited:
Upvote 0
not without group by…why do you not want to use it?
After grouping and executing these steps, you can easily extract the complete table again
I was just thinking aloud of other possible approaches.
Thanks for the calculations, I have applied them.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top