I want to calculate a trend based on a 12 month rolling comparison. Compare Janaury 2020 with January 2021 for Category VW
For now my dataset seems like this:
| Dates | Category | Sales |
|---|---|---|
| 2020-01-20 | BMW | 150 |
| 2020-01-20 | VW | 200 |
| 2020-02-20 | BMW | 250 |
| 2020-02-20 | VW | 300 |
| 2020-03-20 | BMW | 220 |
| 2020-03-20 | VW | 250 |
| .......... | ..... | |
| 2021-01-20 | BMW | 500 |
| 2021-01-20 | VW | 600 |
| 2021-02-20 | BMW | 200 |
What i did for now is importing the table and formatting the date right. I am not sure how to calculate the trend. I saw some functions like lag which could be useful but have no concrete plan how to implement it right. Do you have any suggestions?