Complete the code to calculate sales for the same period last year.
Sales LY = CALCULATE(SUM(Sales[Amount]), SAMEPERIODLASTYEAR([1]))The SAMEPERIODLASTYEAR function requires a date column from a calendar or date table. Here, Calendar[Date] is the correct date column.
Complete the code to calculate last year's sales filtered by product category.
Sales LY Category = CALCULATE(SUM(Sales[Amount]), SAMEPERIODLASTYEAR([1]), FILTER(Products, Products[Category] = "Bikes"))
The SAMEPERIODLASTYEAR function needs a date column, so Calendar[Date] is correct. The filter on product category is separate.
Fix the error in the code to correctly calculate sales for the same period last year.
Sales LY = CALCULATE(SUM(Sales[Amount]), SAMEPERIODLASTYEAR([1]))The error is using a non-calendar date column. Calendar[Date] is the correct date column for SAMEPERIODLASTYEAR.
Fill both blanks to calculate last year's sales for a selected month and year.
Sales LY Selected = CALCULATE(SUM(Sales[Amount]), SAMEPERIODLASTYEAR([1]), FILTER(ALL(Calendar), Calendar[Month] = [2]))
The first blank needs the date column for SAMEPERIODLASTYEAR, which is Calendar[Date]. The second blank is the month filter value, here the string "January".
Fill all three blanks to calculate last year's sales filtered by year and product color.
Sales LY Filtered = CALCULATE(SUM(Sales[Amount]), SAMEPERIODLASTYEAR([1]), FILTER(ALL(Calendar), Calendar[Year] = [2]), FILTER(Products, Products[Color] = [3]))
The date column for SAMEPERIODLASTYEAR is Calendar[Date]. The year filter uses the number 2022. The product color filter uses the string "Red".