0

Sorry for the bad title but I'm not sure how to describe my problem in just a few words. Hopefully this next explanation is clear enough.

I have a dataset that looks something like this:

person_id      202001          202002           202003           202004 
1              1               2                3                4
2              4               3                2                1

This table is storing sales for each person for each month in a year, so for example person with id=1 has 3 sales in march 2020 (202003)

I need to convert this table into something like this:

person_id      sales      date
1              1          202001
1              2          202002
1              3          202003
1              4          202004
2              4          202001
2              3          202002
2              2          202003
2              1          202004

In this format each row stores the sales for a particular person for a particular month. I found some answers about transposing a table but I don't think that applies to this case.

user1769106
  • 138
  • 7

0 Answers0