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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Concatenate text column rows based on unique column key

Hey, 

Is theire a way to Concatenate rows in a text column based on a unique identifier column? 

I have created an example of my datainput and the output i want:

NikFe_0-1649250480950.png

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

In a new query step, insert following

Table.Group(#"Changed Type", {"UniqueOperation ID", "Outermessage"}, {{"Details", each Text.Combine([Details],","), type nullable text}})

If you want to see complete working for a sample - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ0VNJRcgTiRJ0kpVgdZJFknRSdVDSxNDDfyMgIyi/UKdIpQRMrUIqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"UniqueOperation ID" = _t, Outermessage = _t, Details = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"UniqueOperation ID", Int64.Type}, {"Outermessage", type text}, {"Details", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"UniqueOperation ID", "Outermessage"}, {{"Details", each Text.Combine([Details],","), type nullable text}})
in
    #"Grouped Rows"

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

if you like text items on distinct lines

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ0VNJRyi0uKwZSiUnJSrE6aIIpqWmYghmZ6WBBIyMjIC89Pz89JxXISMssKi5RyMnMS8UmW5yanJ+XglM6JxGuNxYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, msg = _t, detail = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"msg", type text}, {"detail", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"id", "msg"}, {{"all det", each Text.Combine([detail], ", #(cr)")}})
in
    #"Grouped Rows"

 

 

group lines.png

Vijay_A_Verma
Super User
Super User

In a new query step, insert following

Table.Group(#"Changed Type", {"UniqueOperation ID", "Outermessage"}, {{"Details", each Text.Combine([Details],","), type nullable text}})

If you want to see complete working for a sample - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test (later on when you use the query on your dataset, you will have to change the source appropriately)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ0VNJRcgTiRJ0kpVgdZJFknRSdVDSxNDDfyMgIyi/UKdIpQRMrUIqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"UniqueOperation ID" = _t, Outermessage = _t, Details = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"UniqueOperation ID", Int64.Type}, {"Outermessage", type text}, {"Details", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"UniqueOperation ID", "Outermessage"}, {{"Details", each Text.Combine([Details],","), type nullable text}})
in
    #"Grouped Rows"

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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

Top Solution Authors