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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Naveeduddin
Frequent Visitor

YoY Date Comparison

Hi All,

 

I'm trying to do a YoY Comparison for 2021 and 2020, so when I use the sameperiodlastyear it compares the exact same date last year but I want it to calculate one day ahead

 

For Ex: My date range is 19 Dec 2021 to 25 Dec 2021, it should compare 20 Dec 2020 to 26 Dec 2020

 

Kindly help!

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Naveeduddin , Try a measure like

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-364,DAY))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

All measures are in the attached pbix file.

If I may suggest other than the below, if you have calendar table with week number column, you can compare it by utilizing the same week number last year.

 

Picture1.png

Sales: =
SUM(Data[Sales])

 

 

Sales previous year expected result: =
VAR mindate =
CALCULATE ( MIN ( 'Calendar'[Date] ), SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) ) + 1
VAR maxdate =
CALCULATE ( MAX ( 'Calendar'[Date] ), SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) ) + 1
RETURN
CALCULATE ( [Sales:], DATESBETWEEN ( 'Calendar'[Date], mindate, maxdate ) )


Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



View solution in original post

6 REPLIES 6
Naveeduddin
Frequent Visitor

Thank you! This was helpful 

Naveeduddin
Frequent Visitor

Wow, Amazing! This worked. Thanks a lot

Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

All measures are in the attached pbix file.

If I may suggest other than the below, if you have calendar table with week number column, you can compare it by utilizing the same week number last year.

 

Picture1.png

Sales: =
SUM(Data[Sales])

 

 

Sales previous year expected result: =
VAR mindate =
CALCULATE ( MIN ( 'Calendar'[Date] ), SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) ) + 1
VAR maxdate =
CALCULATE ( MAX ( 'Calendar'[Date] ), SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) ) + 1
RETURN
CALCULATE ( [Sales:], DATESBETWEEN ( 'Calendar'[Date], mindate, maxdate ) )


Microsoft MVP



If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.




LinkedInVisit my LinkedIn page




Outlook BookingSchedule a short Teams meeting to discuss your question



Anonymous
Not applicable

I was trying to get there. But you did faster! @Jihwan_Kim 

bcdobbs
Community Champion
Community Champion

Not by a computer however SAMEPERIODLASTYEAR returns a table of dates. I think you should just be able to wrap it in DATEADD.

 

Can flesh that out later if you need?



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
amitchandak
Super User
Super User

@Naveeduddin , Try a measure like

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-364,DAY))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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