Forum Discussion
tondeli
Advocate I
8 years agoMerge columns between column values, dynamic count of columns
In my data I have id-key, dimension and dimension value. Three columns total. I don't know how many different values dimension column holds (0,1,2...n). I have pivoted my data so that dimensions will...
- 8 years ago
A dynamic solution:
#"Added Custom" = Table.AddColumn( #"Pivoted Column", "Merged", each Text.Combine( List.Transform( List.Skip( Record.FieldValues(_)), each Replacer.ReplaceValue( Text.From(_), null, "")), " - "), type text)
v-huizhn-msft
Microsoft Employee
8 years agoHi tondeli,
As I tested, please select all columns(no matter how many columns you have) by clicking "CTRL+A", then right click->Merge Columns->type the custom space as picture2 shown.
Picture1 Picture2
You will get expected result as follows.
result
It's easier to merge columns by interface navigation, rather than type the Query statement. After operation in interface, the Power Query statement will be generated automatically, you can click "Advanced Editor" and view the statements.
Best Regards,
Angelia
MarcelBeug
Community Champion
8 years agoA dynamic solution:
#"Added Custom" =
Table.AddColumn(
#"Pivoted Column",
"Merged",
each Text.Combine(
List.Transform(
List.Skip(
Record.FieldValues(_)),
each Replacer.ReplaceValue(
Text.From(_),
null,
"")),
" - "),
type text)- smpa018 years ago
Community Champion
This is awesome.
- Anonymous7 years agoNot applicable
MarcelBeug Could you explain what the parts in your function does? I like the result but have a hard time adjusting it for my needs.
Best regards,
Alex