Combine duplicate rows with unique ID and maintain columns

Anonymous
2023-11-03T01:04:03+00:00

Hello world!

I have a worksheet where there are multiple rows with the same unique identifier, but each row has several columns of data. I want to combine them down to one row per unique identifier while keeping the columns. If all rows with the same ID have blanks, leave the column blank. If any column has data, consolidate it down to the one row. Data will not overlap/overwrite in the worksheet due to the nature of the data. I have absolutely no idea how to get this done without going one at a time and I have over 1,000 rows. Please help!!!!

The table might look like:

Name Value A Value B Value C
Bob Book Chair
Sally Zebra
Bob Vanilla
Sally Tablet

and what I want to get would be:

Name Value A Value B Value C
Bob Book Chair Vanilla
Sally Zebra Tablet

I really could use a life saver here... I'm desperate and have to submit the data table ASAP.

Microsoft 365 and Office | Excel | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Anonymous
    2023-11-03T01:58:53+00:00

    Hello Ross A,

    I'm Shalom and I'd happily help you with your question. In this forum, we are Microsoft consumers just like yourself.

    I understand your situation. Here are a few methods you can use to consolidate rows with the same identifier in Excel:

    Method 1: Using the Excel Consolidate tool

    Go to Data > Consolidate. In the Consolidate dialog box, accept the default SUM function, under Reference select the data range, click the Add button, check the Top row and Left column options, and then click OK.

    Method 2: Using IF function with helper columns

    Select the dataset and go to Data > Sort A to Z. Add Helper column 1 and enter the formula =IF(A2=A1,B1&”,”&B2,B2) in cell C2. Press Enter key and drag the Fill Handle button to the rest of the empty cells in the helper Column C.

    Add Helper Column 2 and enter the formula =IF(C2<>B2,”Combined”,””) in cell D2. Press Enter key and drag down the Fill Handle to the empty cells.

    Please let me know if you need more help.

    Best Regards, Shalom

    14 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-11-03T20:27:26+00:00
    2 people found this answer helpful.
    0 comments No comments
  3. Ashish Mathur 100.9K Reputation points Volunteer Moderator
    2023-11-03T23:24:45+00:00

    Hi,

    This M code works

    let

    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], 
    
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Name"}, "Attribute", "Value"), 
    
    #"Pivoted Column" = Table.Pivot(#"Unpivoted Other Columns", List.Distinct(#"Unpivoted Other Columns"[Attribute]), "Attribute", "Value") 
    

    in

    #"Pivoted Column"
    

    Hope this helps.

    3 people found this answer helpful.
    0 comments No comments
  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more