+ Reply to Thread
Results 1 to 7 of 7

More than Multiple Lookups: Conditional Multiple Lookups

  1. #1
    Forum Contributor
    Join Date
    12-02-2008
    Location
    India
    Posts
    118

    More than Multiple Lookups: Conditional Multiple Lookups

    Hey all!
    Thanks to this forum i've somewhat understood lookup function a bit, but the more i try to get out of it, the more there seems scope to improve!

    So my question:
    I've learnt that i can lookup with multiple criteria using this function:
    =lookup(2,1/((criteria1)*(criteria2)*...*(criteria_n)),(result vector))

    However, now i'm trying to lookup from another matrix which has a conditional criteria added to it....

    So presently i'm working on it like this:
    =If(Test=CriteriaA,lookup(2,1/((criteria1)*(criteria2)),Result Vector1),IF(Test=CriteriaB,lookup(2,1/((criteria1)*(criteria2)),Result Vector2),0)

    I dunno if its still vague as usually i am so i'll add a sample:
    I'm just looking to do this in some shorter way because the formula on this one's getting too big....
    Basically based on Criteria A,B and C (or mebbe more), the result vector arrays are changed....

    Regards
    Mohit
    Attached Files Attached Files

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: More than Multiple Lookups: Conditional Multiple Lookups

    you could try this
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Contributor
    Join Date
    12-02-2008
    Location
    India
    Posts
    118

    Re: More than Multiple Lookups: Conditional Multiple Lookups

    Hey thanx for that awesome tip!
    The index match function definitely seems to be a better way forward than my nested if lookup...

    ....so i guess its good to always go forward with an Index Match Function whenever we have a matrix to lookup to...?

    Regards
    Mohit

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: More than Multiple Lookups: Conditional Multiple Lookups

    Curious... it's not really clear how the INDEX/MATCH approach will differ from your embedded IF & LOOKUP approach when you have different numbers of criteria to concatenate ?

    The use of the embedded INDEX to negate need for Array will prove no more efficient than the LOOKUP(2,1/(....)) approach - neither in truth are great performers...
    some would argue that when used against larger data sets an Array will perform no worse and in some instances will perform better... to illustrate in terms of INDEX usage ...

    =SUMPRODUCT(--(A1:A1000="a"),--(B1:B1000="b"),C1:C1000)

    and

    =SUM(IF((A1:A1000="a")*(B1:B1000="b"),C1:C1000))
    CSE

    are still used in preference to INDEX even though we can (errors permitting) perform the same with:

    =SUM(INDEX((A1:A1000="a")*(B1:B1000="b")*C1:C1000,0))

    why ? Well because INDEX is quite slow... amplified with big datasets.

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: More than Multiple Lookups: Conditional Multiple Lookups

    it also looks good but
    Please Login or Register  to view this content.
    would also
    give same return for
    Please Login or Register  to view this content.
    depends on what data you are using
    having said that i was thinking of going down the sumproduct route
    Last edited by martindwilson; 10-31-2009 at 09:01 PM.

  6. #6
    Forum Contributor
    Join Date
    12-02-2008
    Location
    India
    Posts
    118

    Re: More than Multiple Lookups: Conditional Multiple Lookups

    Hey!
    How would sumproduct help in this case?

    Also, can u give me a link or something that explains the use of "double hyphen" in a sumproduct function... i see it being used alot around by the learned ones and even using formula evaluation i dont get anything! :P

    Regards

    Mohit

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: More than Multiple Lookups: Conditional Multiple Lookups

    I confess I did not actually look at your file at any point and the point I was making about SUMPRODUCT was really just to illustrate the fact that using INDEX to circumvent need for Arrays is only practical so far
    (ie we use SUMPRODUCT and Arrays in preference to using an embedded INDEX for a reason).

    All that being said, having now looked at your file... yes it would appear that SUMPRODUCT would satisfy requirements in form of either:

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    In terms of how SUMPRODUCT works, coercion (and use of double unary (--)) I would point you to the SUMPRODUCT link in my sig. - Bob Phillips' white paper on the topic.

    In terms of alternatives to the above - the same principles could be applied to LOOKUP

    Please Login or Register  to view this content.
    the above, unlike SUMPRODUCT, will work if the result_vector is populated with text as opposed to numerics but unlike SUMPRODUCT would not aggregate numerical results should multiple records exist for any given combination
    (ie think of SUMPRODUCT as an aggregation function whereas LOOKUP is singular)

    Generally speaking however...

    The downside to both SUMPRODUCT & LOOKUP(2,1/(...)) based approaches is that they are not particularly efficient... in these cases for users pre XL2007 (ie SUMIFS not viable) my advice is always to add a concatenation INDEX at source, eg:

    Please Login or Register  to view this content.
    You can then, courtesy of that simple concatenation, dispense with the need for SUMPRODUCT and/or LOOKUP altogether, eg

    to replace SUMPRODUCT with far more efficient SUMIF
    Please Login or Register  to view this content.
    to replace LOOKUP(2,1/(...)) with more efficient INDEX/MATCH
    Please Login or Register  to view this content.
    and again to iterate both approaches are valid depending on the nature of your return range be it numeric / non-numeric and if numeric depending on whether multiple records require aggregation or not.
    Last edited by DonkeyOte; 11-01-2009 at 03:34 AM.

+ 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