Professional Documents
Culture Documents
Week 4.1.
Logical Functions
Logical operators
A logical operator is used in Excel to compare two values. Logical operators are sometimes called
Boolean operators because the result of the comparison in any given case can only be either
TRUE or FALSE.
• Boolean logic is the formal description for the idea of TRUE and FALSE in this context.
• Boolean logic is rooted in the idea of binary logic of 1s and 0s. In that sense, TRUE is
synonymous to 1 while FALSE equates to 0.
Six logical operators are available in Excel. The following table explains what each of them does
and illustrates the theory with formula examples.
1|P a g e
Data and Computing Skills
Returns TRUE if the values in cells A1 and B1 are the same, FALSE
=A1=B1
otherwise.
=A1="oranges" Returns TRUE if cells A1 contain the word "oranges", FALSE otherwise.
Returns TRUE if cells A1 contain the Boolean value TRUE, otherwise it
=A1=TRUE
returns FALSE.
Returns TRUE if a number in cell A1 is equal to the quotient of the
=A1=(B1/2)
division of B1 by 2, FALSE otherwise.
Using Excel's Equal to operator with text values does not require any extra twists. The only thing
you should keep in mind is that the Equal to logical operator in Excel is case-insensitive,
meaning that case differences are ignored when comparing text values.
For example, if cell A1 contains the word "oranges" and cell B1 contains "Oranges", the
formula =A1=B1 will return TRUE.
If you want to compare text values taking in to account their case differences, you should use the
EXACT function instead of the Equal to operator. The syntax of the EXACT function is as simple
as:
EXACT(text1, text2)
Where text 1 and text2 are the values you want to compare. If the values are exactly the same,
including case, Excel returns TRUE; otherwise, it returns FALSE. You can also use the EXACT
function in IF formulas when you need a case-sensitive comparison of text values, as shown in
the below screenshot:
2|P a g e
Data and Computing Skills
There is a widespread opinion that in Microsoft Excel the Boolean value of TRUE always equates
to 1 and FALSE to 0. However, this is only partially true, and the key word here is "always" or
more precisely "not always" !
When writing an 'equal to' logical expression that compares a Boolean value and a number, you
need to specifically point out for Excel that a non-numeric Boolean value should be treated as a
number. You can do this by adding the double minus sign in front of a Boolean value or a cell
reference, e. g. =A2=--TRUE or =A2=--B2.
The 1st minus sign, which is technically called the unary operator, coerces TRUE/FALSE to -1/0,
respectively, and the second unary negates the values turning them into +1 and 0. This will
probably be easier to understand looking at the following screenshot:
Note. You should add the double unary operator before a Boolean when using other logical
operators such as not equal to, greater than or less than to correctly compare a numeric and
Boolean values.
Let’s look at more examples that the Equal to logical operator (=) can be used to compare
different data types:
3|P a g e
Data and Computing Skills
However, as you can see, even though some of the compared cells appeared to be the same, the
outcome was FALSE. The primary cause for this is the variety of format variances. For example,
A9 and B9 both appear as 1/1/2001, however upon closer observation, it is clear that A9 is text
rather than a date.
The next figure shows a more detailed version of compared cells.
4|P a g e
Data and Computing Skills
Greater than, less than, greater than or equal to, less than or equal to
You use these logical operators in Excel to check how one number compares to another.
Microsoft Excel provides 4 comparison operates whose names are self-explanatory:
Most often, Excel comparison operators are used with numbers, date and time values. For
example:
5|P a g e