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
lekkerbek
Helper IV
Helper IV

Sameperiodlastyear and Dateadd not giving correct result

Hi all,

 

I hope someone can help me. I know what the problem is, but I don't know how to solve it.

 

I have a situation where there are 13 periods in a year. The data that is imported is not on a daily basis, but imported on the last day of that period through an Excel file. So what I have for example is:

 

data on 26 January 2020

data on 24 January 2021

 

If I choose sameperiodlastyear or dateadd -1 year to compare it shows blanks. Obviously because it compares 24 January 2021 to 24 January 2020 (which has no data).

 

Is there a way to work around this?

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@lekkerbek , I think you need 364 day behind year 28*13

 

example

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

 

make sure you use date table

View solution in original post

2 REPLIES 2
lekkerbek
Helper IV
Helper IV

@amitchandak thank you very much. That was it!

amitchandak
Super User
Super User

@lekkerbek , I think you need 364 day behind year 28*13

 

example

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

 

make sure you use date table

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.