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
Krc721
Helper I
Helper I

Group by one column and merge contents of duplicate columns

Hi,

I need to process an excel file in power bi desktop/power query where there may be one or more of the same value in column a.  For each row there are people assigned to the object in column a.   I need to be able to concatenate all the people into one cell separated by semi-colon and have only one line for each item in column a.

 

Ex.

Product Name        Product Builder Name    Project Quality Control Name  Product Owner  Product Tester  Product Shipper

Game 1                    Joe Smith                            John Smith                             Jane Smith       Jill Smith           Bob Jones

Game 1                    Joe Jones                            John Smith                             Jane Smith        Jill Smith           John Jones

Game 2                    Scooby Doo                        Shaggy                                    Velma            Daffney              Freddie

 

Output

Game 1                 Joe Smith; Joe Jone                John Smith                             Jane Smith        Jill Smith         Bob Jones

Game 2                   Scooby Doo                        Shaggy                                    Velma                Daffney              Freddie

 

So one record for Product, concatenating multiple names when different, one name when the same across multiple rows.

 

Thanks!

1 ACCEPTED SOLUTION
Krc721
Helper I
Helper I

@amitchandak 

I believe I solved it.  I made duplicate copies of the query in Power BI.  Then I selected only the role and product name for each role.  Then I deduped each one selecting the Product Name and Role Name (except in master query) so that multiple instances of the same product with same person were gone.  Then I removed the nulls and did some other cleanup and then did the group by on the product changing the Sum to the Text.Combine feature and adding the proper seperator and the word nullable in the last part of the expression for each of the role tables.  When they were imported back into Power BI, checked the data model and all were connected back to the master table.   The Master table was deduped based only on product name after removing the role columns.

 

The master table had all data except for the roles.

Each role had only one other column, product name


Then built the report in table visual in Power BI.

View solution in original post

3 REPLIES 3
Krc721
Helper I
Helper I

@amitchandak 

I believe I solved it.  I made duplicate copies of the query in Power BI.  Then I selected only the role and product name for each role.  Then I deduped each one selecting the Product Name and Role Name (except in master query) so that multiple instances of the same product with same person were gone.  Then I removed the nulls and did some other cleanup and then did the group by on the product changing the Sum to the Text.Combine feature and adding the proper seperator and the word nullable in the last part of the expression for each of the role tables.  When they were imported back into Power BI, checked the data model and all were connected back to the master table.   The Master table was deduped based only on product name after removing the role columns.

 

The master table had all data except for the roles.

Each role had only one other column, product name


Then built the report in table visual in Power BI.

amitchandak
Super User
Super User

@Krc721 . Try a new column like

Concatenatex(Distinct({[Product Builder Name],[Project Quality Control Name],[Product Owner],[Product Tester], [Product Shipper]}), [Value], ", ")

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi Amit.  This is great for another use case I had. Thank you. However, my apologizes for not being clear.  It is the same column across multiple rows.  So in the example.  Game 1 is the product for the group by. They want one row by Game 1 and then there are two different product builders and they want those on one cell called product builder separated by semi colon.  Where there is only one person they want the name to show only once. If the column is empty it should show empty.  The data will be presented in Power BI in table form.   I tried using group by and then switch the List.Sum to Text.Combine and add seperator; however, it duplicates where same name is in multiple roles and puts the separator where there are nulls.  In some rows, the product may be listed with as many as 5 in the same role.

 

I was able to do it in Alteryx and tried to use a similar methodolgoy in Power BI as that is where it has to be built and I am not having success as there is a separator in empty columns and any Product that has several lines with the same person in the role on multiple lines concatenates duplication of name. 

 

 

Product        Product Builder           Product Quality Control  Product Owner   Product Tester  Product Shipper

Game 1       Joe Smith,Joe Jones     John Smith                         Jane Smith        Jill Smith          Bob Jones, John Jones

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.