Understanding Logical Functions

image with no caption

You use logical functions to test for specific conditions. These functions are often called logical operators in discussions of Boolean logic, which is named after George Boole, the British mathematician. You might have run across logical operators in set theory, which is used for teaching logical concepts in high school. You use logical operators to arrive at one of two conclusions: TRUE or FALSE. We discuss the most useful logical functions in the following sections. You can access the logical functions by clicking the Logical button on the Formulas tab on the ribbon.

Excel has a rich set of logical functions. Most logical functions use conditional tests to determine whether a specified condition is TRUE or FALSE.

The IF function returns values according to supplied conditional tests. It takes the arguments (logical_test, value_if_true, value_if_false). For example, the formula =IF(A6<22, 5, 10) returns 5 if the value in cell A6 is less than 22; otherwise, it returns 10. You can nest other functions within an IF function. For example, the formula =IF(SUM(A1:A10)>0, SUM(A1:A10), 0) returns the sum of A1 through A10 if the sum is greater than 0; otherwise, it returns 0.

You can also use text arguments to return nothing instead of zero if the result is false. For example, the formula =IF(SUM(A1:A10)>0, SUM(A1:A10), “ ”) returns a null string (“ ”) if the conditional test is false. The logical_test argument can also consist of text. For example, the formula =IF(A1=“Test”, 100, 200) returns the value 100 if cell A1 contains the string Test; it returns 200 if A1 contains any other entry. The match between the two text entries must be exact except for case.