Reputation: 11
I have some data in the following format
Item | Spend Month 1 | Spend Month 2 | Income Month 1 | Income Month 2 |
---|---|---|---|---|
First | row | Number | Number | Number |
Second | row | Number | Number | Number |
I would like to trans form this to
Item | Month | Spend | Income |
---|---|---|---|
First | Month 1 | Number | Number |
First | Month 2 | Number | Number |
Second | Month 1 | Number | Number |
Second | Month 2 | Number | Number |
Upvotes: 0
Views: 114
Reputation: 943
Here is one possible solution in PowerQuery:
let
Quelle = Excel.CurrentWorkbook(){[Name="Tabelle1"]}[Content],
UnpivotOtherColumns = Table.UnpivotOtherColumns(Quelle, {"Item"}, "Month", "Wert"),
DuplicateColumn = Table.DuplicateColumn(UnpivotOtherColumns, "Month", "Attribute"),
TextAfterDelim = Table.TransformColumns(DuplicateColumn, {{"Month", each Text.AfterDelimiter(_, " ", {1, RelativePosition.FromEnd}), type text}}),
TextBeforeDelim = Table.TransformColumns(TextAfterDelim, {{"Attribute", each Text.BeforeDelimiter(_, " "), type text}}),
PivotColumn = Table.Pivot(TextBeforeDelim, List.Distinct(TextBeforeDelim[Attribute]), "Attribute", "Wert")
in
PivotColumn
Upvotes: 1