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
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
v-yuezhe-msft
Employee
Employee

@Larry02747,

How about you directly use slicer to filter your visual?

1.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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
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.