cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vonw13
Frequent Visitor

Sameperiodlastyear showing entire month instead of mtd

I used a measure to take the total sales mtd, then a new measure to use sameperiodlast year, but it shows the full month of May 2021 instead of mtd previous year. How do I get it do accuratlely show through mtd previous year? I have slicers on my report for month and year.

 

Sales data PY using manual slicers

vonw13_0-1652728694272.png

 

Current year MTD showing accurately

vonw13_1-1652728749304.png

 

PY MTD showing entire month

 

vonw13_2-1652728784670.png

 

 

1 ACCEPTED SOLUTION
themistoklis
Super User
Super User

Hello @vonw13 

 

Try the following formula. Make sure you have a calendar table.

 

Turnover MTD (PY) = CALCULATE(SUM('Table'[TurnOver]),
        DATESBETWEEN('Calendar'[Date],                    
            FIRSTDATE(DATEADD('Calendar'[Date],-12,MONTH)),   
            IF(MONTH(MIN('Calendar'[Date])) = MONTH(TODAY()), EDATE(TODAY(),-12) , LASTDATE(DATEADD('Calendar'[Date],-12,MONTH))) 
         )
     )

 

View solution in original post

4 REPLIES 4
themistoklis
Super User
Super User

Hello @vonw13 

 

Try the following formula. Make sure you have a calendar table.

 

Turnover MTD (PY) = CALCULATE(SUM('Table'[TurnOver]),
        DATESBETWEEN('Calendar'[Date],                    
            FIRSTDATE(DATEADD('Calendar'[Date],-12,MONTH)),   
            IF(MONTH(MIN('Calendar'[Date])) = MONTH(TODAY()), EDATE(TODAY(),-12) , LASTDATE(DATEADD('Calendar'[Date],-12,MONTH))) 
         )
     )

 

That worked! Thank you so much! Do you know why just the regular sameperiodlast year or the other functions didn't work?

To be honest I dont know the answer to this question. 

There are alternatives on calculating the MTD for previous year but I found the above formula the one that covered my needs.

 

May worth trying the formula from this post as well.

https://community.powerbi.com/t5/Desktop/MTD-Comparison-to-same-period-last-year/m-p/188900

 

speedramps
Super User
Super User

Please watch this series of free BI training videos inlcuding a free calendar download.

Then you can sum, filters and compare MTD, YTD, LM, LY, ect like a rock star.

Click here for free videos 

 

Please click thumbs up and accept as solution. 😀

 

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors