Forum Discussion
Year over year comparison
- 7 years ago
The right way to do this is create a date table, then add a date column to your data in Power Query. This old post will help with that since you only have week and year.
Once you've done that, the SAMEPERIODLASTYEAR() function will return the dates you need. So, say your sales is the [Total Sales] measure.
Sales Last Year = CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( Dates[Date] ) )Would return sales for last year in the same context as your visual. So if your visual is showing a full year, it will be the full LY data. If it is by quarter, week, or day, it will still be the samething for last year.
The right way to do this is create a date table, then add a date column to your data in Power Query. This old post will help with that since you only have week and year.
Once you've done that, the SAMEPERIODLASTYEAR() function will return the dates you need. So, say your sales is the [Total Sales] measure.
Sales Last Year =
CALCULATE (
[Total Sales],
SAMEPERIODLASTYEAR ( Dates[Date] )
)Would return sales for last year in the same context as your visual. So if your visual is showing a full year, it will be the full LY data. If it is by quarter, week, or day, it will still be the samething for last year.