+ Reply to Thread
Results 1 to 6 of 6

Help with table lookup using array functions

Hybrid View

  1. #1
    Registered User
    Join Date
    02-27-2007
    Posts
    38

    Help with table lookup using array functions

    I was hoping someone could take a look at the attached workbook and let me know what I'm doing wrong.

    I'm trying to do a lookup on a table where a row is matched by doing a logical test on each column. The row I want is the one that tests true for all columns.

    I'm using the match function and array functions to do the test.

    Thanks for any help you can provide.

    Dave
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    There should be an easier way but this does the trick
    =SUMPRODUCT((A2:A33=J5)*(B2:B33="x")*(C2:C33<J7)*(D2:D33>J7)*(E2:E33<J8)*(F2:F33>J8)*G2:G33)
    be aware it will sum all values in G2:G33 where conditions are met

  3. #3
    Registered User
    Join Date
    02-27-2007
    Posts
    38
    Thanks, that looks like it works.

    I can add in checks to make sure I'm matching exactly one row by just summing the tests without the values.

    e.g.

    =SUMPRODUCT((A2:A33=J5)*(B2:B33=J6)*(C2:C33<J7)*(D2:D33>J7)*(E2:E33<J8)*(F2:F33>J8))


    Just for educational purposes ... was my attempt just a completely inappropriate use of a cntrl-shift-enter formula, or is there a change to it that would make it work using the index and match functions?

    Thanks!

    Dave

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Help with table lookup using array functions

    Alternative Approach:
    Perhaps the DGET function would be appropriate here....
    (I attached a workbook that demonstrates)

    Note the structure of the AgeTest and DateTest criteria.
    • The title CANNOT match a table heading
    • The formulas refer to the first DATA ROW only.
    (The function will increment each row internally)

    Example: AgeTest
    This formula checks if the $J$7 age is within the C2:D2 range:
    =($J$7>=C2)*($J$7<=D2)

    EDITED TO INCLUDE THIS COMMENT:
    If more than one record matches the criteria...DGET returns #NUM!
    In that case....use DSUM (same structure)


    Does that help?
    Attached Files Attached Files
    Last edited by Ron Coderre; 12-04-2008 at 02:30 PM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320
    you needed to match 1 not 0 and include 0 at the end still an array
    =INDEX(G2:G33,MATCH(1,((A2:A33=J5)*(B2:B33=J6)*(C2:C33<=J7)*(D2:D33>=J7)*(E2:E33<=J8)*(F2:F33>=J8)),0))
    Last edited by martindwilson; 12-04-2008 at 02:55 PM.

  6. #6
    Registered User
    Join Date
    02-27-2007
    Posts
    38
    Thank you all. This is great.

    Problem solved and I learned about a function that I've never tried before (DGET).

    Very cool.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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