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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
StuartSmith
Power Participant
Power Participant

Combine Rows with same ID Column.

I have a table (sample data below) and need to combine all rows with the same ID. All rows with the same ID are identical, apart from the "Store Room Security" column that may contain 1 value, multiple values or empty.

StuartSmith_1-1689150636367.png

So as an example, I would like all rows to remain intact, unless there are duplicate ID vlaues and then combine the "Secure Store Security" column so it looks like ID 61 "CCTV, Pin Code, Access Code"

 

StuartSmith_2-1689151097885.png

Thank in advance.

 

 

 

1 ACCEPTED SOLUTION
Nithinr
Resolver III
Resolver III

Group by the ID, Region, text and combine the Store room security as below M query. refer below link for better understanding . Solved: Combining Rows based on the ID of that table - Microsoft Fabric Community

 

 

= Table.Group(#"Specify the above step name", {"ID","Region","Country"}, {{"Store Room Security", each Text.Combine([Store Room Security], ", "), type nullable text}})

 

View solution in original post

5 REPLIES 5
StuartSmith
Power Participant
Power Participant

Thanks everyone 🙂 all sorted.

miTutorials
Super User
Super User

I have made a tutorial incase you find this helpful.

 

Combine / Merge Rows based on ID column using power Query in Power BI | MiTutorials 

Dhairya
Solution Supplier
Solution Supplier

Hey @StuartSmith 

Please follow the below steps to achieve the required output

 

Step 1: Select columns by which you want to "group by" and click on "Group By" button in "transform" pane.

 

Dhairya_1-1689154134865.png

 

Step2: 

 

Dhairya_2-1689154310291.png

 

Step 3: You will get the following output with the error

 

Dhairya_3-1689154432290.png

 

Step 4: Now update the above-highlighted query with the following query

 

= Table.Group(#"Changed Type", 
{"Segment", "Country"},
{{"Products", each Text.Combine(List.Distinct([Product]),", "),
type nullable text}})

Here I have used two functions

 

Text.Combine(): for combining rows with delimiter (in your case delimiter is ",")

List.Distinct(): for removing duplicate values(you can ignore if you want duplicate values)

 

You will the expected output below:
 

Dhairya_4-1689154705060.png

 

If this helps you, please mark my solution as accepted so that others can find it quickly while facing a similar issue. Thank you!

Nithinr
Resolver III
Resolver III

Group by the ID, Region, text and combine the Store room security as below M query. refer below link for better understanding . Solved: Combining Rows based on the ID of that table - Microsoft Fabric Community

 

 

= Table.Group(#"Specify the above step name", {"ID","Region","Country"}, {{"Store Room Security", each Text.Combine([Store Room Security], ", "), type nullable text}})

 

On first inspection, that looks good, so thanks. Is there a simply way to group by all the columns in the table or would I need to manually add all the columns here...

 

= Table.Group(#"Reordered Columns", {"ID", "Region", "Country", Remaining Columns...}

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.