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! Learn more

Reply
Larry02747
Regular Visitor

Trouble with DATESMTD Function

I'm trying to get true TY vs LY month to date comparisons, e.g. If today is August 18th, I want to compare amounts from August 1st - August 18th inclusive from August 2016 to the same range of dates in August 2017. I have this working using a multi-step process:

RevisedMTD = CALCULATE(SUM(Sheet1[Amt]),DATESBETWEEN('DimDate'[Date],[Start Date], ([Start Date]+DAY(TODAY())-1)))

 

RevisedMTDLY = CALCULATE(SUM(Sheet1[Amt]),DATESBETWEEN('DimDate'[Date],[Start Date LY], [Start Date LY Current Day]))

 

Start Date LY = DATEADD(STARTOFMONTH('DimDate'[Date]),-1,YEAR)

 

Start Date LY Current Day = [Start Date LY] + DAY(TODAY())-1

 

Start Date = STARTOFMONTH('DimDate'[Date])

 

If I try to calculate the prior year MTD total by using something like this:  = TOTALMTD([YTD Sales],SAMEPERIODLASTYEAR(DATESMTD('DimDate'[DATE])))

 

I get the full amount for that total month from last year NOT the amount from the first of the month through the current day's date in the month.

 

Guessing there must be a simpler way to do this comparison than what I am presently doing. Grateful for any insights. Thanks!

2 REPLIES 2
Anonymous
Not applicable

@Larry02747,

How about you directly use slicer to filter your visual?

1.JPG

Regards,
Lydia

TomMartens
Super User
Super User

Hey,

 

I never found a neat and simple solution for this question, for this I started some time ago to avoid the TimeIntelligence functions.

 

Maybe you want to consider my post in this thread

https://community.powerbi.com/t5/Desktop/MTD-Previous/m-p/233821#M104135

 

Regards



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
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!

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.

Top Solution Authors