Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
s-in-a-triangle
Frequent Visitor

merge tabseperated column values at once

Hi all,

 

My data looks like this:

 

columnid
|158|9978
|116|623|48724
|116|437|852|863|48344
|116|437|852|48337
|102|4744
 4746
|102|4747
|116|437|852|863|4755
 4845
|102|4846
 4856
|102|4882

 

I have another table where the column values are mapped to string values:

 

column_idvalue
102a
116b
158c
437d
623e
852f
863g

 

What I am looking to achieve is:

column_valuesissueid
c9978
b, e48724
b, d, f, g48344
b,d, f48337
a4744
 4746
a4747
b, d, f, g4755
 4845
a4846
 4856
a4882

 

How can I achieve this as efficient as possible?

 

I can split column by delimiter and then merge one by one, but this will get out of hand quickly.

 

  #"Split Column by Delimiter" = Table.SplitColumn(#"previous_step", "column", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"column.1", "column.2", "column.3", "column.4", "column.5", "column.6", "column.7", "column.8"}),

 

Anybody better ideas?

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @s-in-a-triangle 

 

Assuming TableNames are Table1 and Table2, try this custom column

It gives me correct results with sample data
See attached file's Query Editor as well

 

=let Replacements=Record.FromList(Table2[value],List.Transform(Table2[column_id],each Number.ToText(_)))
in
Text.Combine(List.RemoveItems(List.Transform(Text.Split([column],"|"), each Record.FieldOrDefault(Replacements, _, _)),{null,""}),",")

sinatriangle.png

 


Regards
Zubair

Please try my custom visuals

View solution in original post

1 REPLY 1
Zubair_Muhammad
Community Champion
Community Champion

Hi @s-in-a-triangle 

 

Assuming TableNames are Table1 and Table2, try this custom column

It gives me correct results with sample data
See attached file's Query Editor as well

 

=let Replacements=Record.FromList(Table2[value],List.Transform(Table2[column_id],each Number.ToText(_)))
in
Text.Combine(List.RemoveItems(List.Transform(Text.Split([column],"|"), each Record.FieldOrDefault(Replacements, _, _)),{null,""}),",")

sinatriangle.png

 


Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.