+ Reply to Thread
Results 1 to 17 of 17

How to Retun Only One Match from Two Tables

  1. #1
    Registered User
    Join Date
    02-19-2024
    Location
    Dublin
    MS-Off Ver
    2016
    Posts
    31

    How to Retun Only One Match from Two Tables

    Hi

    I have Table A and Table B in the attached spreadsheet, and I would like to return the unique values of Table A over to Table B under BAS column.

    Table B has multiple instances of same employee id, whereas Table A has unique instances of employee id.

    Thanks for your help in advance.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,673

    Re: How to Retun Only One Match from Two Tables

    Are you still using Excel 2016?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,673

    Re: How to Retun Only One Match from Two Tables

    Is this what you want?

    In I4 copied down:

    =INDEX($D$4:$D$12,MATCH(F4,$A$4:$A$12,0))

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,309

    Re: How to Retun Only One Match from Two Tables

    With 2016, one option is this, copied down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    If you have upgraded, there will be other options.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    02-19-2024
    Location
    Dublin
    MS-Off Ver
    2016
    Posts
    31

    Re: How to Retun Only One Match from Two Tables

    Yes, unfortunately, I work for a charity, so no money for an upgrade.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,673

    Re: How to Retun Only One Match from Two Tables

    See post #3.

  7. #7
    Registered User
    Join Date
    02-19-2024
    Location
    Dublin
    MS-Off Ver
    2016
    Posts
    31

    Re: How to Retun Only One Match from Two Tables

    For each employee id in Table B, I only need to have the result of Table A returned once, only. This formula, like VLOOKUP, return the result for every instance of employee id in Table B, where I want same result brought over only once.

  8. #8
    Registered User
    Join Date
    02-19-2024
    Location
    Dublin
    MS-Off Ver
    2016
    Posts
    31

    Re: How to Retun Only One Match from Two Tables

    See my reply below.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,673

    Re: How to Retun Only One Match from Two Tables

    In I4 copied down:

    =IF(COUNTIF(F$4:F4,F4)=1,INDEX($D$4:$D$12,MATCH(F4,$A$4:$A$12,0)),"")

  10. #10
    Registered User
    Join Date
    02-19-2024
    Location
    Dublin
    MS-Off Ver
    2016
    Posts
    31

    Re: How to Retun Only One Match from Two Tables

    That did it, thanks!
    Last edited by AliGW; 04-02-2025 at 11:55 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead. Please review the forum guidelines.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,673

    Re: How to Retun Only One Match from Two Tables

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED. You can also access the SOLVED tag by editing the opening post and choosing SOLVED from the drop-down to the left of the title box.

    Also, if you have not already done so, remember that you can reward anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.

  12. #12
    Registered User
    Join Date
    02-19-2024
    Location
    Dublin
    MS-Off Ver
    2016
    Posts
    31

    Re: How to Retun Only One Match from Two Tables

    May I ask you to expound the COUNTIF in the formula, please. I think I understand what it does, but if you can explain, please...

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,673

    Re: How to Retun Only One Match from Two Tables

    Put this into J4 and copy it down:

    =COUNTIF(F$4:F4,F4)

    From the results it gives and the changes that happen to the formula as you drag down, you will be able to work it out.

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,309

    Re: How to Retun Only One Match from Two Tables

    COUNTIF(F$4:F4,F4)=1

    Notice that the first reference row is fixed (absolute). So, the first occurrence will be COUNTIF(F4:F4,F4)=1 which will be TRUE.

    The next occurrence will be COUNTIF(F4:F5,F5)=1 which will be FALSE. And so it will continue: F4:F6,F6; F4:F7,F7; F4:F8,F8.

  15. #15
    Registered User
    Join Date
    02-19-2024
    Location
    Dublin
    MS-Off Ver
    2016
    Posts
    31

    Re: How to Retun Only One Match from Two Tables

    Quote Originally Posted by TMS View Post
    COUNTIF(F$4:F4,F4)=1

    Notice that the first reference row is fixed (absolute). So, the first occurrence will be COUNTIF(F4:F4,F4)=1 which will be TRUE.

    The next occurrence will be COUNTIF(F4:F5,F5)=1 which will be FALSE. And so it will continue: F4:F6,F6; F4:F7,F7; F4:F8,F8.
    So, does =1 mean that in case of multiple instances of same employee id, count same only once when it first appears and discard any following repeated instance?

  16. #16
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,309

    Re: How to Retun Only One Match from Two Tables

    In the first instance of the formula, the COUNTIF will return 1. So, 1=1 which is TRUE, and the IF returns the TRUE result which is the VLOOKUP. For subsequent instances, the COUNTIF will increase and return a value greater than 1. So then the IF will return the FALSE result which is the null value.

    As Ali has suggested put the COUNTIF formula in a cell and drag it down to see what results you get.

  17. #17
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,309

    Re: How to Retun Only One Match from Two Tables

    See the updated sample workbook.
    Attached Files Attached Files

+ 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: 4
    Last Post: 07-13-2022, 08:08 AM
  2. [SOLVED] Match First 2 columns of 2 tables, if match return data from 3rd Column
    By ManateeProfanity in forum Excel General
    Replies: 5
    Last Post: 06-27-2021, 12:14 AM
  3. [SOLVED] vlookup retun blank help
    By MRozell in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-28-2017, 10:10 AM
  4. Retun value for last active quarter only. *Help Please*
    By spraymucus in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-20-2014, 12:37 PM
  5. Index Match Match Formula DOESN'T WORK WITH TABLES/TABLE NAMES ??
    By Underling in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-04-2014, 09:01 PM
  6. Vlookup or other tools to retun more than 1 match from 2 criteria
    By ggiorelli in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 03-17-2013, 06:23 PM
  7. How do I create a formula to retun a value of 0 (zero) when a VLO.
    By Adam at GTOFL in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-20-2005, 03:06 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