Excel tutorial
/

Functions

Advanced

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.

Книга1 - Excel
—☐✕
D4fx=ИСКЛИЛИ(B4>0;C4>0)
ABCDE
1ReceiptCashCardValid?
2#50185 0000ИСТИНА
3#5020140 000ИСТИНА
4#50360 00060 000ЛОЖЬ1
5#50400ЛОЖЬ2
6#5050230 000ИСТИНА
7
Готово
1 — payment recorded twice, 2 — not recorded at all. Both give XOR = FALSE

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).

Книга1 - Excel
—☐✕
ФайлГлавнаяВставкаРазметка страницыФормулыДанныеРецензированиеВидСправка
Вставить функциюАвтосуммаФинансовыеЛогическиеТекстовыеДата и времяСсылки и массивыМатематические
Библиотека функций
Диспетчер имён
Определённые имена
D2fx
ABCDE
1ReceiptCashCardValid?
2#50185 0000
3#5020140 000
4
5
Готово

3

Type B2>0 in Logical1 and C2>0 in Logical2, then click OK.

Книга1 - Excel
—☐✕
D2fx
ABCDE
1ReceiptCashCardValid?
2#50185 0000
3#5020140 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”.

Книга1 - Excel
—☐✕
E2fx=ИСКЛИЛИ(A2;B2)
ABCDEF
1Condition 1Condition 2ANDORXOR
2ИСТИНАИСТИНАИСТИНАИСТИНАЛОЖЬ1
3ИСТИНАЛОЖЬЛОЖЬИСТИНАИСТИНА
4ЛОЖЬИСТИНАЛОЖЬИСТИНАИСТИНА
5ЛОЖЬЛОЖЬЛОЖЬЛОЖЬЛОЖЬ
6
Готово
XOR is TRUE only when the conditions differ

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.

Книга1 - Excel
—☐✕
D3fx=ЕСЛИ(ИСКЛИЛИ(ЕЧИСЛО(B3);ЕЧИСЛО(C3));"Incomplete";"OK")
ABCDE
1EmployeeInOutStatus
2Aziz09:0018:00OK
3Dilnoza09:30Incomplete
4JavohirOK
5Kamola17:30Incomplete
6
Готово
Dilnoza and Kamola are each missing one time. Javohir didn’t come — that’s not an incomplete record

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?

Книга1 - Excel
—☐✕
E4fx=ИСКЛИЛИ(B4>0;C4>0;D4>0)
ABCDEFG
1ReceiptCashCardClickXORExactly one
2#60190 00000ИСТИНАИСТИНА
3#60250 00040 0000ЛОЖЬЛОЖЬ
4#60330 00030 00030 000ИСТИНА1ЛОЖЬ
5
Готово
#603 was paid all three ways: XOR wrongly gives TRUE, while COUNTIF(...)=1 correctly gives FALSE

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)?

Книга1 - Excel
—☐✕
Буфер обмена
Шрифт
Выравнивание
Число
Стили
Ячейки
Редактирование
✕✓fx
ABCDEFGHIJKLMNOPQRSTUVWX
1ReceiptCashCardValid?
2#7011200000
3#7024500045000
4#7030310000
5#70400
6#705780000
7
8
9
10
Лист1
Готово

Has ExcelLab been useful?

Support the project and help us release new lessons and exercises.

Support us
Previous

82 / 154