Forum Discussion
Running Total or Cumulative Total column in Power Query
Hi,
a) if you want to make a suggestion, I suggest you post it to Ideas, where it gets votes and better highlight for Microsoft. https://ideas.fabric.microsoft.com/
b)
To create a cumulative total in Power Query, you can follow these steps:
Load your data into Power Query: Import your data into Power Query from your data source. This could be from an Excel table, CSV file, database, or other sources.
Add an Index Column: Go to the "Add Column" tab in the Power Query Editor, then select "Index Column" and choose "From 0". This will add a new column with a sequential index starting from 0.
Sort the data: Sort your data by the column you want to create the cumulative total for. You can do this by clicking on the column header and selecting "Sort Ascending" or "Sort Descending" as appropriate.
Add a Custom Column for the Cumulative Total:
- Go to the "Add Column" tab.
- Click on "Custom Column".
- In the formula bar that appears, enter a formula to calculate the cumulative total.
- For example, if your column containing the values you want to cumulate is named "Value", you can use the following formula: = List.Sum(List.FirstN([Value], [Index] + 1))
- Click OK.
Expand the new column: Click the expand button (double-headed arrow) on the header of the newly created custom column. Uncheck the "Use original column name as prefix" option if you don't want the original column name to be added as a prefix.
There you go.
Kudos and mark as solution appreciated 🙂