+ Reply to Thread
Results 1 to 14 of 14

Return the value of a duplicate

  1. #1
    Registered User
    Join Date
    01-14-2016
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    15

    Return the value of a duplicate

    I have a spreadsheet that shows a location number, merchant ID and tandem ID. Some location numbers are duplicate and can have multiple merchant ID's (which are unique). Tandem ID's are unique to a location number.

    In my spreadsheet, the duplicate location numbers only have a tandem ID for one of the merchant ID's. For example...

    location # merchant ID tandem ID
    12345 55555 AAAA
    12345 66666
    12345 77777

    How can a write a formula to fill out the 'AAAA' tandem Id for all duplicate locations. The logic would be if tandem id is blank and location number is more than one, look in an array of the duplicate location numbers and return the corresponding tandem ID.

    The huge problem is sometimes the location number with the tandem ID may be the first, middle or last of the duplicates, so I can't just say count up one. Is this possible????

    Thanks!!
    Last edited by MDB1; 01-27-2016 at 06:18 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Return the value of a duplicate

    If I understand the request then I'd be inclined to use a helper column

    Assuming your data is in A1:C100 then in D2 enter

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    copy this down your range and then copy the helper column and paste it back to column C as values.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    01-14-2016
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    15

    Re: Return the value of a duplicate

    Thank you. This formula does work but only if the tandem ID correlated with the location number is the first instance. Using my original example, if the tandem ID is instead populated for merchant ID 66666, when the vlookup is run, it will return the tandem ID to only the first instance of location ID, which would be merchant ID 55555, thus blank.

    Any other ideas?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Return the value of a duplicate

    ....in that case assuming I understand you should first create another helper column which concatenates the location & merchant ID and use the formula I gave you on that first helper column. If this does not do what you want please upload a workbook wit a few more examples and permutations and manually add the results you expect to see. Please use real data even if its sensitised to a degree. We often find trivial example data like 12345 AAAAA type stuff does not accurately reflect your real data sufficiently to give you a generalised solution.

  5. #5
    Registered User
    Join Date
    01-14-2016
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    15

    Re: Return the value of a duplicate

    I've attached a file. The first 3 columns are given and the 'expected tandem ID' in column D is the intended result of the vlookup formula. Where the tandem ID is blank and the location number is more than 1, I want to lookup the duplicate or other location number and return the corresponding tandem ID. The merchant ID is the unique identifier where the location number may duplicate up to 5 times.

    Hope this is clear.

    Thanks for any help!
    Attached Files Attached Files

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Return the value of a duplicate

    Perhaps an array formula (entered with Ctrl-Shift-Enter) in D2 copied down

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    01-14-2016
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    15

    Re: Return the value of a duplicate

    I am still having issues with this.

    I've attached another file that may further help with understanding. I need a formula that uses an array a populates what is in column D (Expected result)if there is a duplicate location number that has a tandem ID. If it does not have a duplicate location number the tandem Id should remain blank as in row 11.

    Any help would be greatly appreciated. Thanks!
    Attached Files Attached Files

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Return the value of a duplicate

    Hi,

    If you were to sort your data with column A as the first sort key Ascending and column C as the second Sort key Descending then you could use a trivial VLOOKUP In D2 copied down. e.g.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    with an unsorted list then a more complex formula such as

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    is needed.

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Return the value of a duplicate

    Without sorting, this worked for me (not an array)

    =IF(C2="",INDEX($C$2:$C$100,MATCH(REPT("z",6),INDEX($C$2:$C$100,MATCH(A2,$A$2:$A$100,0)):INDEX($C$2:$C$100,MATCH(A2,$A$2:$A$100)))+MATCH(A2,$A$2:$A$100,0)-1),C2)
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,406

    Re: Return the value of a duplicate

    This also worked for me without sorting. Array-entered
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  11. #11
    Registered User
    Join Date
    01-14-2016
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    15

    Re: Return the value of a duplicate

    Thank you both. Both suggested formulas worked however when I transferred to the real data I found some issues. I guess the generic nature of my example was the issue as suggested by Richard from the beginning.

    I've attached a little more detailed file with a few exceptions that occur as well as placed them in the same column headers in my actual report.

    Hope this is enough to get a good idea.

    Thanks again, you guys were really close!
    Attached Files Attached Files

  12. #12
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,406

    Re: Return the value of a duplicate

    This is the same array formula applied to the latest upload in column O. It returns the expected results indicated at my end.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    How is it working with your live data?

    Edit My formula is very similar to Richard's post #6. I just noticed. My apologies, Richard.
    Attached Files Attached Files
    Last edited by FlameRetired; 01-27-2016 at 05:51 PM.

  13. #13
    Registered User
    Join Date
    01-14-2016
    Location
    Houston, Tx
    MS-Off Ver
    2010
    Posts
    15

    Re: Return the value of a duplicate

    This worked!! Thanks to all!!

  14. #14
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2404
    Posts
    13,406

    Re: Return the value of a duplicate

    You're welcome.

+ 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. If Cells are Duplicate, then Return a Value
    By Ocean Zhang in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-16-2019, 02:56 AM
  2. return true if duplicate
    By Burt_100 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-04-2014, 02:34 PM
  3. Look up one name, return multiple (non-duplicate) results
    By marklub in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-08-2012, 01:51 AM
  4. [SOLVED] return value for duplicate name got wrong value
    By jocer in forum Excel General
    Replies: 6
    Last Post: 08-12-2012, 06:27 AM
  5. [SOLVED] return value for duplicate items (row)
    By jocer in forum Excel General
    Replies: 8
    Last Post: 07-29-2012, 12:38 AM
  6. unable to return duplicate value
    By celticpucca in forum Excel General
    Replies: 13
    Last Post: 02-11-2011, 04:22 AM
  7. Compare duplicate items and return a value
    By tigabalm in forum Excel General
    Replies: 11
    Last Post: 01-25-2010, 05:16 AM

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