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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Elliot137
Regular Visitor

Merging Specific Columns of a Table

I am trying to merge colums based on duplicate block numbers so I would like all the information on 2 (or more) seperate lines to merge together for all the rows that have the same block number ('Block #' Column).

 

The 'Accept/Reject' column will always be 'Major' for this table. For the 'Date Raised' column I would like the earliest date. All the other columns I would like contatenated together with commas seperating them.

 

I would greatly appreciate any help!

 

Below I have shown an example of the data set I have and what I would like it to look like: 

 
Elliot137_1-1680097087683.png

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Elliot137 ,

 

The following example query turns this:

BA_Pete_0-1680100869303.png

 

...into this:

BA_Pete_1-1680100895773.png

 

Example Query:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNvFR0lEyNDU0VYrViVYyMTYyDAcJmFgagAWQVJhDBSwNXMEqLEzQBMyNlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Block #" = _t, #"M/C" = _t]),
    
    groupRows = Table.Group(Source, {"Block #"}, {{"M/C", each Text.Combine([#"M/C"], ", "), type nullable text}})
in
    groupRows

 

 

Summary:

Group By whichever columns you want to keep.

Create aggregate columns for each of the columns you want to combine using the SUM (or any statistical) operator.

Edit the resulting code in the formula bar to change List.Sum(...) to Text.Combine(..., ", ") for each of the columns to be combined.

So this:

BA_Pete_2-1680101129877.png

 

...goes to this:

BA_Pete_3-1680101173265.png

 

For your date column, you can just choose the MIN operator during the Group By process.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

2 REPLIES 2
Elliot137
Regular Visitor

Thanks a lot @BA_Pete 

BA_Pete
Super User
Super User

Hi @Elliot137 ,

 

The following example query turns this:

BA_Pete_0-1680100869303.png

 

...into this:

BA_Pete_1-1680100895773.png

 

Example Query:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNvFR0lEyNDU0VYrViVYyMTYyDAcJmFgagAWQVJhDBSwNXMEqLEzQBMyNlGJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Block #" = _t, #"M/C" = _t]),
    
    groupRows = Table.Group(Source, {"Block #"}, {{"M/C", each Text.Combine([#"M/C"], ", "), type nullable text}})
in
    groupRows

 

 

Summary:

Group By whichever columns you want to keep.

Create aggregate columns for each of the columns you want to combine using the SUM (or any statistical) operator.

Edit the resulting code in the formula bar to change List.Sum(...) to Text.Combine(..., ", ") for each of the columns to be combined.

So this:

BA_Pete_2-1680101129877.png

 

...goes to this:

BA_Pete_3-1680101173265.png

 

For your date column, you can just choose the MIN operator during the Group By process.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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