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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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/g...

 

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/g...

 

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 and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.