Dashboard Mode - DATEADD for period shifts
Business Question
How can we compare sales this year to sales in the same period last year using period shifts?
How can we compare sales this year to sales in the same period last year using period shifts?
| Date | Sales Amount |
|---|---|
| 2023-01-01 | 100 |
| 2023-02-01 | 150 |
| 2023-03-01 | 200 |
| 2023-04-01 | 250 |
| 2023-05-01 | 300 |
| 2023-06-01 | 350 |
| 2023-07-01 | 400 |
Total Sales = SUM('Sales'[Sales Amount])Sales Last Year = CALCULATE(SUM('Sales'[Sales Amount]), DATEADD('Sales'[Date], -1, YEAR))Total Sales measureSales Last Year measure+-----------------------------+-----------------------------+ | Total Sales This Year (KPI) | Sales Last Year (KPI) | +-----------------------------+-----------------------------+ | Line Charts: | | +-------------------------+ +-----------------------------+ | | | Monthly Sales This Year | | Monthly Sales Last Year | | | +-------------------------+ +-----------------------------+ | +---------------------------------------------------------------+ | Table: Sales by Month | +---------------------------------------------------------------+
A date slicer allows selecting a date range. When the user changes the date range, all components update to show sales and last year sales for the selected period.
The DATEADD function shifts the date context by -1 year to calculate last year's sales for the same period.
If you add a filter to show only dates from January to March 2023, which components update?