Forum Discussion
rpiboy_1
Helper V
3 years agoDynamically Merge Multiple Columns
Hi all, I want to dynamically merge columns in a function. Let's say I have this fairly 'standard' PQ expression: #"Inserted Merged Column" = Table.AddColumn(#"PreviousStepp", "NewColumnN...
- 3 years ago
Here is one way to do it. You can provide the colnames as a concatenated text string and parse it in the function.
//fnAddMergeColumn let Source = (inputtable as table, newcolumn as text, colnames as text) => let result = Table.AddColumn(inputtable, "Concatenated", each Text.Combine(Record.ToList(Record.SelectFields(_, Text.Split(colnames, "-")) ), ".")) in result in Source
ppm1
Solution Sage
3 years agoHere is one way to do it. You can provide the colnames as a concatenated text string and parse it in the function.
//fnAddMergeColumn
let
Source = (inputtable as table, newcolumn as text, colnames as text) =>
let
result = Table.AddColumn(inputtable, "Concatenated", each Text.Combine(Record.ToList(Record.SelectFields(_, Text.Split(colnames, "-")) ), "."))
in
result
in
Source