+ Reply to Thread
Results 1 to 12 of 12

Using Lookup function in a larger formula

  1. #1
    Registered User
    Join Date
    09-04-2008
    Location
    Cherry Hill, NJ
    MS-Off Ver
    2007
    Posts
    37

    Using Lookup function in a larger formula

    Hello,
    I am currently using the following formula:
    =SUMPRODUCT(('Step 1_Data_Current Qtr'!T2:T10000=B2)*('Step 1_Data_Current Qtr'!C2:C10000<>"")*1)

    ...to count the number of instances in a data set where:

    T2:T10000=B2 is counting records where the value in the cell is set to B2

    and

    C2:C10000<>"" is counting records where the value in the cell is not blank.

    The current formular is working, but I want to change the formula so that the values in C2:C10000 is looking up specific names (in this case, physicians) and not just where the field is not blank. How can I change to lookup physicians in a specific list that may change, located in a separate tab from the main data set? Thank you.
    Last edited by rgold; 11-10-2008 at 02:51 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    If you assume your physician list is on a sheet called Physicians List in range A1:A10 you could possibly use something like:

    Please Login or Register  to view this content.
    However note that this would count 2 instances of Physician "X" as 2 not 1... are you wanting a distint count of physicians... ie if Physician X appears twice in C2:C10000 where T2:T10000=B2 do you want to count that particular physician once or twice ?

  3. #3
    Registered User
    Join Date
    09-04-2008
    Location
    Cherry Hill, NJ
    MS-Off Ver
    2007
    Posts
    37
    I would like to count the number of times the physician comes up in the field for the value set in B2. Does that help? Thanks. What do the dashes (--) mean in the formula? Thanks.
    Last edited by rgold; 11-10-2008 at 01:40 PM.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    Sorry not really -- if B2 holds physician why are you checking col T against that value ? I thought the physician was to be checked against col C ?

    EDIT: I think we're talking at x-purposes.

    Put your physician list in col A on a new sheet called Physicians List then test the formula provided altering the physician list range to match your own lists dimensions.
    Last edited by DonkeyOte; 11-10-2008 at 01:41 PM.

  5. #5
    Registered User
    Join Date
    09-04-2008
    Location
    Cherry Hill, NJ
    MS-Off Ver
    2007
    Posts
    37
    I know it is difficult to explain without looking at the data. Let me try. In the data set I am working with, the "T" range has a value of either "Y" or "N". In a separate worksheet, formulas using this column are looking up that value by selecting "Y" or "N" in a drop down list using data validation tool.

    Does that help explain?

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

    Add a sheet -- call it Physicians List. Add names you want to look for in A1 onwards of this sheet.

    Adjust the formula provided such that this:

    Please Login or Register  to view this content.
    matches your real range... ie if you have 100 listed use A1:A100.

    Post back once you've tested this approach.

  7. #7
    Registered User
    Join Date
    09-04-2008
    Location
    Cherry Hill, NJ
    MS-Off Ver
    2007
    Posts
    37
    Tried the formla and a value is resulting but not the correct one. Trying to figure this out. The formula so far is:

    =SUMPRODUCT(--('Step 1_Data_Current Qtr'!T2:T10000=B2),--(ISNUMBER(SEARCH('Step 3_Physician Lookup'!A1:A50,'Step 1_Data_Current Qtr'!C2:C10000))))

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    first let's change the SEARCH to a MATCH:

    Please Login or Register  to view this content.
    If the number is still incorrect can you elaborate on whether the following:

    "N" / "Mr X"
    "N" / "Mr X"

    should be counted once or twice
    (assuming B2 = "N" and "MrX" is listed on your Physician List)

  9. #9
    Registered User
    Join Date
    09-04-2008
    Location
    Cherry Hill, NJ
    MS-Off Ver
    2007
    Posts
    37
    The formula did not calculate and provided an error. To answer your questions:

    The "N" or "Y" value shows up multiple times in the data set and the physician name (Mr/Mrs X) also shows up multiple. Each record with a physician name should have value of "Y" or "N" in the data set for that column. Does that help?

  10. #10
    Registered User
    Join Date
    09-04-2008
    Location
    Cherry Hill, NJ
    MS-Off Ver
    2007
    Posts
    37
    Does ISNUMBER refer to what is being counted or the output value?

  11. #11
    Registered User
    Join Date
    09-04-2008
    Location
    Cherry Hill, NJ
    MS-Off Ver
    2007
    Posts
    37
    It worked! Below is the resulting formula. Thank you so much for your prompt feedback!

    =SUMPRODUCT(--('Step 1_Data_Current Qtr'!T2:T18000=B2),--(ISNUMBER(MATCH('Step 1_Data_Current Qtr'!C2:C18000,'Step 3_Physician Lookup'!A1:A50,0))))

  12. #12
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531
    Sorry, I was not around to answer your question immediately.

    Without the ISNUMBER the MATCH will either return an Index position (number) of the match in the lookup range if it can find one or an #N/A error value if no MATCH can be found.

    On that basis you can use ISNUMBER(MATCH(...)) to return TRUE for a Match (as a MATCH would return the INDEX position of that match value within the lookup range - ie a number) or FALSE for no match as it would return an error value (not number).
    (if you used ISNA instead of ISNUMBER you would get the opposite result -- an Error would return TRUE and a Match would return FALSE)

    The double unary operator (--) then coerces the boolean TRUE/FALSE values to 1/0 respectively.
    Last edited by DonkeyOte; 11-10-2008 at 03:10 PM.

+ 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