cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NewbieJono
Super User
Super User

Compare to the same day last year

Hello all,  on a chart, can i compare to the same day last year. e.g compare Monday to the previous years closest Monday. At the momene my chart looks like this.

 

Capture.PNG

 

As you can see the comparison is out of sync.

 

Here is the dax i use

 

Mail Received Previous Year = calculate([Total MailReceived],SAMEPERIODLASTYEAR('DIM - Date Table'[Date]))

 

1 ACCEPTED SOLUTION

@NewbieJono , Please try a suggestion from @ashwinwullems , same week day last year is 364 days behind. So should work for leap year too

 

example

 

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



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!

View solution in original post

5 REPLIES 5
NewbieJono
Super User
Super User

Yes Monday is peak day, just wanted to match them up. Does anyone know what the dax for this would be

you can try dateadd ( <Dates>, -52*7, DAYS

what does this do,  would it deal with a leap year?

@NewbieJono , Please try a suggestion from @ashwinwullems , same week day last year is 364 days behind. So should work for leap year too

 

example

 

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



!! Microsoft Fabric !!
Microsoft Power BI Learning Resources, 2023 !!
Learn Power BI - Full Course with Dec-2022, with Window, Index, Offset, 100+ Topics !!
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
ashwinwullems
Frequent Visitor

Sameperiodlastyear is the exact date from last year. If this is sales related there might be a discrepancy in dates vs sales dates (weekdays vs weekends).

 

You can try using some form of dateadd to get the dates closer to eachother.

 DATEADD ( <Dates>, -365, DAY 

Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors