+ Reply to Thread
Results 1 to 7 of 7

VLOOKUP an item that has more than one matching value?

  1. #1
    Registered User
    Join Date
    07-05-2018
    Location
    Canada
    MS-Off Ver
    2019
    Posts
    8

    VLOOKUP an item that has more than one matching value?

    What's the best way to lookup a value from one table, that has multiple matching values in another table? Or, perhaps to word it another way, to lookup a value using more than one criteria?

    Let's say I have two tables, ProductSheet and DailyPrices. They look somewhat like this:

    DailyPrices:
    Date SKU Price
    11-Jul-18 SOX $5.25
    11-Jul-18 BLT $2.00
    12-Jul-18 HAT $4.00
    13-Jul-18 SOX $6.00

    ProductSheet:
    SKU Current Price
    SOX =Latest price in price list
    HAT =Latest price in price list
    BLT =Latest price in price list

    How can I lookup the *latest* price of an item in DailyPrices and return it as the current price in ProductSheet? I tried VLOOKUP but I believe what I'm looking to do is too complicated for VLOOKUP. I also tried a table-based query but couldn't get that to return what I needed either. Any suggestions? Thanks in advance!

  2. #2
    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,986

    Re: VLOOKUP an item that has more than one matching value?

    Like this:

    =IFERROR(LOOKUP(2,1/($A$2:$A$14=F2),$B$2:$B$14),"")

    see file.

    File attached this time...
    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

  3. #3
    Registered User
    Join Date
    07-05-2018
    Location
    Canada
    MS-Off Ver
    2019
    Posts
    8

    Re: VLOOKUP an item that has more than one matching value?

    Thanks Glenn for taking time out of your day to help me. My sample was a little simplistic, but I was able to combine what you gave me with a table-based query and get the results I'm looking for. Thank-you!

    That said, could you help me understand how it works? I believe the secret sauce is in this portion:

    =IFERROR(LOOKUP(2,1/($A$2:$A$14=F2),$B$2:$B$14),"")

    That doesn't seem to follow the syntax for LOOKUP() in the online help, any chance you can walk me through what you've done here? Thanks again for helping me solve my problem!

  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,986

    Re: VLOOKUP an item that has more than one matching value?

    ($A$2:$A$14=F2)
    looks for a match for F2 in A2 to A14. It returns TRUE, FALSE,FALSE,TRUE,FALSE,FALSE,FALSE, etc to the end of the range.

    1/($A$2:$A$14=F2)
    returns 1,#DIV/0,1,#DIV/0,#DIV/0,#DIV/0,#DIV/0,etc

    LOOKUP(2
    You're looking for a value = 2. There can never be one. It'll either be 1 or #DIV/0. In this case, LOOKUP will match the last numeric value found in the array, which corresponds to the last instance of a match for SOX... and

    $C$2:$C$10)

    return the corresponding value from C2 to C10.

    The IFERROR bit returns a blank if no match is found.





    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.

  5. #5
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: VLOOKUP an item that has more than one matching value?

    A couple of alternatives that don't rely on the dates being in ascending order.

    Based on the dailyprices data in columns A2:C5, criteria SKU in E2

    All versions of excel from 2007 onwards (this one must be array confirmed with Shift Ctrl Enter).

    =SUMIFS($C$2:$C$5,$B$2:$B$5,$E2,$A$2:$A$5,MAX(IF($B$2:$B$5=$E2,$A$2:$A$5)))

    Office 365 subscription version (untested, I don't have this version at home).

    =SUMIFS($C$2:$C$5,$B$2:$B$5,$E2,$A$2:$A$5,MAXIFS($A$2:$A$5,$B$2:$B$5,$E2))

  6. #6
    Registered User
    Join Date
    07-05-2018
    Location
    Canada
    MS-Off Ver
    2019
    Posts
    8

    Re: VLOOKUP an item that has more than one matching value?

    Wow, that's... a little kludgey. But it works, thanks to everyone for taking the time to help!

  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,986

    Re: VLOOKUP an item that has more than one matching value?

    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. Finding an item that isn't matching.
    By kylpr in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-07-2017, 04:42 PM
  2. [SOLVED] lookup if matching item and between dates
    By Sherk in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-13-2015, 12:04 PM
  3. [SOLVED] Formula needed - line item of unique item matching criteria
    By NS4Excel in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 04-18-2015, 06:32 PM
  4. Excel 2007 : Help matching data based on item number
    By SubtleFudge in forum Excel General
    Replies: 6
    Last Post: 04-10-2012, 04:42 PM
  5. Replies: 5
    Last Post: 07-26-2011, 10:35 PM
  6. Select combobox item using string matching
    By TheFormerAstronomer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2011, 04:27 AM
  7. Replies: 9
    Last Post: 05-21-2011, 12:14 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