Forum Discussion
SAMEPERIODLASTYEAR - wrong result
- 7 years ago
Hi, naelske_cronos
I tried to understand what you mean and provide a solution. I used DATEADD() function to get the value of the same period last year.Create a column to convert Year and Month to a date type value.
dateFormat = test[Month] & "-" & test[Year]
After creating it, select the data type option to choose DATE type
Then edit relationship between your calendar table and your data table.
Then create the following measure:
rolling 12 Month PY = VAR rollingMonths = CALCULATE ( SUM ( test[Sales] ), DATEADD ( 'Calendar'[Date], -12, MONTH ) ) RETURN rollingMonthsIn the report, you need to choose these fields:
In the Date fields, you just need Year and Month.
Now, you can get the visual you want.
Best Regards,
Eads
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, naelske_cronos
I tried to understand what you mean and provide a solution. I used DATEADD() function to get the value of the same period last year.
Create a column to convert Year and Month to a date type value.
dateFormat = test[Month] & "-" & test[Year]
After creating it, select the data type option to choose DATE type
Then edit relationship between your calendar table and your data table.
Then create the following measure:
rolling 12 Month PY =
VAR rollingMonths =
CALCULATE ( SUM ( test[Sales] ), DATEADD ( 'Calendar'[Date], -12, MONTH ) )
RETURN
rollingMonthsIn the report, you need to choose these fields:
In the Date fields, you just need Year and Month.
Now, you can get the visual you want.
Best Regards,
Eads
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous6 years agoNot applicable
Thank you so much!
I work with a fiscal calendar so date functions don't work well.
I was using SamePeriodLastYear(dateadd(date,1,day)) and it was giving me the correct daily results but wouldn't total correctly.
This solution works! THANK YOU!!!