Dashboard Mode - SAMEPERIODLASTYEAR
Business Question
How did our monthly sales perform this year compared to the same months last year?
How did our monthly sales perform this year compared to the same months last year?
| Month | Year | Sales |
|---|---|---|
| January | 2023 | 1000 |
| February | 2023 | 1200 |
| March | 2023 | 1500 |
| January | 2022 | 900 |
| February | 2022 | 1100 |
| March | 2022 | 1300 |
Total Sales = CALCULATE(SUM(SalesData[Sales]), SalesData[Year] = 2023)Sales LY = CALCULATE(SUM(SalesData[Sales]), SAMEPERIODLASTYEAR(SalesData[Date]))Sales This Year = CALCULATE(SUM(SalesData[Sales]), SalesData[Year] = 2023)Sales Last Year = CALCULATE(SUM(SalesData[Sales]), SAMEPERIODLASTYEAR(SalesData[Date]))+----------------------+----------------------+ | Total Sales This Year | Total Sales Last Year | +----------------------+----------------------+ | Line Chart | | Monthly Sales Comparison | +-----------------------------------------------+ | Sales by Month Table | +-----------------------------------------------+
A slicer for Year allows users to select 2023 or 2022. When the year changes, the KPI cards and line chart update to show sales for the selected year and the same period last year. The table filters to show only data for the selected year.
If you add a filter selecting only February, which components update and what sales values do they show?
SAMEPERIODLASTYEAR function in Power BI?SAMEPERIODLASTYEAR shifts the date context back exactly one year to compare the same time periods.SAMEPERIODLASTYEAR with a date column named Sales[Date]?'Sales'[Date] is correct.Sales LY = CALCULATE(SUM('Sales'[Amount]), SAMEPERIODLASTYEAR('Sales'[Date]))Sales LY show when filtered on March 2023?SAMEPERIODLASTYEAR.Sales LY = CALCULATE(SUM('Sales'[Amount]), SAMEPERIODLASTYEAR(Sales[Date]))Sales[Date] is invalid.SAMEPERIODLASTYEAR to calculate this?Pass the test and this pattern moves unknown