Power query acumulate sum formula

emema0

New Member
Joined
Jan 18, 2019
Messages
4
Im working in power query, I need to acumulate value per month and account. For january I like to only se value for janauray and then for february summed value for jan and feb and so on.
Is there any formula that ca create the coulumn Acum Value below?


AccountPeriodValueAcum Value
123Jan22
123Feb24
123Mar59
601Jan44
601Feb15
601Mar27
100Jan11
100Feb56
100Mar28

<tbody>
</tbody>
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
is that what you want?

AccountPeriodValueAccountPeriodValueRunningTotStartOver
123​
Jan
2​
123​
Jan
2​
2​
123​
Feb
2​
123​
Feb
2​
4​
123​
Mar
5​
123​
Mar
5​
9​
601​
Jan
4​
601​
Jan
4​
4​
601​
Feb
1​
601​
Feb
1​
5​
601​
Mar
2​
601​
Mar
2​
7​
100​
Jan
1​
100​
Jan
1​
1​
100​
Feb
5​
100​
Feb
5​
6​
100​
Mar
2​
100​
Mar
2​
8​

M-code for table
Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TableType = Value.Type(Table.AddColumn(Source, "RunningTotStartOver", each null, type number)),
    #"Grouped Rows" = Table.Group(Source, {"Account"}, {{"AllData", fnRunningTotStartOver, TableType}}),
    #"Expanded AllData" = Table.ExpandTableColumn(#"Grouped Rows", "AllData", {"Period", "Value", "RunningTotStartOver"},{"Period", "Value", "RunningTotStartOver"})
in
    #"Expanded AllData"[/SIZE]

M-code for function
Code:
[SIZE=1](MyTable as table) as table =>
let
    Source = Table.Buffer(MyTable),
    TableType = Value.Type(Table.AddColumn(Source, "RunningTotStartOver", each null, type number)),
    Cumulative = List.Skip(List.Accumulate(Source[Value],{0},(Cumulative,Value) => Cumulative & {List.Last(Cumulative) + Value})),
    AddedRunningTotStartOver = Table.FromColumns(Table.ToColumns(Source)&{Cumulative},TableType)
in
    AddedRunningTotStartOver[/SIZE]
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,421
Members
448,961
Latest member
nzskater

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