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

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

Reply
Anonymous
Not applicable

Calculate running total based on Sort Column

I have a table where I am trying to calculate a running total based on a sort column with an additional filter as follows. This would have typically been a standard YTD formula but the start of the fiscal year is in June and not calendar based hence the Month Sort.

 

Table.JPG

 

Any thoughts on how best to build  formula to do that?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

 

Use and modify the below Formula as per your need.

 

Running Total COLUMN =
CALCULATE (
    SUM ( 'table'[col1] ),
    ALL( 'table'),   //ALLEXCEPT ( 'table', 'table'[] ) //If you want to group by any column
    'table'[col2] <= EARLIER ( 'table'[col2] )
)

https://www.wallstreetmojo.com/power-bi-running-total/

 

Did I resolve your issue? Mark my post as a solution! Appreciate your Kudos, Press the thumbs up button!!

 

Regards,
Pranit

 

View solution in original post

11 REPLIES 11
amitchandak
Super User
Super User

@Anonymous , first create an FY calendar with the correct sort. Hope you have dates

You have all 12 start months calendar here -https://community.powerbi.com/t5/Community-Blog/Creating-Financial-Calendar-Decoding-Date-and-Calendar-1-5-Power/ba-p/1187441

Now use datesytd with year-end date of your choice

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"5/31")) //means year start in june
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"5/31"))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @Anonymous 

 

Use and modify the below Formula as per your need.

 

Running Total COLUMN =
CALCULATE (
    SUM ( 'table'[col1] ),
    ALL( 'table'),   //ALLEXCEPT ( 'table', 'table'[] ) //If you want to group by any column
    'table'[col2] <= EARLIER ( 'table'[col2] )
)

https://www.wallstreetmojo.com/power-bi-running-total/

 

Did I resolve your issue? Mark my post as a solution! Appreciate your Kudos, Press the thumbs up button!!

 

Regards,
Pranit

 

Anonymous
Not applicable

Thank you so much. This worked exactly as stated and I used the ALLEXCEPT filter to apply the running total to the applicable name.

Anonymous
Not applicable

Can you post the formula you used?  I'm not getting the running total, just the total on each row when using the ALLEXCEPT filter.  Table looks like below now - 

UserAmtRunning Total
1100250
1100250
150250

 

Hi,

Do you have a Date column?  If yes, then share that dataset.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Here's the table I'm using 'User_Payments' - 

User_IDTran_DateTran_AmtRunning_Deposits
1007/1/2021100300
1007/15/2021125300
1007/18/202175300
1056/1/2021120220
1056/30/2021100220
1107/15/20215050
1156/15/2021115200
1157/1/202185299

 

Running_Deposits is a calculated column using this DAX code : 

Running_Deposits =
CALCULATE (
SUM ( 'User_Payments'[Tran_Amt] ),
ALLEXCEPT (
'User_Payments',
'User_Payments'[User_ID]
),
'User_Payments'[User_ID]
= EARLIER ( 'User_Payments'[User_ID] )
)
 
I'm getting the total for each User_ID, but not the running total.  I'd like results like this:
User_IDTran_DateTran_AmtRunning_Deposits
1007/1/2021100100
1007/15/2021125225
1007/18/202175300
1056/1/2021120120
1056/30/2021100220
1107/15/20215050
1156/15/2021115115
1157/1/202185200

 

I've tried <= and >= operators in the filters, but that does not yeild better results.  

 

Thanks! 

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I am so so thankful to you, I was looking for this solution for hours. 

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Ashish,

Thank you very much for sharing this.  I'll work with it to get it into a calculated column rather than a measure as this is really just one component of a much larger need.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.