+ Reply to Thread
Results 1 to 13 of 13

Duplicate values to return unique value

Hybrid View

  1. #1
    Registered User
    Join Date
    03-24-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Arrow Duplicate values to return unique value

    Hi everyone,

    I have been pulling my hair over this for almost 2 months now and hoping you can help me out.

    I'm essentially trying to find the

    Column A contains the code ID and Column B has the product. The rows would often contain the same code ID but the product may be the same with the odd one that may appear. I would then like to say if code ID contains multiple "Apples" and a single "Melon" - I would like Column C to sayBook1.xlsx Melon for that code ID.

    I have tried looking at countifs however can't seem to determine as to how I should be approaching this. The data is static and I would require excel formula for this.

    Any help or suggestions you can provide would be super appreciated and can get me a good night sleep

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: Duplicate values to return unique value

    Hello,
    here's a suggestion using helper columns :
    Attached Files Attached Files
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: Duplicate values to return unique value

    attach your sample file with some more example and show your expected result by entering manually
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  4. #4
    Registered User
    Join Date
    03-24-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Duplicate values to return unique value

    HELP.xlsxHi Siva,

    Thank you for your time to assist with my enquiry. I have attached another example with more information of what I'm after.

    Unfortunately with the amount of data I will need to work with Excel formula.

    Any help or suggestion you can provide will be very much appreciated.

    Many thanks

  5. #5
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: Duplicate values to return unique value

    Hello,
    Did you look at the suggestion I made?
    Here's your new file with the helper columns...

    (note that the identifiers are all different in your file except rows 15 and 16... was it an error ?)
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    03-24-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Duplicate values to return unique value

    Hi,

    Thank you for your suggestion regarding helper columns. Sorry I must have not explained my expected result well and the suggestion you've provided isn't what I was after. I really appreciate your help though

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,862

    Re: Duplicate values to return unique value

    In you file "Help" all the identifiers are different except for the last 2: This is "obviously" a mistake ? so we should assume all the identifiers in the coloured bands are the same. ??

  8. #8
    Registered User
    Join Date
    03-24-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Duplicate values to return unique value

    Updated HELP.xlsxHi yes sorry that was a mistake.
    I've attached a revised spreadsheet. Sorry to be confusing about this, its hard to explain what I wanted so I thought I would show via spreadsheet and expected results. Again really appreciate your time helping me out.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,862

    Re: Duplicate values to return unique value

    Try


    =IF(COUNTIF($B$2:B3,B3)=COUNTIF($B$2:$B$16,B3),IF(COUNTIFS($B$2:$B$16,B3,A$2:A$16,"Email Referral"),"Email Referral","Phone Referral"),"")

  10. #10
    Registered User
    Join Date
    03-24-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: Duplicate values to return unique value

    Updated HELP.xlsxHi, that is very close to what I wanted. Although it doesn't seem to produce the expected results?
    Would really appreciate if you could have a look at column E.

    Also if its not too much trouble I would love to learn how your formula works.

  11. #11
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,862

    Re: Duplicate values to return unique value

    Yes it does: the formula in D2 was wrong because I posted the formula for D3 by mistake!


    In D2

    =IF(COUNTIF($B$2:B2,B2)=COUNTIF($B$2:$B$16,B2),IF(COUNTIFS($B$2:$B$16,B2,A$2:A$16,"Email Referral"),"Email Referral","Phone Referral"),"")


    P.S Is it necessary for the "Email Referral" to in the row which as "Email Referral" rather then the last entry for a given identifier??
    Last edited by JohnTopley; 01-10-2016 at 08:15 AM.

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,862

    Re: Duplicate values to return unique value

    How the formula works:

    =IF(COUNTIF($B$2:B2,B2)=COUNTIF($B$2:$B$16,B2),IF(COUNTIFS($B$2:$B$16,B2,A$2:A$16,"Email Referral"),"Email Referral","Phone Referral"),"")

    IF(COUNTIF($B$2:B2,B2)=COUNTIF($B$2:$B$16,B2),

    This checks for the last entry (row) for a given identifier. The first COUNTIFS counts the number of a given identifier as you drag down the rows: note the range $b$2:b2 which changes to $b$2:b3 in row 3, $b$2:b4 in row 4 etc. The second COUNTIFS counts total number of a given identifier in the whole range,

    When they are equal i.e. we have found the last row for a given identifier , I simple check if there is an "Email Referral" - COUNTIFS($B$2:$B$16,B2,A$2:A$16,"Email Referral") for this identifier. if YES , then this the "default" you want, so assign "Email Referral": otherwise assign "Phone Referral".

    COUNTIFS($B$2:$B$16,B2,A$2:A$16,"Email Referral") is equivalent to COUNTIFS($B$2:$B$16,B2,A$2:A$16,"Email Referral")>=1. If you a get results >=1, this is TRUE, a result of 0 is FALSE (in the IF statement: =IF ( formula, TRUE result, FALSE result)

    Where the first COUNTIFS do not match, the result is Null ("") or could be blank * ").

    Hope this explains how it works.
    Last edited by JohnTopley; 01-10-2016 at 07:36 AM.

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,862

    Re: Duplicate values to return unique value

    Modified the formula to present data as per your example.

    =IF(COUNTIFS($B$2:$B$16,B2,A$2:A$16,"Email Referral")>=1,IF(A2="Email Referral","Email Referral",""),IF(COUNTIF($B$2:B2,B2)=COUNTIF
    ($B$2:$B$16,B2),"Phone Referral",""))

    or

    =IF(COUNTIFS($B$2:$B$16,B2,A$2:A$16,"Email Referral"),IF(A2="Email Referral","Email Referral",""),IF(COUNTIF($B$2:B2,B2)=COUNTIF($B$2:$B$16,B2),"Phone Referral",""))

    The basic logic is I described previously so hopefully you will understand the change.

    Formula checks if there is an "Email Referral" and if yes, assigns this in appropriate row. If there is no "email" but more than one "phone" it assigns "Phone Referral" to last entry.
    Last edited by JohnTopley; 01-10-2016 at 08:15 AM.

+ 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. [SOLVED] Using INDEX MATCH to return unique values for non-unique search term
    By rico_suave in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 06-03-2015, 01:53 AM
  2. [SOLVED] Find count of Unique or Duplicate Values based on Concatenated values in 2 columns
    By bdicarlo1 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-03-2014, 12:42 AM
  3. [SOLVED] Golf Scoring but have duplicate scores - need to return unique name
    By nunmakr in forum Excel General
    Replies: 11
    Last Post: 07-29-2014, 09:38 AM
  4. [SOLVED] Finding Sum of Unique Values for Duplicate Values
    By LegoLand in forum Excel General
    Replies: 13
    Last Post: 03-21-2014, 06:49 PM
  5. [SOLVED] How to turn duplicate values into unique values
    By dco223 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-19-2013, 01:21 AM
  6. [SOLVED] Delete duplicate values and mantening unique values
    By ronald coletto in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-22-2013, 02:19 PM
  7. Handling duplicate values into unique and sum their next column values
    By No_feelings in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-26-2012, 05:12 PM

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