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
Heuers
Regular Visitor

MTD LY Same time period

Hi,

 

Im trying to compare the MTD of the current period with the relevant MTD of the period LY. The issue I am experiencing is the period LY has a full years worth of data and thus trying to perform a LFL comparison in the month you are in is not accurate. In order to get around this I have performed the below:

 

MTD TY formula:

 

GB_MTD:=TOTALMTD([GB],Cal[Date])

 

MTD LY: GB_MTD_LY2:=IF(LASTDATE(Cal[Date])>TODAY()-1,BLANK(),
CALCULATE([GB_MTD],DATEADD(Cal[Date],-1,YEAR)))

 

After completing this I have had the following issues. When looking at it from a days POV everything looks fine: the LY formula cuts it off as I expect at todays date, however - once I look at it monthly I lose the data for the month that is not completed.

 

I have made sure the calendar table has all the relavant dates for the month concerned - is this something to do with using datesadd for months that are not completed?

 

I am new to the forum and can post examples of the issue I am having - just not sure how to do so.

 

Any advice wiould be GREATLY appreciated for a new to the forum and pretty new to PBI user.

 

Thanks

 

Shane 

 

 

 

 

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Heuers ,

 

I have created a sample for your reference.

 

GB_MTD = CALCULATE(SUM('Table'[value]),DATESMTD('date'[Date]))
LY = TOTALMTD(CALCULATE(SUM('Table'[value]),SAMEPERIODLASTYEAR('date'[Date])),'date'[Date])

dm.PNG

 

Pbix as attached.

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @Heuers ,

 

I have created a sample for your reference.

 

GB_MTD = CALCULATE(SUM('Table'[value]),DATESMTD('date'[Date]))
LY = TOTALMTD(CALCULATE(SUM('Table'[value]),SAMEPERIODLASTYEAR('date'[Date])),'date'[Date])

dm.PNG

 

Pbix as attached.

 

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
amitchandak
Super User
Super User

@Heuers , try like

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


last year MTD Sales =
var _max = date(year(today())-1,month(today()),day(today()))
return
CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)),'Date'[Date]<=_max)

 

In place of Today, You can use Max date of you fact

@amitchandak 

 

Thanks for the reply - tried your solution below and its works great for comparing the same LFL period.

 

I can now perform MTD vs MTD LY calculation.

 

Could you please provide me with a reason why the following happens: I have a pivot connected to that model: If a blank out from a certain day as in my orginal soloution, the days blank out correctly, why does the month total also become blank whilst there is data for the corresponding days under it? 

 

Measure 1 is your solution blanking out from 27/04 onwards. LY measure is your solution with no blank.

 

Thanks

 

 

1.PNG

 

 

 

 

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.