How to combine duplicate rows into one (keeping unique data only)

Anonymous
2021-12-02T12:52:38+00:00

Dear experts,

I have a list with thousands entries, first column has duplicate values, while values in the second column are different.

What I am trying to achieve is shown in the screenshot below:

  1. Column 1: To merge unique values only and omitting duplicates.
  2. Column 2: Combine data from those duplicate rows into one cell, separated by comma.

Is there a function in Excel to achieve this, can Power Query do this?

I do appreciate your kind support.

Microsoft 365 and Office | Excel | For business | 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
Answer accepted by question author
  1. HansV 462.4K Reputation points MVP Volunteer Moderator
    2021-12-02T14:39:23+00:00

    Don't format the data on the right as a table.

    Enter the following formula in D5:

    =UNIQUE(Table1[Key])

    where Table1 is the name of the table on the left. The formula will automatically spill to the cell(s) below.

    In E5, enter the formula

    =TEXTJOIN(", ",TRUE,IF(Table1[Key]=D5,Table1[Data],""))

    and fill or copy down.

    39 people found this answer helpful.
    0 comments No comments
Answer accepted by question author
  1. Ashish Mathur 100.8K Reputation points Volunteer Moderator
    2021-12-02T23:52:27+00:00

    Hi,

    You may refer to 2 solutions in this workbook - Query Editor and formulas.

    Hope this helps.

    27 people found this answer helpful.
    0 comments No comments

6 additional answers

Sort by: Most helpful
  1. HansV 462.4K Reputation points MVP Volunteer Moderator
    2021-12-02T16:05:53+00:00

    Don't worry - it might well be useful to users who don't have the latest version of Excel.

    2 people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2021-12-03T07:10:01+00:00

    Hi,

    You may refer to 2 solutions in this workbook - Query Editor and formulas . . .

    Thank You Ashish Mathur.

    I am learning Power Query. When I solved this question using formulas, I was also curious to know the solution using PQ.

    Thank You!

    0 comments No comments
  3. Ashish Mathur 100.8K Reputation points Volunteer Moderator
    2021-12-03T07:19:51+00:00

    You are welcome.

    0 comments No comments