Sample Data
Sales data for three days in 2023 and the same days in 2022.
| Cell | Value |
|---|---|
| A1 | Date |
| B1 | Sales |
| A2 | 2023-01-01 |
| B2 | 100 |
| A3 | 2023-01-02 |
| B3 | 150 |
| A4 | 2023-01-03 |
| B4 | 200 |
| A5 | 2022-01-01 |
| B5 | 80 |
| A6 | 2022-01-02 |
| B6 | 120 |
| A7 | 2022-01-03 |
| B7 | 180 |
Sales data for three days in 2023 and the same days in 2022.
| Cell | Value |
|---|---|
| A1 | Date |
| B1 | Sales |
| A2 | 2023-01-01 |
| B2 | 100 |
| A3 | 2023-01-02 |
| B3 | 150 |
| A4 | 2023-01-03 |
| B4 | 200 |
| A5 | 2022-01-01 |
| B5 | 80 |
| A6 | 2022-01-02 |
| B6 | 120 |
| A7 | 2022-01-03 |
| B7 | 180 |
CALCULATE(SUM(Sales[Sales]), SAMEPERIODLASTYEAR(Calendar[Date]))A B 1 Date Sales 2 2023-01-01 100 3 2023-01-02 150 4 2023-01-03 200 5 2022-01-01 80 6 2022-01-02 120 7 2022-01-03 180 Formula references Sales[Sales] in column B and Calendar[Date] in column A. SAMEPERIODLASTYEAR uses dates in A2:A4 to find matching dates in A5:A7.
A B C 1 Date Sales Result 2 2023-01-01 100 380 3 2023-01-02 150 4 2023-01-03 200 5 2022-01-01 80 6 2022-01-02 120 7 2022-01-03 180
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