Forum Discussion
SAMEPERIODLASTYEAR not returning the correct data
- 10 years ago
Anonymous
This issue was stemming from the fact that PowerBI wasn't recognizing the date field as a true date field. I had to create a new column that explicitly created a new date field for it to work. Thanks.
Few points you have to consider.
1. The Date table should have a key called DateKey of the format - (YYYYMMDD).
2. Similarly the FactTable should also have a key called FactDateKey of the format - (YYYYMMDD)
3. The two tables should be linked on the DateKey columns
4. The DateTable should be contigous and no gaps.
5. For the same period previous year it is enough to use the expression
PYRSalesSamePeriod:=CALCULATE([Sales], SAMEPERIODLASTYEAR(Calendar[FullDate]))
The Calendar here refers to the Calendar Table and the FullDate is a column in this table of format (DD/MM/YYYY).
Replace it with your names
Try it out and if this solves your problem please accept this as a solution and also give Kudos.
Cheers
CheenuSing
Anonymous
This issue was stemming from the fact that PowerBI wasn't recognizing the date field as a true date field. I had to create a new column that explicitly created a new date field for it to work. Thanks.