+ Reply to Thread
Results 1 to 20 of 20

Multiple Logical Tests in an IF function

  1. #1
    Registered User
    Join Date
    07-25-2014
    Location
    Georgia
    MS-Off Ver
    2013
    Posts
    15

    Multiple Logical Tests in an IF function

    Hello,

    I have a sort-of working formula I need help with:

    =IFERROR(IF(ISNA(MATCH($F$9,AxisVAD,0)),VLOOKUP(A17,'SEARCH THIS'!A:D,4,FALSE),VLOOKUP(A17,'SEARCH THIS'!A:D,3,FALSE)),"")

    The formula tests if cell F9 matches a value in a defined range (I will notethat these are text values) and if it's positive it returns one value, and if not, it returns another. My problem is that even if the value does not match the defined range, the formula still returns the first value option.

    So... here's what I need it to do:

    Does value match AxisVAD? NO: does value match AxisBBD? No: return nothing. OR Does value match AxisVAD? Yes: return _________. OR Does value match AxisVAD? No: Does value match AxisBBD? YES: return _________. .

    Please help!
    Last edited by scrouse14; 07-25-2014 at 12:55 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Multiple Logical Tests in an IF function

    I do not believe you are using the MATCH function correctly. MATCH will not compare two values, it will find a value in an array and return it's position relative to the first cell of that array.

    If you have in A1:A5 the letters A B C D E, for example, and you use =MATCH("C",A1:A5,0) the result will be 3, because "C" is in the third position of the array defined.



    If you are comparing two values to see if they are the same, all you need to do is

    Try;

    =IFERROR(IF(ISNA($F$9=AxisVAD,VLOOKUP(A17,'SEARCH THIS'!A:D,4,FALSE),VLOOKUP(A17,'SEARCH THIS'!A:D,3,FALSE)),"")

    Edit: Read the rest of the post, since it is a range you could use match with an operator such as > <

    =if(match(a1,a1:15,0)>0,"true","false")
    This will give a positive result greater than zero if the lookup value is anywhere in the array
    Last edited by Speshul; 07-25-2014 at 09:23 AM.
    You should hit F5, because chances are I've edited this post at least 5 times.
    Example of Array Formulas
    Quote Originally Posted by Jacc View Post
    Sorry, your description makes no sense. I just made some formula that looks interesting cause I had nothing else to do.
    Click the * below on any post that helped you.

  3. #3
    Registered User
    Join Date
    07-25-2014
    Location
    Georgia
    MS-Off Ver
    2013
    Posts
    15

    Re: Multiple Logical Tests in an IF function

    Thank you. Do you have any advice on adding the second logical test?

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Multiple Logical Tests in an IF function

    Nest another IF statement in there

    IF(logical test, true, IF(another logical test, true, IF(and another logical test, true, false), false2)

    BOLD if will run when the first if comes back false
    ITALIC if will run when both the BOLD and first if come back false
    Last edited by Speshul; 07-25-2014 at 09:27 AM.

  5. #5
    Registered User
    Join Date
    07-25-2014
    Location
    Georgia
    MS-Off Ver
    2013
    Posts
    15

    Re: Multiple Logical Tests in an IF function

    Thank you for your response. I tried the following, and it tells me I have too many arguments:

    =IF(ISNA(MATCH($F$9,AxisVAD,0)),VLOOKUP(A17,'SEARCH THIS'!A:D,4,FALSE),(ISNA(MATCH($F$9,AxisBBD,0),VLOOKUP(A17,'SEARCH THIS'!A:D,3,FALSE))))


    This is how excel is seeing it:
    Orange= logical test
    Blue= value if true
    Red=value if false

  6. #6
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Multiple Logical Tests in an IF function

    =IF(ISNA(MATCH($F$9,AxisVAD,0)), <-----There is the test for the IF
    VLOOKUP(A17,'SEARCH THIS'!A:D,4,FALSE), <------ this happens if TRUE
    (ISNA(MATCH($F$9,AxisBBD,0), <------- This happens if FALSE
    VLOOKUP(A17,'SEARCH THIS'!A:D,3,FALSE)))) <--------- This is the extra argument, when should this run?

    Can you upload a sample of exactly what you are trying to achieve?

  7. #7
    Registered User
    Join Date
    07-25-2014
    Location
    Georgia
    MS-Off Ver
    2013
    Posts
    15

    Re: Multiple Logical Tests in an IF function

    Ok, then let me put it this way:

    IF(ISNA(MATCH($F$9,AxisVAD,0)), <-----There is the test for the IF
    VLOOKUP(A17,'SEARCH THIS'!A:D,4,FALSE), <------ this happens if first logical test is TRUE
    (ISNA(MATCH($F$9,AxisBBD,0), <------- This is the second logical test I need to run IF the first test is false
    VLOOKUP(A17,'SEARCH THIS'!A:D,3,FALSE)))) <-------- This needs to happen if the second logical test is TRUE

    I need the entire formula to return nothing if neither are true. I need two logical tests in 1 formula.

  8. #8
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Multiple Logical Tests in an IF function

    How about this:
    =IFERROR(VLOOKUP(A17,'SEARCH THIS'!A:D,IF(ISNA(MATCH($F$9,AxisVAD,0)),4,IF(ISNA(MATCH($F$9,AxisBBD,0)),3,"")),0),"")
    Quang PT

  9. #9
    Registered User
    Join Date
    07-25-2014
    Location
    Georgia
    MS-Off Ver
    2013
    Posts
    15

    Re: Multiple Logical Tests in an IF function

    Thank you for the new perspective on the formula! This formula works the same way as the one I had originally posted.

    The main issue still remains, when a value is input into F9 which does not match either AxisVAD or AxisBBD (or even if nothing is entered in F9), the formula still returns the first value it finds: "(ISNA(MATCH($F$9,AxisVAD,0)),4" if there is a value entered in A17.

  10. #10
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Multiple Logical Tests in an IF function

    Quote Originally Posted by scrouse14 View Post
    Ok, then let me put it this way:

    IF(ISNA(MATCH($F$9,AxisVAD,0)), <-----There is the test for the IF
    VLOOKUP(A17,'SEARCH THIS'!A:D,4,FALSE), <------ this happens if first logical test is TRUE
    (ISNA(MATCH($F$9,AxisBBD,0), <------- This is the second logical test I need to run IF the first test is false
    VLOOKUP(A17,'SEARCH THIS'!A:D,3,FALSE)))) <-------- This needs to happen if the second logical test is TRUE

    I need the entire formula to return nothing if neither are true. I need two logical tests in 1 formula.
    That is not a second logical test, there is no IF statement in there, the bold row is the FALSE statement of the first IF.

    The reason there are too many arguments, is you essentially have four arguments for one IF statement, when an IF statement only have logical_test , value_if_true , value_if_false

  11. #11
    Registered User
    Join Date
    07-25-2014
    Location
    Georgia
    MS-Off Ver
    2013
    Posts
    15

    Re: Multiple Logical Tests in an IF function

    Thank you, I do realize that it is not a second logical test. However, I am saying I need to find a way to make there be one there.

    I need there to be an either ___ or ____ OR ____ with a logical order of which comes first.

    Is there another statement that I can use to make what I need to happen calculate?

  12. #12
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Multiple Logical Tests in an IF function

    Maybe you can try to use ISNUMBER(MATCH(...)), instead of ISNA

    I tried with my formula:
    =IFERROR(VLOOKUP(A17,'SEARCH THIS'!A:D,IF(ISNUMBER(MATCH($F$9,AxisVAD,0)),4,IF(ISNUMBER(MATCH($F$9,AxisBBD,0)),3,"")),0),"")
    means if match VAD, gives 4, if match BBD, gives 3, if not, gives "", as column_number for VLOOKUP

  13. #13
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Multiple Logical Tests in an IF function

    =IFERROR(MATCH($F$9,AxisVAD,0),
    IFERROR(VLOOKUP(A17,'SEARCH THIS'!A:D,4,FALSE),
    IFERROR(ISNA(MATCH($F$9,AxisBBD,0)),
    IFERROR(VLOOKUP(A17,'SEARCH THIS'!A:D,3,FALSE),"Nothing matched"))))

    If you can upload a sample file, this will be solved much more quickly

  14. #14
    Registered User
    Join Date
    07-25-2014
    Location
    Georgia
    MS-Off Ver
    2013
    Posts
    15

    Re: Multiple Logical Tests in an IF function

    The Real Deal.xlsm

    Please see the attached for a dummy version. Thank you for all the help.

  15. #15
    Valued Forum Contributor
    Join Date
    01-19-2012
    Location
    Barrington, IL
    MS-Off Ver
    Excel 2007/2010
    Posts
    1,211

    Re: Multiple Logical Tests in an IF function

    You are getting 13 because IF(ISNA(MATCH($F$9,Sheet1!$O$8:$O$20,0) returns the number 13, because you are looking for "Johns House" in a range in which "Johns House" is listed on the 13th row. MATCH does not test for a values existence in a range, it returns the index in which that value exists.

    Add a >0 to the end of the match, and now it is a test. Because if the value is greater than 0, it will return a TRUE, instead of a 13. TRUE can be used by the IF function to work properly.

    =IFERROR(VLOOKUP(A17,'SEARCH THIS'!A:D,IF(ISNA(MATCH($F$9,Sheet1!$O$8:$O$20,0))>0,4,IF(ISNA(MATCH($F$9,Sheet1!$O$22:$O$27,0))>0,3,"")),0),"")

    I'm still looking though, trying to reverse engineer this sheet!
    I don't quite understand what the Addresses have to do with it and why a MATCH is being used to look for them?


    Oh, if you just needed it to be blank if no name is selected in the dropdown, do this

    =IF(F9="","",IFERROR(VLOOKUP(A17,'SEARCH THIS'!A:D,IF(ISNA(MATCH($F$9,Sheet1!$O$8:$O$20,0))>0,4,IF(ISNA(MATCH($F$9,Sheet1!$O$22:$O$27,0))>0,3,"")),0),""))
    Last edited by Speshul; 07-25-2014 at 02:26 PM.

  16. #16
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: Multiple Logical Tests in an IF function

    Something completely different.
    Look at the orange cells
    Attached Files Attached Files
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  17. #17
    Registered User
    Join Date
    07-25-2014
    Location
    Georgia
    MS-Off Ver
    2013
    Posts
    15

    Re: Multiple Logical Tests in an IF function

    Speshul,

    "You are getting 13 because IF(ISNA(MATCH($F$9,Sheet1!$O$8:$O$20,0) returns the number 13, because you are looking for "Johns House" in a range in which "Johns House" is listed on the 13th row. MATCH does not test for a values existence in a range, it returns the index in which that value exists."

    That's not why I'm getting 13. I'm not searching for John's house. John's house is the determining factor. IF F9 is in either of the defined ranges, which as you can see, the formula sees just fine using MATCH, then return the correct price from SEARCH THIS.

    John's house is in a named range which defines which price to use from the sheet "Search This." If you change the address to Stacy's house, you will get the second price, not the position of which Stacy's house is in the range, because Stacy's house is in another named range to define which price should be used. MATCH does not ONLY define what position something is in. And in this formula, it works just fine as it is.

    The formula as it stands does it's initial job. Please note that there is nothing wrong with how it returns prices when the address is chosen from the drop down box. The problem exists when NOTHING is chosen or when something that is not in the drop down box is typed into it.

  18. #18
    Registered User
    Join Date
    07-25-2014
    Location
    Georgia
    MS-Off Ver
    2013
    Posts
    15

    Re: Multiple Logical Tests in an IF function

    Thank you Popipipo for the new perspective, but this does not solve the problem I'm having. If you enter nothing or a type something other than the drop down options into F9, it still returns a value. The issue I'm having is that if F9 is blank or has another value typed into it, the formula needs to return nothing or 0.

  19. #19
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: Multiple Logical Tests in an IF function

    If you enter nothing or a type something other than the drop down options into F9, it still returns a value.
    If I type nothing or something else in F9 Cells N17 and N18 are empty

  20. #20
    Registered User
    Join Date
    07-25-2014
    Location
    Georgia
    MS-Off Ver
    2013
    Posts
    15

    Re: Multiple Logical Tests in an IF function

    You're right, I'm sorry I was still seeing my formula result showing up as well. Thank you!!! Tbh I am not too understanding of what you did, but it works so thanks!

+ 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] need help with basic IF function with multiple "logical tests".
    By nightale in forum Excel General
    Replies: 7
    Last Post: 07-10-2014, 07:49 PM
  2. if function: preforming logical tests on multiple sheets
    By sai19 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-28-2013, 09:15 AM
  3. Multiple IF logical tests
    By plauterborn in forum Excel General
    Replies: 3
    Last Post: 02-14-2012, 04:39 PM
  4. Multiple text Logical tests
    By smanderson in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-21-2010, 04:47 PM
  5. multiple logical tests as argument in Database function
    By riwiseuse in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-09-2009, 07:45 AM

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