0

Is there an easy way to convert a matrix like table to just two columns, one with the record ID and one with a Category representing the old columns (not sure how to phrase it)?

I have:

id    foo   bar   baz
1     x
2           x
3                 x
4     x     x     x

I want:

id    category
1     foo
2     bar
3     baz
4     foo
4     bar
4     baz

The fourth row of the first tabe gets 3 rows in the new table since it has an 'x' for each column.

Please let me know if there is a better way to phrase this question or if this type of operation has name.

sushi
  • 274
  • 1
  • 4
  • 13
  • 2
    It is called UnPivot. and you can do this with power query. https://stackoverflow.com/questions/20541905/convert-matrix-to-3-column-table-reverse-pivot-unpivot-flatten-normal See the second answer. – Scott Craner Nov 02 '22 at 22:22
  • Excellent! 'Unpivot other columns' worked perfectly. – sushi Nov 02 '22 at 22:26

0 Answers0