Forum Discussion
Split variables and associated values into separate columns
Hi!
I have this particular table:
| Variables | Values |
| new person | 4 |
| new person | 9 |
| new person | 8 |
| new person | 2 |
| old person | 5 |
| old person | 1 |
| old person | 7 |
| old person | 3 |
Now I want to convert the table in such a way that the final output should return this:
| Variable | Value_1 | Variable | Value_2 |
| new person | 4 | old person | 5 |
| new person | 9 | old person | 1 |
| new person | 8 | old person | 7 |
| new person | 2 | old person | 3 |
So basically I want to split the variables and their associated values from one column to separate columns. Any tips / workarounds ?
=Table.FromColumns(List.Combine(Table.Group(PreviousStepName,"Variable",{"n",Table.ToColumns})[n]),List.TransformMany({0..List.Count(List.Distinct(PreviousStepName[Variable]))-1},each Table.ColumnNames(PreviousStepName),(x,y)=>if x=0 then y else y&"_"&Text.From(x)))
1 Reply
- wdx223_DanielCommunity Champion
=Table.FromColumns(List.Combine(Table.Group(PreviousStepName,"Variable",{"n",Table.ToColumns})[n]),List.TransformMany({0..List.Count(List.Distinct(PreviousStepName[Variable]))-1},each Table.ColumnNames(PreviousStepName),(x,y)=>if x=0 then y else y&"_"&Text.From(x)))