Forum Discussion
Same time last year.
Hi,
I have a dataset with 4 columns. Below is the sample and complete dataset can be found here - https://drive.google.com/file/d/1Yje0VHf3sNgfuQ65rMCDVPn95Wo6x-tG/view?usp=sharing
| Product | Week | Metric | Value |
| Product A | 1/4/2019 | Units | 12899 |
| Product A | 1/11/2019 | Units | 13893 |
| Product A | 1/18/2019 | Units | 13158 |
| Product A | 1/25/2019 | Units | 12384 |
| Product A | 2/1/2019 | Units | 13293 |
| Product A | 2/8/2019 | Units | 13528 |
| Product A | 2/15/2019 | Units | 12621 |
This is the desired output (sample - complete output is in the file)
| 1/3/2020 | 1/10/2020 | 1/17/2020 | 1/24/2020 | 1/31/2020 | 2/7/2020 | 2/14/2020 | 2/21/2020 | |
| Units | 10549 | 12062 | 12140 | 11224 | 11611 | 12414 | 12263 | 12479 |
| Forecast | ||||||||
| Last year (Units) | 12899 | 13893 | 13158 | 12384 | 13293 | 13528 | 12621 | 13053 |
| Change | -2350 | -1831 | -1018 | -1160 | -1682 | -1114 | -358 | -574 |
| Change% | -18.2% | -13.2% | -7.7% | -9.4% | -12.7% | -8.2% | -2.8% | -4.4% |
I am actually not what measure can be used to show the same time last year's units and the change. The format of the data cannot be changed (as there are other views dependent on this data) but we can add columns if required for this view.
4 Replies
- Fowmy
Super User
itsmeanuj
Create a weekly Calendar Table or use the data table with Year and Week Number then use the below formula get the previous year same week value. Other steps are simple.
https://1drv.ms/u/s!AmoScH5srsIYgYI9aLoSXu8qL3-T5w?e=TDKYugLast Year Units = VAR LY = CALCULATE( SUM(Data[Value]), FILTER(ALL('CAlendar'), 'CAlendar'[YEAR]=MAX('CAlendar'[YEAR])-1 && 'CAlendar'[WEEK] = MAX('CAlendar'[WEEK]) ) ) RETURN LY________________________
Did I answer your question? Mark this post as a solution, this will help others!.
I accept KUDOS 🙂 , Click on the Thumbs-Up button on the right.
- amitchandak
Super User
You try sameperiodlastyear or a trailing year measure
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
https://docs.microsoft.com/en-us/dax/sameperiodlastyear-function-dax
Refer this blog
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184
Appreciate your Kudos.- itsmeanuj
Helper IV
amitchandak dataset is a bit different since it is a weekly data. so we have to compare 1st week of 2019 with 1st week of 2020 and so on.
- amitchandak
Super User
itsmeanuj , you use week Rank. and week Number.
Please refer WTD Questions— Time Intelligence 4–5
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3In this first link, question same week last year. In second link look at comments