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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Mitchell92
Helper II
Helper II

Merging text in rows per unique key

Hi all,

 

Hoping this is an easy one for some of you. I have data that looks like this in the Power Query Editor that I'd like to "merge" into one row (except this is over about 250K rows):

 

Column 1 (Key)

Column 2 (Free text field)

181

This is an

181

example of the

181

data I am trying to merge

 

Hoping you may know the easiest way to do this?

 

Thank you in advance.

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Use group by in combination with Text.Combine. See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQwVNJRCsnILFYAosQ8pVgdmGBqRWJuQU6qQn6aQklGKpJESmJJooKnQmKuQklRZWZeukJJvkJualE6UE0sAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column 1" = _t, #"Column 2" = _t]),
    #"Grouped Rows" = Table.Group(Source, {"Column 1"}, {{"Result", each Text.Combine([Column 2]," ")}})
in
    #"Grouped Rows"

View solution in original post

2 REPLIES 2
Vijay_A_Verma
Super User
Super User

Use group by in combination with Text.Combine. See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQwVNJRCsnILFYAosQ8pVgdmGBqRWJuQU6qQn6aQklGKpJESmJJooKnQmKuQklRZWZeukJJvkJualE6UE0sAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column 1" = _t, #"Column 2" = _t]),
    #"Grouped Rows" = Table.Group(Source, {"Column 1"}, {{"Result", each Text.Combine([Column 2]," ")}})
in
    #"Grouped Rows"

Thanks Vijay

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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