+ Reply to Thread
Results 1 to 14 of 14

Vector lookup with 2 criteria

  1. #1
    Registered User
    Join Date
    11-09-2009
    Location
    Williamston, NC
    MS-Off Ver
    Excel 2003
    Posts
    14

    Vector lookup with 2 criteria

    I am looking up values L, M, and S from a seperate worksheet based on two factors. age in months, and gender. I have read enough to figure out how to lookup values L,M,S one at a time using a vectorlookup, from one worksheet to another. However, the LMS values being looked up are for females only. I know I must get the gender codes worked in but not sure how to work this in.
    I don't know if I need an and If function, to meet the gender (1male, 2 female) or what.

    I am attaching a small example. If anyone could assist, I would appreciate.
    Attached Files Attached Files
    Last edited by Tim Hardison; 11-10-2009 at 01:22 PM.

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

    Re: how to use a vector lookup with 2 criteria

    Yes, an IF would work ... though really only practical if the ranges are fixed:

    Please Login or Register  to view this content.
    If not there are other less-efficient routes to cater for dynamic ranges but the above should be pretty efficient if resizing dynamically is not an issue.

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Vector lookup with 2 criteria

    Try in K2:

    =SUMPRODUCT(--('LMS for BMI'!$B$2:$B$219=$H2),--('LMS for BMI'!$A$2:$A$219=$I2),'LMS for BMI'!C$2:C$219)

    and copy down and across to column M.

    Note: The values in columm I should be entered as numbers, not text... just retype the 1's and 2's without apostrophes to replace them.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Registered User
    Join Date
    11-09-2009
    Location
    Williamston, NC
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Vector lookup with 2 criteria

    The ranges are fixed for now. I am limiting this between ages 10 and 19, since I am working with adolescents. The CDC table actually run between 2 and 20 years. If I can get this working, I can go back and include the entire age range.

    Let me try pasting the code in my real worksheet. Thanks.

  5. #5
    Registered User
    Join Date
    11-09-2009
    Location
    Williamston, NC
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Vector lookup with 2 criteria

    It is still pulling the same exact L value for two kids at 161.5 months, one male and one female. The L value should be different due to gender.

  6. #6
    Registered User
    Join Date
    11-09-2009
    Location
    Williamston, NC
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Vector lookup with 2 criteria

    I tried the =sumproduct code from NBVC in K2 and it diplayed .00000000000

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Vector lookup with 2 criteria

    Try it like this:

    =SUMPRODUCT(--('LMS for BMI'!$B$2:$B$219=$H2),--('LMS for BMI'!$A$2:$A$219=$I2+0),'LMS for BMI'!C$2:C$219)

  8. #8
    Registered User
    Join Date
    11-09-2009
    Location
    Williamston, NC
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Vector lookup with 2 criteria

    Thanks NBVC, it works. I am elated. I have one final thing a forumla to compute the Z score in the worksheet example.

    I think I got it write, because I checked it against a website that has a z score calulator, but if you could look at the forumula I wrote, I would appreciate it.


    I am attaching a seperate sheet of the Z-score calculation.
    Attached Files Attached Files

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Vector lookup with 2 criteria

    If you are following this equation: Z= ((BMI/M)^L-1)/(LS), then yes, I think you have it right...

  10. #10
    Registered User
    Join Date
    11-09-2009
    Location
    Williamston, NC
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Vector lookup with 2 criteria

    Something isn't computing right. My z-scores should be ranging from -3 to +3, and most are centering around -0.02 to 0.03. Let me check my formula from the CDC website.

  11. #11
    Registered User
    Join Date
    11-09-2009
    Location
    Williamston, NC
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Vector lookup with 2 criteria

    I copied and pasted directly from the CDC page on computing Z-Score.

    To obtain the z-score (Z) and corresponding percentile for a given measurement (X), use the following equation:

    ((X/M)**L) - 1
    Z = -------------------------, Lš0
    LS

    Where X is BMI Which is J2
    M is the median which is L2
    L is the BoxCox Transformation factor K2
    S is the Standard Deviation which is S2.

    I know I should be getting a wider range of zscores since 60% of these kids will be overweight or obese.

    If you could check this one more time, I would appreciate it. From Original Sample

    Tim

  12. #12
    Registered User
    Join Date
    11-09-2009
    Location
    Williamston, NC
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Vector lookup with 2 criteria

    I remember I had to put parentheses in the denominator and it works. Thanks, I am through.

    Tim

  13. #13
    Registered User
    Join Date
    10-15-2016
    Location
    Kirkland, WA
    MS-Off Ver
    Pro 2013
    Posts
    1

    Re: Vector lookup with 2 criteria

    Hello.

    I'm a new member, and I have a question about the proposed solution involving IF(Gender=1 [Column I], LOOKUP X, LOOKUP Y). I appreciate the suggestions because I'm dealing with some large sheets that I have to do embedded Lookups in, and I can't get the lookups to sort for criteria properly if you put a gun to my head!

    In the example, the vectors in both the "Value if True" and the "Value if False" Segments of the IF Formula have to be reduced to 1/2 of the actual columns, which are B[LastName] and C[FirstName].

    That is, the writer says that in the first Lookup, you would only search through B1 to B110/C1 to C110; and in the second Lookup, you would only search through B111 to B119/C111 to C119.

    Obviously, this would require sorting by Male and Female binary values in Column I; but my real question is whether this means the solution is *only* viable if you can do such binary sorting on the IF value, e.g., Gender in this case?

    For instance, if column I weren't gender, and it were something with 10 or 20 different values, like individual purchase prices, would I be able to use an IF(value, LOOKUP1, LOOKUP2) formula to select them?

    Also, what if there were more than 2 values to search?

    Thanks much if anyone can help,

    S

  14. #14
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: Vector lookup with 2 criteria

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    Ben Van Johnson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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