Panopia.com
Home
Calc
Archives

Logical Functions

Excel spreadsheet file used in video: Right-click to download file

TRUE and FALSE

Many of the arguments used by the logical functions are Boolean values. There are only 2 Boolean values, TRUE and FALSE, they evaluate to 1 and 0 respectively. The numbers 1 and 0 can be used in place of TRUE AND FALSE in formulas.

AND Function

The AND function takes Boolean arguments and gives a boolean result, if any of the arguments are FALSE then AND returns FALSE, otherwise it will return TRUE. In the following example AND tests whether the values in both Cell A1 and A2 are greater than 2, the value in A1 is less than 2 so AND will return FALSE:

If both cells contain values more than 2 then AND will return TRUE:

All arguments must return TRUE for the AND function to return TRUE.

OR Function

The OR function takes Boolean arguments and returns a Boolean result. If any of the arguments of the OR function return TRUE then the OR function returns TRUE. Only if all the arguments return FALSE will the OR function return false. In the following example the OR function tests whether the values in cell A1 OR cell A2 are greater than 2. Both values are less than 2 so OR returns FALSE:

If any argument in the OR function returns TRUE then OR Returns TRUE, here Cell B1 is more than 2 so OR returns TRUE:

IF Function

The IF function takes a Boolean value for it's first argument, if the value is TRUE then it executes the 2nd argument. If the value is FALSE, it executes the 3rd argument. In the following example, the first argument tests whether the number in cell A1 is more than 2. The number is more than 2, so the Argument is TRUE then IF executes the 2nd argument displaying a message "More than Two":

If the number in cell A1 is changed to 1 then the 1st argument of the IF function is FALSE and IF then executes the 3rd argument which displays the message "less than Two" in cell B1:

NOT Function

The NOT function returns the inverse value for it's argument. For example NOT(FALSE) returns TRUE and NOT(TRUE) returns FALSE.

XOR Function

The XOR function takes Boolean arguments or an array of boolean values. IF there are an odd number of TRUE results from it's arguments XOR returns TRUE. If there are an even number TRUE results from it's arguments XOR returns FALSE. In the following example XOR has for it's argument an array of cells A1 to A5, all of the cells are 1 so they result in TRUE. 5 is an odd number of TRUE results so XOR returns TRUE:

If one of the cells is changed to a 0, then there are an even number of TRUE results and XOR returns FALSE:

TRUE and FALSE Functions

The TRUE() function takes no arguments, it always returns TRUE.
The FALSE() function also takes no arguments and always returns FALSE.

©2021 Panopia.com