+ Reply to Thread
Results 1 to 9 of 9

Vlookup multiple criteria return unique values

  1. #1
    Registered User
    Join Date
    11-04-2020
    Location
    Bruksel
    MS-Off Ver
    2016
    Posts
    5

    Vlookup multiple criteria return unique values

    Hello,

    I am new in the forum and I am looking for a quick help. I have huge data with several vlookup data which is ok but in one of the worksheets, i have repetitions which causes mistake when use vlookup. Please see the sample file. In the first page, I have ID, Country and Product and second page code, Country, approval and Product. I would like to return ID from first page. However, since I have several codes (lines) for some country/product combination Vlook up did not work. I would like to have unique ID from first page only once for the same country / product combination. If it can put the unique id in E column against approval (approved) and leave the other lines blank, that would be great. Many thanks for your support.
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,860

    Re: Vlookup multiple criteria return unique values

    If what you are looking to do is below then...

    Excel 2016 (Windows) 32 bit
    G
    H
    I
    J
    K
    4
    Table3.Code Country Product Table3.approval ID
    5
    X Morocco A N/A
    1
    6
    Y Morocco A approved
    1
    7
    Z Morocco A N/A
    1
    8
    P Germany B approved
    2
    9
    I Israel D approved
    3
    10
    L Morocco F approved
    4
    11
    K Algeria A N/A
    5
    12
    ZZ Italy F N/A
    6
    13
    W Egypt B N/A
    7
    14
    R Senegal G N/A
    8
    15
    U Algeria H approved
    9
    16
    P Algeria H N/A
    9
    17
    O Morocco H N/A
    10
    18
    T Germany B N/A
    2
    Sheet: Result

    ...here is the Mcode for a Power Query solution. Joining the two tables in an outer join.

    Please Login or Register  to view this content.
    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    11-04-2020
    Location
    Bruksel
    MS-Off Ver
    2016
    Posts
    5

    Re: Vlookup multiple criteria return unique values

    Hi,

    Thanks for quick response. However, what I am looking is to get unique id (1 just one time for Morocco and Product A and the rest should be blank in K column. If the unique id, 1 against 'approved' that would be great (like below);

    Table3.Code Country Product Table3.approval ID
    X Morocco A N/A
    Y Morocco A approved 1
    Z Morocco A N/A

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Vlookup multiple criteria return unique values

    Use this:

    =IF(D5="Approved",INDEX(sample!$A$4:$A$13,INDEX(MATCH(1,((sample!$B$4:$B$13=B5)*(sample!$C$4:$C$13=Result!C5)),0),0)),"")

    In Belgium, you will probably need ; as the separator
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Registered User
    Join Date
    11-04-2020
    Location
    Bruksel
    MS-Off Ver
    2016
    Posts
    5

    Re: Vlookup multiple criteria return unique values

    Super, it worked with I was looking for but I tried it for different set of data, it is not working. I know sometimes simple things are making big difference. What is the trick here to be careful? I even checked the format of the cells from which I am getting data. I even copy/paste the data to sample file to make sure that I am not doing mistake but it did not work. It worked when I make manual entries. I have 10000 lines. Unfortunately, I cannot share the data and I know my explanation is not sufficient but if you have and idea, please comment.
    Many Thanks

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,860

    Re: Vlookup multiple criteria return unique values

    If I am understanding your request then

    Excel 2016 (Windows) 32 bit
    G
    H
    I
    J
    K
    4
    Table3.Code Country Product Table3.approval id.1
    5
    X Morocco A N/A
    6
    Y Morocco A approved
    1
    7
    Z Morocco A N/A
    8
    P Germany B approved
    2
    9
    I Israel D approved
    3
    10
    L Morocco F approved
    4
    11
    K Algeria A N/A
    12
    ZZ Italy F N/A
    13
    W Egypt B N/A
    14
    R Senegal G N/A
    15
    U Algeria H approved
    9
    16
    P Algeria H N/A
    17
    O Morocco H N/A
    18
    T Germany B N/A
    Sheet: Result

    and the Mcode would be

    Please Login or Register  to view this content.

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Vlookup multiple criteria return unique values

    As you say... I cannit comment on what I cannot see. Check for stray spaces in your data. That's a common problem.

  8. #8
    Registered User
    Join Date
    11-04-2020
    Location
    Bruksel
    MS-Off Ver
    2016
    Posts
    5

    Re: Vlookup multiple criteria return unique values

    Thanks to both! The formula worked!

  9. #9
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Vlookup multiple criteria return unique values

    You're welcome.



    If that takes care of your original question, please select "Thread Tools" from the menu link above and mark this thread as SOLVED.

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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. Vlookup two criteria and return multiple values
    By jenbonavita in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-28-2020, 04:17 PM
  2. Replies: 5
    Last Post: 05-27-2019, 03:46 PM
  3. [SOLVED] Vlookup 2 criteria and return multiple values
    By Sasquatch2014 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-29-2017, 12:49 PM
  4. Replies: 8
    Last Post: 05-08-2017, 09:17 PM
  5. [SOLVED] Help return multiple unique values in a row. VLOOKUP?
    By Royser12345 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-22-2016, 04:58 AM
  6. Select multiple criteria based on check box selection and return all unique values.
    By TommyToe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-21-2013, 09:14 AM
  7. [SOLVED] VLOOKUP or something with multiple unique return values in a list?
    By girt0n in forum Excel General
    Replies: 1
    Last Post: 04-17-2012, 12:41 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