Forum Discussion
Cumulative sum in Power query editor
- 5 years ago
Anonymous , refer this blog for power query running total
https://www.myonlinetraininghub.com/quickly-create-running-totals-in-power-query
- 5 years ago
Hi Anonymous
You can try these steps.
Add Index to your query and create a Custom column
Or you can use following M query in the Advanced Editor:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8ssv0zUyMDJQ0lEyM7LUMzdVitWJVnJJTYaJGhrpGZuDBb0S80CChkBBYwtLPRNjsKhbahJM1NDAzFTPwgQs7JtYBBc2N9EzApobCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [YearMonth = _t, Amount = _t]), #"Added Index" = Table.AddIndexColumn(Source, "Index", 1, 1, Int64.Type), #"Changed Type" = Table.TransformColumnTypes(#"Added Index",{{"Amount", type number}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Running Total", each List.Sum(List.FirstN(#"Changed Type"[Amount],[Index]))) in #"Added Custom"The result looks like this:
For more details, you can refer the attached pbix file. For further understanding running total in Power Query, you can refer these links:
Quickly Create Running Totals in Power Query
Grouped running total with Power Query M
Best Regards
Caiyun Zheng
If this post helps, please consider make it as the solution by Accept it as Solution. Really appreciate!
amitchandakI followed your blog solution and it was awesome! Thanks for sharing your knowledge!