+ Reply to Thread
Results 1 to 16 of 16

Match Formula to Return 1 of 3 Possible Values

  1. #1
    Registered User
    Join Date
    07-09-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    21

    Match Formula to Return 1 of 3 Possible Values

    Hello Excellers!

    I am hoping that the Hive Mind that is this forum can help me find a solution to my problem.

    Summary:
    I am looking for a formula that will look up a value in 2 different arrays and return 1 of 3 possible statements "<--Present", "<--Absent", or "<--Per Diem".

    Description:
    The work book has the monthly employees for 2010 sorted by their departments and status. The columns are broken down by Full Time, Part Time, and Per Diem.
    Sometimes an employee will be terminated in January and will not be listed in February, and I need a "<--Absent" placed in the column beside their name. If an employee goes Per Diem from January to February I need a "<--Per Diem" placed. If an employee is present in both January and February, I need a "<--Present" placed.

    Problem:
    I am using this formula to return "<--Present" or "<--Absent"

    =IF(ISERROR(MATCH(D7,$G$7:$G$87,0)),"<--absent","<--present")

    So I figured I can change the formula to return "<--Present", "<--Absent", or "<--Per Diem"

    =IF(MATCH(D7,$G$7:$G$87,0),"<--present",IF(MATCH(D7,G145:G157,0),"<--Per Diem","<--Absent"))

    However, this formula is incorrect only producing a "<--present" if the value is in G7:G:87.

    Any help out there?

    Thanks
    Last edited by DanBraden; 11-12-2010 at 05:34 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Match Formula to Return 1 of 3 Possible Values

    Maybe:

    =IF(MATCH(D7,$G$7:$G$87,0), IF(MATCH(D7,G145:G157,0), "<--Per Diem", "<--present"), "<--Absent"))
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-09-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Match Formula to Return 1 of 3 Possible Values

    Quote Originally Posted by JBeaucaire View Post
    Maybe:

    =IF(MATCH(D7,$G$7:$G$87,0), IF(MATCH(D7,G145:G157,0), "<--Per Diem", "<--present"), "<--Absent"))
    Thank you for your reply! Unfortunately this returns "<--Per Diem" and nothing else.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Match Formula to Return 1 of 3 Possible Values

    Got something I can look at?

    Click GO ADVANCED and use the paperclip icon to post up a desensitized copy of your workbook.

  5. #5
    Registered User
    Join Date
    07-09-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Match Formula to Return 1 of 3 Possible Values

    I've attached an example of the workbook; please let me know if you need further clarification.

    Thanks for the help!
    Attached Files Attached Files

  6. #6
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Match Formula to Return 1 of 3 Possible Values

    Maybe:

    Please Login or Register  to view this content.
    ugly, but seems to work (if I understand your question)

  7. #7
    Registered User
    Join Date
    07-09-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Match Formula to Return 1 of 3 Possible Values

    Quote Originally Posted by Cutter View Post
    Maybe:

    Please Login or Register  to view this content.
    ugly, but seems to work (if I understand your question)
    Off the bat the formula isn't working, however, I never thought to use "ISNA". That might work if I apply it correctly. Let me take a bash at it and see if I can make it work.

  8. #8
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Match Formula to Return 1 of 3 Possible Values

    It's giving the following results for me:

    If employee is present in January, and present in February - Present

    If employee is present in January, not present in February - Absent

    If employee not present in January, present in February = Per Diem

    If employee not present in January or February - #N/A


    I assumed the upper region is January, lower region is February in column G

  9. #9
    Registered User
    Join Date
    07-09-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Match Formula to Return 1 of 3 Possible Values

    Quote Originally Posted by Cutter View Post
    It's giving the following results for me:

    If employee is present in January, and present in February - Present

    If employee is present in January, not present in February - Absent

    If employee not present in January, present in February = Per Diem

    If employee not present in January or February - #N/A


    I assumed the upper region is January, lower region is February in column G
    I'm sorry, in the worksheet each month has it's own column. I monkeyed with the formula and arrived at:

    =IF(AND(ISNA(MATCH(A10,$D$7:$D$77,0)),NOT(ISNA(MATCH(A10,D88:D106,0)))),"<--per diem",IF(AND(MATCH(A10,D10:D80,0)>0,ISNA(MATCH(A10,D10:D80,0))),"<--Absent","<--present"))

    However, terminated employees are showing as #N/A instead of "<--Absent" I think I might have moved some of the lookup_arrays to the wrong places.

  10. #10
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Match Formula to Return 1 of 3 Possible Values

    The last part of your formula has the same ranges being searched for a match.

  11. #11
    Registered User
    Join Date
    07-09-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Match Formula to Return 1 of 3 Possible Values

    Perhaps I should change the Formula to:

    =IF(AND(ISNA(MATCH(A10,$D$7:$D$77,0)),NOT(ISNA(MATCH(A10,$D$85:$D$103,0)))),"<--per diem",IF(AND(MATCH(A10,$D$7:$D$77,0)>0,ISNA(MATCH(A10,$D$85:$D$103,0))),"<--Present","<--Absent"))

    But this iteration is returning #NA and not "<--Absent" on terminated employees.

  12. #12
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Match Formula to Return 1 of 3 Possible Values

    You reversed the order of the last two results.
    You have Present before Absent

    Use:

    Please Login or Register  to view this content.

  13. #13
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Match Formula to Return 1 of 3 Possible Values

    Just to make it consistently ugly (but maybe easier to follow the logic) you can use this:

    Please Login or Register  to view this content.
    It only returns #N/A if no match in either range - you should (because I do) get one of the three choices by the other 3 scenarios.

  14. #14
    Registered User
    Join Date
    07-09-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Match Formula to Return 1 of 3 Possible Values

    I really appreciate your help Cutter!

    I'm sorry but I'm still having problems getting the results I want. I reversed Absent and Present because all the present employee's were resulting "<--Absent". I figured it was part of what happened when I tried to fit the formula's ranges to my layout.

    EDIT:

    Thanks Cutter! I finally got it to work but I had to reverse "<--Absent" and "<--Present" LOL.
    I really appreciate all the help, I've been pretty frustrated working on this by myself!

    If you like, please take a look at the example I'm attaching. I think it fixed the problem.
    Attached Files Attached Files
    Last edited by DanBraden; 11-12-2010 at 05:18 PM.

  15. #15
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Match Formula to Return 1 of 3 Possible Values

    I am now looking at your sample file. Which cell would you like the formula in?

    The one for January will be different from the one in February.


    Glad you got it working. Don't firget to mark it as SOLVED.
    Last edited by Cutter; 11-12-2010 at 05:22 PM.

  16. #16
    Registered User
    Join Date
    07-09-2010
    Location
    New Jersey
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: Match Formula to Return 1 of 3 Possible Values

    Thank You for the support Cutter!

    I only care about the formulas in Column C because the workbook is for a whole year. The formulas in Column F are nothing but an example of my total workbook and will be changed to reflect C when I re-apply it to my original.

    I really can't adequately express my gratitude for you support. Thank you, again.

+ 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