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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
CoffeeTime
Frequent Visitor

Running Total Comparing Months

I am trying to plot a visual that compares tickets during each month, day by day. I was able to create it on a non cumulative view, but the running total for each month won't work.

 

I used a slicer to filter this year's period (2020+) and created a visual I would like to see each month's evolution comparison. I couldn't get to my desired result, because each month's count starts from the previous end and I would like to start from 0.

 

The first visual is OK. The problem is with the second one. As you can see, the month's initial value is not zero as I would like.

 

Imagem1.pngImagem2.png

1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @CoffeeTime ,

 

Create a calculated column for the day of the month

Day of Month = 
DAY ( 'Table'[Dates] )

 Then create this measure

MTD =
CALCULATE (
    [Sum of Values],
    FILTER (
        ALL ( 'Table'[Day of Month] ),
        'Table'[Day of Month] <= MAX ( 'Table'[Day of Month] )
    )
)

 

The reason why your formula is not returning the expected result is because you are using [Date] in your filter so the cumulative sum is always from the earliest date in the current filter context until the current date in your line chart instead of actually from the start of the month.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

I was trying to do the same thing as OP and for some reason danextian's solution didn't work for me: it just showed the daily totals for each day of the month, not the MTD running total.

 

So instead I used this measure:

Earnings MTD = 
   IF(MAX('Date Table'[Date])>TODAY(),BLANK(),
    TOTALMTD(SUM('Project'[InvoiceAmount]),'Date Table'[Date])
   )

 Then on my graph I had my date variable on the x axis, in Series I had a variable for the month (filtered to just the current and previous month) and then the measure above as Values.

AlexFeuch_0-1649812902911.png

 

amitchandak
Super User
Super User

If you want Cumulative month, then prefer daysmtd or totalmtd

Example

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,MONTH))))
last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
last year MTD (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))


last QTR same Month (complete) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-1,Qtr))))


MTD (Year End) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR('Date'[Date])))
MTD (Last Year End) Sales =  CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFYEAR(dateadd('Date'[Date],-12,MONTH),"8/31")))

 

My Calendar is Date

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
danextian
Super User
Super User

Hi @CoffeeTime ,

 

Create a calculated column for the day of the month

Day of Month = 
DAY ( 'Table'[Dates] )

 Then create this measure

MTD =
CALCULATE (
    [Sum of Values],
    FILTER (
        ALL ( 'Table'[Day of Month] ),
        'Table'[Day of Month] <= MAX ( 'Table'[Day of Month] )
    )
)

 

The reason why your formula is not returning the expected result is because you are using [Date] in your filter so the cumulative sum is always from the earliest date in the current filter context until the current date in your line chart instead of actually from the start of the month.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

Hi! I have a similar issue. I used what you provided above and that worked! However, how do I get it to automatically  same time last year each time?  I manually selected the same time last year. The table this uses does update every 13 months. I am thinking if I have it selected it will automatically update that month upon refresh?

 

 

 

Hi,

Could you share some data and show the expected result.  Show the result in a simple Table format.  From there, we can always build any chart we want.


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

@CoffeeTime add +0 at end of your measure and then test it. Would appreciate Kudos 🙂 if my solution helped.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors