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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Power Query: How do I convert multiple rows to comma separated values, according to their IDs?

Hi everyone!

 

I have the following dataset:

IDColour
1Red
1Blue
1Green
1Yellow
2Red
2Blue
3Green

 

How can I transform it to the following, but it has to be in Power Query:

 

IDColours
1Red, Blue, Green, Yellow
2Red, Blue
3Green


Thank you!

1 ACCEPTED SOLUTION
Thingsclump
Resolver V
Resolver V

Hi @Anonymous 

 

This article explains it. You have to group it and then tweak the code little bit to join text rather than sum.

 

https://exceltown.com/en/tutorials/power-bi/powerbi-com-and-power-bi-desktop/power-bi-data-sources/group-by-to-merge-texts-something-like-concatenatex-but-in-queries/

 

Thanks,

thingsclump

www.thingsclump.com 

View solution in original post

5 REPLIES 5
adityaD
Frequent Visitor

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQpKTVGK1YGwnXJKU+Ec96LU1Dw4LzI1Jye/HMw1QtJlhKzLGKErFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Colour = _t]),
#"Grouped Rows" = Table.Group(Source, {"ID"}, {{"Count", each _[Colour], type table [ID=nullable text, Colour=nullable text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Text.Combine([Count],",")),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Count"})
in
#"Removed Columns"

Thingsclump
Resolver V
Resolver V

Hi @Anonymous 

 

This article explains it. You have to group it and then tweak the code little bit to join text rather than sum.

 

https://exceltown.com/en/tutorials/power-bi/powerbi-com-and-power-bi-desktop/power-bi-data-sources/group-by-to-merge-texts-something-like-concatenatex-but-in-queries/

 

Thanks,

thingsclump

www.thingsclump.com 

It works. Thank you!

It works. Thank you!
Anonymous
Not applicable


That's awesome. Thank you @Thingsclump 

Helpful resources

Announcements
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.