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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
webportal
Impactful Individual
Impactful Individual

Total month to date for last year until a specific day of the month

I want to calculate the sum of MTD sales per day for the same period of last year, only until a specific day.

So for example, if the filter is year= 2019 and month= 2, I need the MTD sales for february 2018 until the 5th, calculated day by day:

MTDSales=
VAR MyDay = 5
RETURN
CALCULATE(
  TOTALMTD(SUM(Sales); Calendar[Date]);
  SAMEPERIODLASTYEAR(Calendar[Date]);
  //here I need another filter to stop on the 5th!
)
1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

please have a look here:

https://www.daxpatterns.com/time-patterns/

 

I think that almost every time intelligence calculation is covered here.

 

Please be alos aware that sooner or later you have to decide how to treat the upcoming leapyear in 2020, but there are some considerations about the same timeframe if a leapyear has to be considered in one way or the other.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

3 REPLIES 3
TomMartens
Super User
Super User

Hey,

 

please have a look here:

https://www.daxpatterns.com/time-patterns/

 

I think that almost every time intelligence calculation is covered here.

 

Please be alos aware that sooner or later you have to decide how to treat the upcoming leapyear in 2020, but there are some considerations about the same timeframe if a leapyear has to be considered in one way or the other.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Sure, I've read all that before, but no pattern like this one.

Hey,

 

please provide a pbix that contains sampole data and represents your data model.

Upload the file to onedrive and share the link.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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