Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mansi64011
Frequent Visitor

Running total in Power Query

Hello,
I wanted to create a Running Total column in Power Query.
I have an Invoice Table which looks like below:
Account IDInvoice Date Invoice PriceRunning Total
110/13/20165050
112/10/2017279329
12/23/201813801709
24/15/2018325325
23/4/20197871112
36/19/201822
49/10/201723562356
47/30/2018352391
49/9/20182542645
45/7/20197563401
53/12/20173737
58/26/2018876913

My SQL code for that is:
SELECT SUM(InvoicePrice) OVER (Partition by AccountID Order by InvoiceDate) as RunningTotal
FROM Invoices
 
Note: 1 account can have many invoices so I partitioned by account ID as I want to see running total for each account.
1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

1 REPLY 1
ImkeF
Community Champion
Community Champion

Hi @mansi64011 

please check out this solution: https://www.thebiccountant.com/2018/09/30/memory-efficient-clustered-running-total-in-power-bi/ 

 

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.