Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Split variables and associated values into separate columns

Hi!
I have this particular table:

VariablesValues
new person4
new person9
new person8
new person2
old person5
old person1
old person7
old person3

 

Now I want to convert the table in such a way that the final output should return this:

VariableValue_1VariableValue_2
new person4old person5
new person9old person1
new person8old person7
new person2old person3

 

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_Daniel's avatar
    wdx223_Daniel
    Community 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)))