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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Calculating MTD on a custom Calendar

Hey everyone,

I'm having issues calculating MTD on a custom calender. For example the sales month for january is jan 5 2022 - feb 1st. I have create a custom calender and assigned Financial Month, Days, & Years to the dates in the year. Then I am using filters to narrow down these date ranges. It is working however the input for this is the selling date and if there isn't a sale on the date then it won't show the MTD sales for the salesperson. It just leaves a blank instead of showing the sales accumulated up to the current/selected date. What I need is for it to show the current total MTD for the sales person up to the selected date. This is my current Measure.

MTD SALES 3.0 =
VAR CurrentFinMonth = SELECTEDVALUE('Sales Matrix'[Fin Month])
VAR CurrentFinYear = SELECTEDVALUE('Sales Matrix'[FinYear])
VAR CurrentDay = SELECTEDVALUE('Sales Matrix'[Day Number])
VAR SellingDate = HASONEVALUE('Sales Matrix'[Selling Date])
RETURN
CALCULATE( COUNT(MOCK_DATA[VIN]),
FILTER(ALL('Sales Matrix'),'Sales Matrix'[Fin Month] = CurrentFinMonth && 'Sales Matrix'[FinYear] = CurrentFinYear && 'Sales Matrix'[Day Number] <= CurrentDay && SellingDate = TRUE
))
Selling DateFin MonthFin YearDay Number
1/5/2022120221
1/6/2022120222

 

 

SalePersonIDSales DateVIN
11121/5/20221x
11131/5/20222b
11121/7/20223n
11131/8/20224c

 

The issue being that if i flip to the Jan 6th in my selling date slicer, the MTD measure will show blank on my table vizualization instead of carrying over the sale from the previous day. If I change the slicer to the 7th, the table will show 2 sales for salespersonID 1112, and blank for 1113. and then if i change the date to 1/8 it will show two sales for 1113 and blank for 1112. 

 

Any Help would be appreciated. I've seen similar issues but nothing that directly solves my problem. Thanks!

1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

In my experience a simple CALCULATE + DATESMTD should do this if you use the financial month as the axis value.
Example:
Data:

ValtteriN_0-1642007997691.png

 


My "financial month" in this example is MONTH('Calendar'[date]+10)

Dax:

CustomMonthMTD = CALCULATE(SUM('Sales'[Value]),DATESMTD('Calendar example'[Date]))

End result:
ValtteriN_1-1642008092803.png


As we can see the MTD calculation is done using the financial month instead of the date.

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!






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

Proud to be a Super User!




View solution in original post

1 REPLY 1
ValtteriN
Super User
Super User

Hi,

In my experience a simple CALCULATE + DATESMTD should do this if you use the financial month as the axis value.
Example:
Data:

ValtteriN_0-1642007997691.png

 


My "financial month" in this example is MONTH('Calendar'[date]+10)

Dax:

CustomMonthMTD = CALCULATE(SUM('Sales'[Value]),DATESMTD('Calendar example'[Date]))

End result:
ValtteriN_1-1642008092803.png


As we can see the MTD calculation is done using the financial month instead of the date.

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!






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

Proud to be a Super User!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.