+ Reply to Thread
Results 1 to 8 of 8

Vlookup on multiple axis with multiple criteria

  1. #1
    Registered User
    Join Date
    11-07-2009
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    6

    Vlookup on multiple axis with multiple criteria

    multiple_lookup.xlsxPlease view my attached Excel workbook.

    It has 2 sheets. Sheet 1 is named "Calculator" and takes 3 fields as input: B1, B2, and B3, and then should place an answer in B4.

    The data to be looked up is in Sheet 2 named "Data".

    If I enter search criteria of "John", "2008", and "2" - I want B4 to tell me "High Jump" i.e. I want to get back the nameof the event which matches the event score specified for a given person and a given year.

    Hope my trivial example makes sense. I've done things before with VLOOKUP and MATCH, but I can't get my head around how I would do this one.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Vlookup on multiple axis with multiple criteria

    try the calculator...
    Attached Files Attached Files

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

    Re: Vlookup on multiple axis with multiple criteria

    In the event that you have duplicate scores in the same year for the same person the only way I know to capture

    all events is to use an array formula over multiple cells. If you don't have duplicates this still works.

    Array enter this formula in B4 of the Calculator sheet. To commit an array formula press Ctrl + Shift + Enter.

    Fill down to B7. You will know it has been entered correctly when you see the formula enclosed in { } curly braces.

    You don't type those in yourself. Excel does it for you.

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

    I put duplicate scores into the data sheet to demonstrate. The file is attached.

    Hope this helps.
    Last edited by FlameRetired; 01-08-2015 at 11:01 PM. Reason: new formula

  4. #4
    Registered User
    Join Date
    11-07-2009
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Vlookup on multiple axis with multiple criteria

    Hi FlameRetired,

    Thank you for taking the time to reply. I have inspected your attached spreadsheet and it is working perfectly.

    I am, however, struggling to understand the formula - probably due to length of formula and my inability to mentally parse all of the brackets! Would you mind explaining the algorithm and the formulas used?

    I would like to modify the layout of the Calculator sheet such that there can be multiple rows - each representing a seprate "query" of Name, Year, and Score - in columns B, C and D, respectively. The result should be generated in column E of the same row. Note: I would like to ignore the possibility of multiple results for a given score and only display the first result.

    match2.xlsx

    Please see my attached spreadsheet. I have attempted to adjust the layout of the calculator tab as described above - but column E calculates incorrectly when I copy the formula over verbatim. I suspect this is due to the ROWS($1:1) part, but I don't understand the full formula you have posted so I am not sure on how to adjust it.

  5. #5
    Registered User
    Join Date
    11-07-2009
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Vlookup on multiple axis with multiple criteria

    So I understand that the common way to find a value based on a x-axis 'key' and a y-axis 'key' is to do something like this:

    =INDEX(B3:D6,MATCH(A1,$A$3:$A$6,0),MATCH(B1,Data!$B$2:$D$2,0))

    This is based on B3:D6 being data, A3:A6 being x-axis labels, B2:D2 being y-axis labels, A1 being the x-axis "name" to search for, and B1 being the y-axis "name" to search for.

    This will correctly return the value from the corresponding data column.

    What I don't understand is how to deal with the complication of actually wanting to check to see if the data value matches a given value and then return a second label from the x-axis... I see that you've used SMALL, IF, ROW, ROWS, and MIN functions but I can't get my head around the algorithm.

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

    Re: Vlookup on multiple axis with multiple criteria

    Withdrawn by FR.
    Last edited by FlameRetired; 01-11-2015 at 01:46 AM. Reason: errors in explanation

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

    Re: Vlookup on multiple axis with multiple criteria

    Quote Originally Posted by theLOLkid View Post
    ..............What I don't understand is how to deal with the complication of actually wanting to check to see if the data value matches a given value and then return a second label from the x-axis... I see that you've used SMALL, IF, ROW, ROWS, and MIN functions but I can't get my head around the algorithm.
    I'll attempt an explanation of that formula in a follow-up post, but first here is the formula for your second arrangement in post #4. In E1 of Calculator sheet:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Again this is an array formula that must be committed by holding down the Ctrl + Shift keys while you hit Enter. Then in this arrangement fill down and across to H8. You'll notice the ROW($1:$4) part. It replaces the ROW(Data!$A$2:$A$5)-MIN(ROW(Data!$A$2:$A$5))+1 part in the earlier formula. This is something I will attempt to explain in the follow-up.

    The file is attached.

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

    Re: Vlookup on multiple axis with multiple criteria

    Quote Originally Posted by theLOLkid View Post
    ...... I see that you've used SMALL, IF, ROW, ROWS, and MIN functions but I can't get my head around the algorithm.
    Before diving into the SMALL, IF, ROW, ROWS and MIN parts:

    I noticed in post #5 you reference the formula
    =INDEX(B3:D6,MATCH(A1,$A$3:$A$6,0),MATCH(B1,Data!$B$2:$D$2,0))
    with relative cell / range references. In this case B3:D6 must be “anchored” absolutely as $B$3:$D$6 or you will get incorrect results. Perhaps you already knew that but it seemed important I not overlook it.

    For the algorithm refer to the formula in my first upload. To help me parse formulas I rely on selective use of the F9 key quite often. While tedious to use I find it pays enormous dividends. It reveals the hidden “insides” of the formula….what each function is passing to the next function or operator. This explanation relies on that.

    In the formula bar highlight / select the blue part of the formula in cell B4 Calculator sheet and press the F9 key.
    =IFERROR(INDEX(Data!$B$2:$B$5,SMALL(IF(($B$3=INDEX(Data!$C$2:$F$5,0,MATCH(Calculator!$B$2,Data!$C$1:$F$1,0)))*(Calculator!$B$1=Data!$A$2:$A$5),ROW(Data!$A$2:$A$5)-MIN(ROW(Data!$A$2:$A$5))+1),ROWS($1:1))),"")

    You should see {1;1;0;0}. These are the results of the TRUEs / FALSEs generated by coercing those text values into their underlying numeric values of 1s and 0s. IF evaluates each of those and every non-zero gets assigned a position specific index number. That is where the if true ROW(Data!$A$2:$A$5)-MIN(ROW(Data!$A$2:$A$5))+1 part comes into play.

    If you highlight / select that part of the formula in B4 and press the F9 key you should see {1;2;3;4}. I could just as easily reduced the complication here by replacing the ROW/MIN/ROW part with ROW($1:$4) which I did in the upload post #7. The results are the same. The approach I used is a discipline I’ve learned from this forum. There are a rather large number of array formulas worked out in this forum that can start in any row and end in any row. It assures that the row assignments will always start with 1 and extend to the last row no matter what, helps avoid typos and makes formulas easier to debug. The need becomes more apparent when using named ranges. Here we could get away with ROW($1:$4).

    The ROWS($1:1) part is the last argument to the SMALL function that sorts and groups all those resulting assigned index numbers in ascending order. It does this by using the count of the number of rows to designate 1st smallest, 2nd smallest…….. You will notice as you arrow down from B4 to B5 etc. the ROWS values change…..$1:1, $1:2, $1:3 and from the count of the rows assigns each assigned index number its proper place in order. It is these that are then passed to the outermost INDEX function’s first argument …….. INDEX(Data!$B$2:$B$5. Those index number(s) will return the Event(s) in Data!$B$2:$B$5 respective to those row numbers which have been indexed …….. Data!$B$2 being the first row / event in this case.
    BTW: I used COLUMNS($A:A) for this same purpose in the second upload because the resulting presentation is column wise.

    I hope I haven’t made your eyes “glaze over” with this explanation. If you have any more questions about this formula please let us know.
    Last edited by FlameRetired; 01-11-2015 at 02:52 PM.

+ 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 (or index/match) with multiple criteria over multiple sheets
    By Groovicles in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-18-2013, 01:56 PM
  2. [SOLVED] Trying to sum multiple criteria, criteria on the X and the Y axis
    By Happs in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-22-2013, 03:54 AM
  3. vlookup? match? index? MULTIPLE criteria for vlookup search problem....
    By aborg88 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-11-2013, 09:56 AM
  4. Possible VLOOKUP multiple criteria & multiple worksheets
    By this2willpass in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-16-2012, 08:23 AM
  5. Vlookup + multiple criteria + multiple data returned
    By stonesy in forum Excel General
    Replies: 6
    Last Post: 02-17-2010, 08:53 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