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

Share with Power BI Enthusiasts: 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 ) )

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.


Click here to visit my LinkedIn page

Click here to schedule 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 ) )

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.


Click here to visit my LinkedIn page

Click here to schedule 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))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.