Forum Discussion
SAMEPERIODLASTYEAR returning no data
I have a table with claim and serDate.
I have binned/grouped serDate into a 7 day group.
Using
returns the correct count.
- Anonymous5 years ago
Anonymous
Because you used today() as the condition, and there is no today's date in the previous year.Just replace the SAMEPERIODLASTYEAR('log'[SerDate])) to
FILTER('log',[SerDate].[Year]=YEAR(TODAY())-1&&[SerDate].[MonthNo]=MONTH(TODAY()) && [SerDate].[Day]=DAY(TODAY()))Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
2 Replies
- amitchandakSuper User
Anonymous , with time intelligence you should use a date table as it requires continous dates. Date tbale should have all date for last year in data tbale
examples, I also doubt the need to <today ()
Year behind Sales = CALCULATE([Total Claims],SAMEPERIODLASTYEAR('Date'[Date]))
Year behind Sales = CALCULATE([Total Claims]),dateadd('Date'[Date],-1,Year))or
forced=
var _max = date(year(today()),month(today())-3,day(today()))
returnCALCULATE([Total Claims]),dateadd('Date'[Date],-1,Year),,'Date'[Date]<=_max)
- AnonymousNot applicable
Anonymous
Because you used today() as the condition, and there is no today's date in the previous year.Just replace the SAMEPERIODLASTYEAR('log'[SerDate])) to
FILTER('log',[SerDate].[Year]=YEAR(TODAY())-1&&[SerDate].[MonthNo]=MONTH(TODAY()) && [SerDate].[Day]=DAY(TODAY()))Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.