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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
merijndk
New Member

Combine all columns from a row in 1 new column

I have the following table:

 

ID | 1  | 2  | 3  | 4  |
0  | 11 | 12 | 10 | 18 |
2  | 14 | 13 | 19 | 20 |

Now I want to combine all rows after ID to 1 new row that has all the values with commas seperated, so:

 

ID | allow_rows  |
0  | 11,12,10,18 |
1  | 14,13,19,20 |

 How could I achieve this in the query editor?

1 ACCEPTED SOLUTION
MarcelBeug
Community Champion
Community Champion

A more dynamic solution would be the following code:

 

let
    Source = Input,
    #"Added Custom" = Table.AddColumn(Source, "allow_rows", each Text.Combine(List.Transform(List.Skip(Record.FieldValues(_)),Text.From),",")),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"ID", "allow_rows"})
in
    #"Removed Other Columns"
Specializing in Power Query Formula Language (M)

View solution in original post

2 REPLIES 2
MarcelBeug
Community Champion
Community Champion

A more dynamic solution would be the following code:

 

let
    Source = Input,
    #"Added Custom" = Table.AddColumn(Source, "allow_rows", each Text.Combine(List.Transform(List.Skip(Record.FieldValues(_)),Text.From),",")),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"ID", "allow_rows"})
in
    #"Removed Other Columns"
Specializing in Power Query Formula Language (M)
MetrumOBE
Regular Visitor

Hello merijndk,

 

you can do it by adding a custom column in the Query Editor and then perform a concatenation like this :

 

= [1] & "," & [2] & "," ...

 

This is in the case you have a fix number of columns.

 

Or you can follow this post explaining how to merge several columns to create a merged one.

https://support.office.com/en-us/article/Merge-columns-Power-Query-80ec9e1e-1eb6-4048-b500-d5d42d9f0...

 

Or, you can also use the CONCATENATEX() DAX function into the Power BI Model.

 

I hope it will help you.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors