# IF

IF(logical_test [,value_if_true] [,value_if_false])

Returns the value based on whether a certain condition is True or False.

 logical_test The value or expression that can be evaluated to True or False. value_if_true (Optional) The value that is returned if "logical_test" is True. value_if_false (Optional) The value that is returned if "logical_test" is False.

 REMARKS
 * For an overview of conditional formulas refer to this page* This function is not case sensitive when matching text strings.* This function does not support wildcards (? and *).* This function does use short circuiting evaluation.* If the "value_if_true" is left blank then, "value_if_false" must be provided.* If the "value_if_false" is left blank then, "value_if_true" must be provided.* If "logical_test" is true and "value_if_true" is blank, then zero is returned. Example 12.* If "logical_test" is false and "value_if_false" is blank, then False is returned.* You can have a maximum of 64 nested IF functions.* You can use the IFERROR function to return the value or something else if it evaluates to an error.* You can use the IFS function when you have multiple conditions and do not want to use nested IF functions.* You can use the AND function to return the logical AND for any number of arguments.* You can use the OR function to return the logical OR for any number of arguments.* You can use the NOT function to return the opposite of a True or False value.* You can use the SWITCH function to return a value based on a list of exact matches.* For the Microsoft documentation refer to support.microsoft.com

 A B 1 =IF(50<100,"true value","false value") = true value 9 2 =IF(100<50,"true value","false value") = false value 14 3 =IF(B2>20,"true value","false value") = false value 41 4 =IF(B2<30,"true value","false value") = true value one 5 =IF("text"="text",TRUE,FALSE) = True two 6 =IF("TEXT"="text",TRUE,FALSE) = True 7 =IF(B6="","blank","not blank") = blank 8 =IF(ISBLANK(B6),"blank","not blank") = blank 9 =IF(AND(B4="one",B5="two"),"both","") = both 10 =IF(OR(B4="one",B1>30),"one","") = one 11 =IF(TRUE,"true value") = true value 12 =IF(TRUE,) = 0 13 =IF(FALSE,) = False 14 =IF(TRUE,,"false value") = 0 15 =IF(FALSE,"true value") = False 16 =IF(TRUE,,) = 0 17 =IF(FALSE,,) = 0 18 =IF(B2<10,10,IF(B2<=20,20,IF(B2<=30,30,IF(B2<=40,40,"over 40")))) = 20 19 =IFS(B2<10,10,B2<=20,20,B2<=30,30,B2<=40,40,B2>40,"over 40") = 20 20 =IF(B4="one",1,IF(B4="two",2,IF(B4="three",3,IF(B4="four",4,5)))) = 1 21 =IFS(B4="one",1,B4="two",2,B4="three",3,B4="four",4,ISTEXT(B4)=TRUE,5) = 1 22 =SWITCH(B4,"one",1,"two",2,"three",3,"four",4,5) = 1

 1 - What value is returned when the logical test returns True.2 - What value is returned when the logical test returns False.3 - What value is returned when the logical test "B2>20" is evaluated.4 - What value is returned when the logical test "B2<30" is evaluated.5 - What value is returned when the condition "text"="text" is evaluated.6 - What value is returned when the condition "TEXT"="text" is evaluated. This function is not case sensitive.7 - What value is returned when the cell "B6" is compared to an empty string.8 - What value is returned when the cell "B6" is passed to the ISBLANK function.9 - What value is returned when the AND function is evaluated.10 - What value is returned when the OR function is evaluated.11 - What value is returned when the logical test is True and the "value_if_false" is not provided.12 - What value is returned when the logical test is True and the "value_if_false" is not provided. The default value is 0.13 - What value is returned when the logical test is False and the "value_if_false" is not provided. The default value is False.14 - What value is returned when the logical test is True but the "value_if_true" is blank. The default value is 0.15 - What value is returned when the logical test is False but the "value_if_false" is blank. The default value is False.16 - What value is returned when the logical test is True and both the other arguments are blank. The default value is 0.17 - What value is returned when the logical test is False and both the other arguments are blank. The default value is 0.18 - What value is returned when the cell "B2" is evaluated using multiple nested IF functions.19 - What would the equivalent formula be using the IFS function.20 - What value is returned when the cell "B4" is evaluated using multiple nested IF functions.21 - What would the equivalent formula be using the IFS function and the ISTEXT function.22 - What would the equivalent formula be using the SWITCH function.