Forum Discussion
Compare to last year
Hello,
I would like to compare last year's sales based on the date selection. For example, if the date selected is April 1-15, 2024, the previous year column should show the sales for April 1-15, 2023.
I created 2 sample measures based on SAMEPERIODLASTYEAR and DATEADD but it seems that I am missing something. The PREVIOUS YEARS show the same as the current year (selected date range). Thanks.
Hi,
Create a Calendar Table with a relationship (Many to One and Single) from the Date column of sheet1 to the Date column of the Calendar Table. To your visual/slicer/filter, drag Date from the Calendar Table. Write these measures:
Total = SUM('Sheet1'[SALES])
Total in SPLY = CALCULATE(SUM('Sheet1'[SALES]), sameperiodlastyear(calendar[date]))
Hope this helps.
3 Replies
- Ashish_Mathur
Super User
Hi,
Create a Calendar Table with a relationship (Many to One and Single) from the Date column of sheet1 to the Date column of the Calendar Table. To your visual/slicer/filter, drag Date from the Calendar Table. Write these measures:
Total = SUM('Sheet1'[SALES])
Total in SPLY = CALCULATE(SUM('Sheet1'[SALES]), sameperiodlastyear(calendar[date]))
Hope this helps.
- Oros
Post Prodigy
- Ashish_Mathur
Super User
You are welcome.