I have a dataset that look like this
doc date value
2345 201902 470942
2345 201903 470044
2345 201904 470
2345 201905 35000 ...
And I want to transform like this
doc date value value_1m value_2m value_3m
2345 201905 35000 470 470044 470942
2345 201904 470 470044 470942 ...
as you can see the new columns value_1m, value_2m, value_3m are the values of the previous months 201904, 201903, 201902 and so on.
I have tried with the (CASE WHEN key ) but my variable "date" is a number and goes for every month so I cant use it.
I am new in this forum so please sorry if it is not too clear and Thanks in advance.