Excel XOR function: checking “only one of the two”
XOR returns TRUE when only one of two conditions is met. How it differs from AND and OR, the 3+ condition trap and an “exactly one” formula.
XOR is the “exclusive or”. It returns TRUE when only one of two conditions is met. If both are met, or neither is — FALSE.
A real case: at a checkout every receipt is paid either in cash or by card. If both columns are filled, the payment was recorded twice; if both are empty, it was never recorded. XOR finds these errors instantly. OR can’t help here: it treats “both” as fine too.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Receipt | Cash | Card | Valid? | |
| 2 | #501 | 85 000 | 0 | ИСТИНА | |
| 3 | #502 | 0 | 140 000 | ИСТИНА | |
| 4 | #503 | 60 000 | 60 000 | ЛОЖЬ1 | |
| 5 | #504 | 0 | 0 | ЛОЖЬ2 | |
| 6 | #505 | 0 | 230 000 | ИСТИНА | |
| 7 |
Syntax
=ИСКЛИЛИ(logical1; [logical2]; ...)
- logical1 — the first condition:
B2>0,A2="Yes". - logical2, … — further conditions, up to 254 in total.
The exact rule: XOR returns TRUE when the number of TRUE results is odd (1, 3, 5 …) and FALSE when it is even (0, 2, 4 …). For two conditions that means exactly “only one”. The function exists since Excel 2013.
Step by step: a check column with XOR
1
Select D2, where the check result will go.
2
Формулы → Логические → pick XOR (at the very end of the list).
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Receipt | Cash | Card | Valid? | |
| 2 | #501 | 85 000 | 0 | ||
| 3 | #502 | 0 | 140 000 | ||
| 4 | |||||
| 5 |
3
Type B2>0 in Logical1 and C2>0 in Logical2, then click OK.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Receipt | Cash | Card | Valid? | |
| 2 | #501 | 85 000 | 0 | ||
| 3 | #502 | 0 | 140 000 | ||
| 4 | |||||
| 5 |
4
Fill the formula down. Now filter column D and review the receipts showing FALSE — they need a second look.
Example 1: AND vs OR vs XOR in one table
Put the three logical functions side by side and the difference is obvious. The key one is in the first row: when both conditions are TRUE, OR says “yes” while XOR says “no”.
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Condition 1 | Condition 2 | AND | OR | XOR | |
| 2 | ИСТИНА | ИСТИНА | ИСТИНА | ИСТИНА | ЛОЖЬ1 | |
| 3 | ИСТИНА | ЛОЖЬ | ЛОЖЬ | ИСТИНА | ИСТИНА | |
| 4 | ЛОЖЬ | ИСТИНА | ЛОЖЬ | ИСТИНА | ИСТИНА | |
| 5 | ЛОЖЬ | ЛОЖЬ | ЛОЖЬ | ЛОЖЬ | ЛОЖЬ | |
| 6 |
Example 2: finding incomplete records
An attendance log records arrival and departure times. A row with only one of them is incomplete: the employee was probably not checked out. If both are empty, the person didn’t come that day — not an error.
=ЕСЛИ(ИСКЛИЛИ(ЕЧИСЛО(B2);ЕЧИСЛО(C2));"Incomplete";"OK")
A time is a number, so ISNUMBER reliably tells whether the cell is filled.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Employee | In | Out | Status | |
| 2 | Aziz | 09:00 | 18:00 | OK | |
| 3 | Dilnoza | 09:30 | Incomplete | ||
| 4 | Javohir | OK | |||
| 5 | Kamola | 17:30 | Incomplete | ||
| 6 |
Pro level: “exactly one” for 3 or more conditions
A customer must pay with one of three methods: cash, card or Click. “Exactly one” means the count of TRUE equals 1. When you add TRUE values, each becomes 1, so:
=(B2>0)+(C2>0)+(D2>0)=1— works for any number of conditions.=СЧЁТЕСЛИ(B2:D2;">0")=1— shorter when there are many columns.
Keep XOR for parity checks: for example, =ИСКЛИЛИ(B2:D2>0) — is the number of filled columns odd?
| A | B | C | D | E | F | G | |
|---|---|---|---|---|---|---|---|
| 1 | Receipt | Cash | Card | Click | XOR | Exactly one | |
| 2 | #601 | 90 000 | 0 | 0 | ИСТИНА | ИСТИНА | |
| 3 | #602 | 50 000 | 40 000 | 0 | ЛОЖЬ | ЛОЖЬ | |
| 4 | #603 | 30 000 | 30 000 | 30 000 | ИСТИНА1 | ЛОЖЬ | |
| 5 |
Try it in the simulator
Type =ИСКЛИЛИ(B2>0;C2>0) in D2 and fill it down to D6. Which receipts have the payment recorded wrongly (FALSE)?
| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Receipt | Cash | Card | Valid? | ||||||||||||||||||||
| 2 | #701 | 120000 | 0 | |||||||||||||||||||||
| 3 | #702 | 45000 | 45000 | |||||||||||||||||||||
| 4 | #703 | 0 | 310000 | |||||||||||||||||||||
| 5 | #704 | 0 | 0 | |||||||||||||||||||||
| 6 | #705 | 78000 | 0 | |||||||||||||||||||||
| 7 | ||||||||||||||||||||||||
| 8 | ||||||||||||||||||||||||
| 9 | ||||||||||||||||||||||||
| 10 |
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.