0

I have a large dataset where I want to combine the values of multiple rows in one column where there are duplicates in another column. See my Example below:

CURRENT DATA

Product Type Email
Product 1 [email protected]
Product 2 [email protected]
Product 3 [email protected]
Product 4 [email protected]
Product 1 [email protected]
Product 2 [email protected]

REQUIRED DATA

Product Type Email
Product 1, Product 2, Product 3, Product 4 [email protected]
Product 1, Product 2 [email protected]

The values in the column "Product Type" are combined and separated by commas wherever the Emails are duplicates in the "Email" column.

4
  • 1
    newer versions of excel (2021+) would use just 3 formulas to perform this task. Unfortunately you tag with excel 2010. I don't think power query existed back, leaving you only with VBA.
    – gns100
    Commented Jan 11, 2022 at 20:55
  • @gns100 if using Excel 2021+ is an easier option I will hunt down an install. If you can share the formulas that would still be very helpful. Removing the excel 2010 tag so not to limit myself. Thanks.
    – Denoteone
    Commented Jan 11, 2022 at 21:01
  • for newer excel column email would be Unique(), then for column product type it would be something like: Arraytotext(filter()). good luck.
    – gns100
    Commented Jan 11, 2022 at 21:08
  • I believe these formulas are available on the free web version of excel. At least that's what I see when I checked, but don't know if my free account is somehow linked to my desktop version...
    – gns100
    Commented Jan 11, 2022 at 21:14

1 Answer 1

1

Power query is available as a free add-in from Microsoft for Excel 2010+.

All you need to do is Group by email and change the m-code to concatenate the relevant rows.

I "Named" the table created "currentData" and you see that referenced in the code.

let
    Source = Excel.CurrentWorkbook(){[Name="currentData"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Product Type", type text}, {"Email", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Email"}, {
        {"Products", each Text.Combine([Product Type], ", "), Text.Type}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Grouped Rows",{"Products", "Email"})
in
    #"Reordered Columns"

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .