Logical Functions in Excel (IF, AND, OR, XOR, IFERROR, IFNA, IFS, and SWITCH)
Logical functions are functions that allow you to test conditions and return values based on the results. In this blog post, we will learn how to use nine common logical functions in Excel: IF, AND, OR, XOR, NOT, IFERROR, IFNA, IFS, and SWITCH.
IF Function
The IF function allows you to make decisions based on whether a condition is true or false. The IF function can also be nested inside another IF function, to test multiple conditions and return different values.
![]() |
I have also applied conditional formatting for cells containing "F" values |
AND Function
The AND function checks multiple conditions and returns TRUE if all of them are true, and FALSE if any of them are false. You can have up to 255 conditions in the AND function.
OR Function
The OR function checks multiple conditions and returns TRUE if any of them are true, and FALSE if all of them are false. You can have up to 255 conditions in the OR function.
Syntax of the OR function is: =OR(condition1, condition2, …)
![]() |
All these functions are not case-sensitive. meaning whether you use uppercase or lowercase (e.g., "YES" or "Yes") in formula, the results remain same. |
XOR Function
The XOR function, stands for "exclusive or,". It returns TRUE if an odd number of conditions are TRUE and FALSE if an even number of conditions are TRUE. In other words, XOR evaluates multiple conditions and returns TRUE only when an odd number of these conditions are true. If an even number or none of the conditions are true, it returns FALSE.
Syntax of the XOR function is: =XOR(condition1, condition2, …)
IFERROR Function
The IFERROR function is a logical function that can be used to handle errors in formulas. It returns a value if the first argument is an error, and the value of the first argument otherwise.
Syntax of the IFERROR function is: =IFERROR(value, value_if_error)
The value argument can be any value or expression that you want to test for errors. The value_if_error argument can be any value that you want to return if the value argument is an error.
IFNA Function
The IFNA function is a logical function that can be used to handle #N/A errors in formulas. It returns the value of the first argument, otherwise a other specified value if the first argument is the #N/A error.
Syntax of the IFNA function is: =IFNA(value, value_if_na)
The "value_if_na" argument can be any value that you want to return if the first argument is the #N/A error.
IFS function
The IFS function is a logical function that checks multiple conditions and returns a value corresponding to the first true condition. It is a simplified version of the nested IF function, as it eliminates the need for multiple IF statements. You can use up to 127 pairs of logical tests and values in the IFS function.
Syntax of the IFS function is: =IFS(logical_test1, value_if_true1, [logical_test2, value_if_true2], ...)
SWITCH function
The SWITCH function is a logical function that evaluates an expression and returns a value based on a matching case. It is similar to the IFS function, but it uses exact matches instead of logical tests. You can use up to 126 pairs of values and results in the SWITCH function. The syntax of the SWITCH function is:
=SWITCH(expression, value1, result1, [default or value2, result2], ...)

Comments
Post a Comment