The XOR logical function is now part of Google Sheets. Learn the use of XOR function in Google Sheets and its difference with the logical OR function.
Google has silently added the XOR logical function in its cloud-powered Spreadsheet application called Google Sheets.
Google is doing everything possible to make this already powerful and popular Spreadsheet application more acceptable to users.
You can use XOR formula in Google Sheets to perform an exclusive OR. What does it mean by exclusive OR which is also called as EOR?
See the examples below to understand this. Take a look at the Syntax and jump to the examples.
XOR(logical_expression1, [logical_expression2, ...])
How to Use the XOR Function in Google Sheets
To understand the use of XOR in Google Doc Sheets, you should know what is exclusive OR.
See is one example. Here are the values of two cells.
A1 = 5
A2 = 20
Formula:
=xor(A1=10,A2=20)
Result: TRUE
Change the value in A1 to 10. You can see that the above same formula returns FALSE. Why so?
XOR Returns TRUE if an odd number of arguments are TRUE
To make you understand this better, I have included more logical tests below.
Here are few more XOR formula examples that explain to you what is the odd number of arguments are true in the XOR function.
See the formulas in column E. Just count the TRUE in each of the formulas.
In all the formulas the number of TRUE arguments is odd and since all of the formulas return TRUE.
The difference of XOR Function with OR in Google Sheets
If you replace XOR with the OR function in all of the above formulas the result would be the same.
The OR function doesn’t differentiate whether the total number of logical expression TRUE is odd or even. It only tests if any of the provided arguments are logically true.
I have the number 5 in cell A1, B1, C1 and D1. See the two formulas below.
=or(A1=5,B1=5,C1=5,D1=5)
Result: TRUE
=xor(A1=5,B1=5,C1=5,D1=5)
Result: FALSE
Here the XOR formula returns FALSE since even number of arguments is the TRUE. Refer to this Docs Editors help article for more info.
I don’t have any real-life example to share with you related to the use of XOR in Google Sheets. But I suggest you go through this XOR Gate Wikipedia article to get some insight about the practical use.
Hope this tutorial could help you to learn how to use the XOR Function in Google Sheets.