+ Reply to Thread
Results 1 to 7 of 7

Merging non-unique entries into a single unique entry

  1. #1
    Registered User
    Join Date
    09-11-2015
    Location
    United States
    MS-Off Ver
    2007/2010
    Posts
    8

    Merging non-unique entries into a single unique entry

    Hello,

    I'm working with a dataset of about 20 columns and 40,000 rows. The columns include a unique identifier (ID1), a non-unique identifier (ID2), and then binary variables. For example, a small section of my dataset would look like this:

    ID1---------ID2-----------Red----------Green------Blue--------Orange

    JS------John Smitha-------0--------------1-----------1------------0
    JS------John Smithb-------1--------------1-----------0------------0
    MB------Matt Brown-------0--------------1-----------1------------1
    DB------David Book-------0--------------0-----------0------------1

    I need to combine the ID2 entries according to their unique ID1 in a way that combines a 0 and 1 as 1, a 0 and a 0 as 0, and a 1 and a 1 as 1. For example, the new table should be as follows:

    ID1-----Red----------Green------Blue--------Orange

    JS--------1--------------1-----------1------------0
    MB-------0--------------1-----------1------------1
    DB-------0--------------0-----------0------------1

    I would like to avoid doing this manually, as there are about 5,000 non-unique entries that need to be combined.
    Thanks for your help!

  2. #2
    Valued Forum Contributor
    Join Date
    10-10-2012
    Location
    New York
    MS-Off Ver
    Excel 2007/2010
    Posts
    337

    Re: Merging non-unique entries into a single unique entry

    You should be able to accomplish what you want by using a pivot table.

    - Highlight your table/data set and insert a pivot table
    - Drag ID1 field into the Row Labels box
    - Drag your Color fields into the Values box
    - For each field you have in the Values box, change the Value Field Settings to Summarize values by Max and not Sum.

    You can either keep the pivot table or copy/paste special values.
    Don't just use the answers provided for you. Try to understand how it works by reverse engineering or asking about it.

    Please mark the thread as [SOLVED] (Thread Tools->Mark thread as Solved) when answered.
    If you're happy with an answer given, please click the * under the person's name to boost their reputation.

  3. #3
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Merging non-unique entries into a single unique entry

    This post might have the answer to your problem:
    http://www.excelforum.com/excel-gene...e-records.html
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  4. #4
    Registered User
    Join Date
    09-11-2015
    Location
    United States
    MS-Off Ver
    2007/2010
    Posts
    8

    Re: Merging non-unique entries into a single unique entry

    Thank you! I will do some reading up on pivot tables, and if I can't make it work I'll move on to the VBA code. I'll post back with progress.

  5. #5
    Registered User
    Join Date
    09-11-2015
    Location
    United States
    MS-Off Ver
    2007/2010
    Posts
    8

    Re: Merging non-unique entries into a single unique entry

    @Craig K.

    Thank you! The pivot table worked perfectly. I will mark the thread as solved.

    I do, however, have a related question for which I would appreciate your help. I can make a new thread if needed.

    I have other variables that are not simply encoded as "0" or "1". How would you change the Value Field Settings to Summarize:

    Insurance: "Y" or "N" so that "Y" is the overriding value? Or so that some third value "P" is reported? (In cases of discordant entries)
    Race: "W" or "U" or "B" or "HW" so that "U" is replaced by the other values. (In cases of discordant entries)


    Thanks for your help! I'm sure I will have more questions

  6. #6
    Valued Forum Contributor
    Join Date
    10-10-2012
    Location
    New York
    MS-Off Ver
    Excel 2007/2010
    Posts
    337

    Re: Merging non-unique entries into a single unique entry

    The solution I gave using the pivot table was under the assumption that you were just consolidating numeric binary values. Pivot tables are used to summarize numeric values, and that's why it worked in this case. You could technically create workarounds with the solution I provided by changing text values to number values and back again, but you would be better off looking into the solution from the other thread that newdoverman linked to.

  7. #7
    Registered User
    Join Date
    09-11-2015
    Location
    United States
    MS-Off Ver
    2007/2010
    Posts
    8

    Re: Merging non-unique entries into a single unique entry

    Thanks. For now I will most likely pursue workarounds by converting text to number and back again. I have no knowledge of Excel VBA, but I may have to learn about it in the future.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 01-29-2015, 04:08 PM
  2. [SOLVED] Count unique entries based off unique criteria in another column
    By hambly in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 06-11-2014, 03:33 PM
  3. Help merging duplicate entries with unique information
    By wizelsnarf in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-12-2014, 03:02 PM
  4. Replies: 5
    Last Post: 11-09-2013, 09:15 PM
  5. Replies: 7
    Last Post: 05-11-2012, 02:00 PM
  6. Merging multiple rows and column data for each unique ID into single row
    By skilaru in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-22-2012, 11:59 AM
  7. # of unique dates per unique list entry
    By MrNovice in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-27-2009, 07:01 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1