Forum Discussion
Unexpected behavior Sameperiodlastyear
- 5 years ago
Anonymous
Did you make it look like this? dateadd('Date'[Date],-365,day)
-1 is yesterday , -365 goes back to 12 months.
Hi Anonymous
Try to use "day" as interval for your DATEADD instead of year.
Hi Amine,
thanks for your answer but this does not fix my problem, because I want to look at the same period but 12 months ago, not yesterday.
Chris
- aj19735 years ago
Community Champion
Anonymous
Did you make it look like this? dateadd('Date'[Date],-365,day)
-1 is yesterday , -365 goes back to 12 months.
- Anonymous5 years agoNot applicable
Hi Amine,
you are right, I read your solution to quickly. I have another visual where sameperiodlastyear shows me the correct value on a per year basis and your solution gives a slightly different value. Do you maybe know why? I've changed "-365" to different days to see if I could match the value from sameperiodlastyear but I cannot.
What could be the logic behind this difference?Thanks,
Chris
- aj19735 years ago
Community Champion
Anonymous
The difference is in the granularity of data you want to see in your visual. PREVIOUSYEAR returns the result of the entire previous year, DATEADD returns back the number of days from the date you want to start your calculation. Nothing wrong with either approach, it is just how the user wants to see the data in a specific visual.
Check out this article may it could help.
https://minova.nl/geen-categorie/power-bi-dax-dateadd-versus-previousmonth
https://radacad.com/dateadd-vs-parallelperiod-vs-sameperiodlastyear-dax-time-intelligence-question