+ Reply to Thread
Results 1 to 26 of 26

Daily Challenge! Need help with multiple vlookup criteria

  1. #1
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Daily Challenge! Need help with multiple vlookup criteria

    Hey Pro's!

    I have a unique challenge that is giving me a hard time. I am trying to write an all in one formula with several lookups based on certain criteria. I have 25 line items that I am trying to assign a user to each, based on certain criteria. In the attached spreadsheet, there are 4 tabs. Tab 1 is the data tab. Tab 2 and 3 are the lookup reference tabs. Tab 4 is a list of forms that I only want the formula to apply to.

    Here are the specifics of the formula I am trying to have it contain in one cell:

    - Formula should only apply to items where the "Form" equals one of the forms listed in tab "List 3"
    - Formula should only apply to items where the "Location" equals "GOS"
    - If the Form = SMILE_ERR, the formula should only apply to Err Code B36 and B07 (column E).
    - If the Location = "GOS" and Initials = "" or Initials = "STR", formula should look to "List 2" tab to pull back the ID based on sales office match.
    - If the Location = "GOS" and Initials <> "" and Initials <> "STR", formula should look to "List 1" tab to pull back the ID based on initials match.
    - If the Form = SMILE_ERR, the formula should only apply to Err Code B36 and B07 (column E).

    Any help or guidance you can provide would be greatly appreciated!
    Attached Files Attached Files
    Last edited by tkbuc; 07-20-2017 at 12:09 PM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,217

    Re: Daily Challenge! Need help with multiple vlookup criteria

    There is no manually added data in the assign column - we will need some so that we can see what you are expecting. Please add some (about 10) to the file and attach again. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,895

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Something like below?
    =IFERROR(IF(SUMPRODUCT(ISNUMBER(MATCH(A2,'List 3'!$A$2:$A$10,0))*(F2="GOS")*(A2<>"SMILE_ERR")+(A2="SMILE_ERR")*(C2="B07")+(A2="SMILE_ERR")*(C2="B06"))=1,IF(OR(D2="",D2="STR"),VLOOKUP(Data!E2,'List 2'!$A$2:$B$16,2),VLOOKUP(Data!D2,'List 1'!$A$2:$B$7,2)),"NA"),"NA")

    Though I suspect there's better method.

    See attached.
    Attached Files Attached Files
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,099

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Take a look at column g:

    =IF(AND(ISNUMBER(MATCH(A2,'List 3'!$A$2:$A$10,0)),IFERROR(F2="GOS",FALSE)),IF(OR(D2="",D2="STR"),VLOOKUP(E2,'List 2'!$A$2:$B$16,2,FALSE),VLOOKUP(D2,'List 1'!$A$2:$B$7,2,FALSE)),"")

    HOWEVER, this does not take account of "- If the Form = SMILE_ERR, the formula should only apply to Err Code B06 and B07 (column E)" as I have no idea what you mean by this. so, explain that again and also see if what I already have is heading in the correct direction...
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  5. #5
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Sure. Here is the updated version.
    Attached Files Attached Files

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,895

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Your updated file seems to be in conflict with your condition(s).

    G4: PR_CORRESP isn't in your List3
    G5: BROKER_CHG isn't in your List3
    G18: ERR_CODE is B36 (not B06 or B07) - See EDIT:
    G22: Initials = "STR" should it not lookup in List2?
    G26: ERR_CODE is B07 And Initials <> "" Or "STR", so should it not lookup in List1?

    To return blank instead of "NA" just replace "NA" with "" in the formula found in Post #3

    EDIT: Ah I see you had B36 & B07 intially, but had B06 & B07 in second instance in your condition. I had missed that.
    Replace "B06" in the formula with "B36", if that's what you need.
    Last edited by CK76; 07-20-2017 at 11:55 AM. Reason: See Edit:

  7. #7
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Correct. The error codes should be B36 and B07 for Smile_Error forms. However, the list of forms on the data tab shouldn't drive the formula except for the smile_err. In the system, some forms may or may not appear in the data so I can't have that be a driving factor. Attached is the expected outcome.
    Attached Files Attached Files
    Last edited by AliGW; 07-20-2017 at 12:12 PM.

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,895

    Re: Daily Challenge! Need help with multiple vlookup criteria

    So below condition doesn't apply?
    - Formula should only apply to items where the "Form" equals one of the forms listed in tab "List 3"

  9. #9
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Quote Originally Posted by CK76 View Post
    So below condition doesn't apply?
    So sorry. I'm confusing myself. Disregard what you quoted me. Yes. Formula should only apply to items where the form equals one of the forms listed in tab "List 3". So sorry. Juggling too much today.

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,895

    Re: Daily Challenge! Need help with multiple vlookup criteria

    See demo column in attached.
    Attached Files Attached Files

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,099

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Based on your comment at Post 9, please check your expected answer for rows 4-6...

    I am currently looking at this one:

    =IF(OR(AND(ISNUMBER(MATCH(A2,'List 3'!$A$2:$A$10,0)),IFERROR(F2="GOS",FALSE)),AND(A2="SMILE_ERR",OR(C2="B07",C2="B36"))),IF(OR(D2="",D2="STR"),VLOOKUP(E2,'List 2'!$A$2:$B$16,2,FALSE),VLOOKUP(D2,'List 1'!$A$2:$B$7,2,FALSE)),"")
    Last edited by Glenn Kennedy; 07-20-2017 at 12:31 PM.

  12. #12
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Quote Originally Posted by CK76 View Post
    See demo column in attached.
    It looks good. The only two issues I see is line 22, nothing should populate because the initials are "STR". For Line 26, nothing should populate because the location = TAMPA. Other than those, the formula works.

  13. #13
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Quote Originally Posted by Glenn Kennedy View Post
    Based on your comment at Post 9, please check your expected answer for rows 4-6...

    I am currently looking at this one:

    =IF(OR(AND(ISNUMBER(MATCH(A2,'List 3'!$A$2:$A$10,0)),IFERROR(F2="GOS",FALSE)),AND(A2="SMILE_ERR",OR(C2="B07",C2="B36"))),IF(OR(D2="",D2="STR"),VLOOKUP(E2,'List 2'!$A$2:$B$16,2,FALSE),VLOOKUP(D2,'List 1'!$A$2:$B$7,2,FALSE)),"")
    When I apply the formula to my expected outcome file (attached), it provides an assignment for line 6 and line 22 but these shouldn't have assignments. Line 6 shouldn't becaue "B04" is not a proper error code and for line 22, the initials are "STR" which should not have formula applied.
    Attached Files Attached Files

  14. #14
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,895

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Ok. Line 26 fixed. But for line 22, when Initials = "STR" shouldn't formula lookup in List2?

    - If the Location = "GOS" and Initials = "" or Initials = "STR", formula should look to "List 2" tab to pull back the ID based on sales office match.
    Current formula:
    =IFERROR(IF(SUMPRODUCT(ISNUMBER(MATCH(A22,'List 3'!$A$2:$A$10,0))*(F22="GOS")*(A22<>"SMILE_ERR")+(A22="SMILE_ERR")*(C22="B07")*(F22="GOS")+(A22="SMILE_ERR")*(C22="B36"))*(F22="GOS")=1,IF(OR(D22="",D22="STR"),VLOOKUP(Data!E22,'List 2'!$A$2:$B$16,2),VLOOKUP(Data!D22,'List 1'!$A$2:$B$7,2)),""),"")

    Edit: Took redundant check outside of SUMPRODUT to make it slightly shorter.
    =IFERROR(IF(SUMPRODUCT(ISNUMBER(MATCH(A2,'List 3'!$A$2:$A$10,0))*(A2<>"SMILE_ERR")+(A2="SMILE_ERR")*(C2="B07")+(A2="SMILE_ERR")*(C2="B36"))*(F2="GOS")=1,IF(OR(D2="",D2="STR"),VLOOKUP(Data!E2,'List 2'!$A$2:$B$16,2),VLOOKUP(Data!D2,'List 1'!$A$2:$B$7,2)),""),"")
    Last edited by CK76; 07-20-2017 at 12:43 PM.

  15. #15
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    I think this works. Let me apply it to the larger data file and see what it looks like.

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,217

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Tkbuc - please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!

    For normal conversational replies, try using the QUICK REPLY box below.

  17. #17
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    OK so I applied the formula to the larger data set. I saved the file (attached) and filtered to the issue I am seeing. I am sseing the formula not use the Sales office for the lookup if the initials are not found on the initials tab.

    So for example, line 1282, initials "AJW" is not found on the initials tab called "GOSC RM". As a result, I would expect the formula to then look for Sales Office "OC" on the "GOSC SM" tab for the assignment. It is not doing that. It somehow is assigning "nwar1" as the assignment, which is only found on the initials tab but not for the initials "AJW".

    This is the formula modified for the larger set data:
    =IFERROR(IF(SUMPRODUCT(ISNUMBER(MATCH(D2,'GOSC Docs'!$A$2:$A$16,0))*(D2<>"SMILE_ERR")+(D2="SMILE_ERR")*(O2="B07")+(D2="SMILE_ERR")*(O2="B36"))*(AK2="GOSC")=1,IF(OR(P2="",P2="STR"),VLOOKUP(AF2,'GOSC SM'!$C$2:$H$32,6),VLOOKUP(P2,'GOSC RM'!B:F,5)),""),"")
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    ***bump***

  19. #19
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,895

    Re: Daily Challenge! Need help with multiple vlookup criteria

    I am sseing the formula not use the Sales office for the lookup if the initials are not found on the initials tab.
    Well... you didn't specify above condition in your previous posts. We are not mind reader and can't give you what you didn't ask for.

    Correct answers are given to those that ask correct questions

    At any rate, use Exact match for vlookup then. And use IFERROR to lookup in another list. Something like below.
    =IFERROR(IF(SUMPRODUCT(ISNUMBER(MATCH(D85,'GOSC Docs'!$A$2:$A$16,0))*(D85<>"SMILE_ERR")+(D85="SMILE_ERR")*(O85="B07")+(D85="SMILE_ERR")*(O85="B36"))*(AK85="GOSC")=1,IF(OR(P85="",P85="STR"),VLOOKUP(AF85,'GOSC SM'!$C$2:$H$32,6,0),IFERROR(VLOOKUP(P85,'GOSC RM'!B:F,5,0),VLOOKUP(AF85,'GOSC SM'!$C$2:$H$32,6,0))),""),"")

  20. #20
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    CK76,

    It worked! Thank you so much for your time, skill and patience with me. Apologies for me not being very clear.

    For my knowledge and learning, would you be able to explain how this portion of the formula works? I understand VLOOKUPS and IFERRORs, but not that familiar with SUMPRODUCT and ISNUMBER. Just trying to understand the logic the formula is using.

    IF(SUMPRODUCT(ISNUMBER(MATCH(D85,'GOSC Docs'!$A$2:$A$16,0))*(D85<>"SMILE_ERR")+(D85="SMILE_ERR")*(O85="B07")+(D85="SMILE_ERR")*(O85="B36"))*(AK85="GOSC")=1

  21. #21
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,895

    Re: Daily Challenge! Need help with multiple vlookup criteria

    SUMPRODUCT is just one way of checking logical condition (often used on array/range).

    First, MATCH function looks for exact match for Form in list. If not found, it returns error.
    So, if any number is returned, it means match has been found in the list. Therefore, ISNUMBER is used to convert that into True/False array.

    Multiplication of logical statement equates to AND(Logical1, Logical2, ...).

    Addition of logical statement equates to OR(Logical1, Logical2, ....)

    This is because in many programs (including Excel). True = 1 and False = 0.

    So above, can also be written as...
    IF(AND(AND(ISNUMBER(MATCH(D85,'GOSC Docs'!$A$2:$A$16,0)),OR(D85<>"SMILE_ERR",AND(D85="SMILE_ERR",OR(O85="B07",O85="B36")))),(AK85="GOSC"),,)

    I just find it easier to read/write logical statement in mathematical terms, rather than in multiple nested AND/OR statements.

    But, to think of it... Since we are not trying to evaluate array of true/false, there's no need for SUMPRODUCT in this case. Formula can be written as...

    =IFERROR(IF((ISNUMBER(MATCH(D85,'GOSC Docs'!$A$2:$A$16,0))*(D85<>"SMILE_ERR")+(D85="SMILE_ERR")*(O85="B07")+(D85="SMILE_ERR")*(O85="B36"))*(AK85="GOSC")=1,IF(OR(P85="",P85="STR"),VLOOKUP(AF85,'GOSC SM'!$C$2:$H$32,6,0),IFERROR(VLOOKUP(P85,'GOSC RM'!B:F,5,0),VLOOKUP(AF85,'GOSC SM'!$C$2:$H$32,6,0))),""),"")

  22. #22
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Thanks again CK!

  23. #23
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Hey CK!

    Another question. I've been asked to add two more criteria to the formula you provided me (in column BG in the attached spreadsheet)

    =IFERROR(IF((ISNUMBER(MATCH(D2,'GOSC Docs'!$A$2:$A$16,0))*(D2<>"SMILE_ERR")+(D2="SMILE_ERR")*(O2="B07")+(D2="SMILE_ERR")*(O2="B36"))*(AK2="GOSC")=1,IF(OR(P2="",P2="STR"),VLOOKUP(AF2,'GOSC SM'!$C$2:$H$32,6,0),IFERROR(VLOOKUP(P2,'GOSC RM'!B:F,5,0),VLOOKUP(AF2,'GOSC SM'!$C$2:$H$32,6,0))),""),"")

    New CRITERIA:
    1. If column D = "Refund" OR if column W = "Y", then the formula should provide a blank assignment.
    2. In the event that column P is populated with initials that aren’t recognized by the lookup to the "GOSC RM" tab AND column AL contains either "AD-TPA", "AD-Assoc" or "AD-PEO", could we have the formula populate with “SPM”?
    Attached Files Attached Files

  24. #24
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    ***bump****
    Last edited by tkbuc; 08-03-2017 at 12:19 PM.

  25. #25
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,895

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Try this.
    =IF((D2="Refund")+(W2="Y"),"",IFERROR(IF((ISNUMBER(MATCH(D2,'GOSC Docs'!$A$2:$A$16,0))*(D2<>"SMILE_ERR")+(D2="SMILE_ERR")*(O2="B07")+(D2="SMILE_ERR")*(O2="B36"))*(AK2="GOSC")=1,IF(OR(P2="",P2="STR"),VLOOKUP(AF2,'GOSC SM'!$C$2:$H$32,6,0),IFERROR(VLOOKUP(P2,'GOSC RM'!B:F,5,0),IF(ISNUMBER(MATCH(AL2,{"AD-TPA","AD-Assoc","AD-PEO"},0)),"SPM",VLOOKUP(AF2,'GOSC SM'!$C$2:$H$32,6,0)))),""),""))

    But if I were you... I'd use helper columns to make it easier to understand each logic step.

  26. #26
    Registered User
    Join Date
    01-28-2015
    Location
    Tampa, FL
    MS-Off Ver
    2010
    Posts
    104

    Re: Daily Challenge! Need help with multiple vlookup criteria

    Thank you!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VLOOKUP Multiple Column Challenge
    By Logit in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 08-08-2016, 09:21 PM
  2. [SOLVED] Challenge for real excel experts!! complex categorization on multiple criteria
    By joannelittell in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-16-2013, 05:07 AM
  3. Find max value every day from multiple daily values (Solarpanels daily yield)
    By jakobscafe in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-08-2013, 09:20 AM
  4. vlookup? match? index? MULTIPLE criteria for vlookup search problem....
    By aborg88 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-11-2013, 09:56 AM
  5. [SOLVED] Sum multiple entire rows based on criteria, array formula challenge!
    By ppffffpp in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-10-2012, 09:42 PM
  6. Excel 2007 : Vlookup challenge
    By ngaisteve1 in forum Excel General
    Replies: 11
    Last Post: 04-23-2012, 04:11 AM
  7. VLookUp Challenge
    By wmgrubb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2007, 06:28 PM

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