XOR Function

Returns TRUE when an odd number of conditions are TRUE — with two, that means exactly one.

Category

Logical

Available in

Excel 2013+, Microsoft 365

Returns

TRUE or FALSE

Want to practice XOR in a real spreadsheet? Open a blank sheet in our Practice Sandbox and try it with live data, with the AI Excel tutor beside you. No Excel needed — just a free account.Try it free in the Sandbox

Overview

XOR stands for “exclusive or”. With two conditions it returns TRUE when one or the other is TRUE, but not both.

It's useful for catching rows where two options should never both be chosen — or where at least one must be.

Syntax

=XOR(logical1, [logical2], …)

Arguments

ArgumentRequired?What it does
logical1YesThe first condition.
logical2, …OptionalUp to 254 more conditions.

Examples

Example 1 — Exactly one discount

Customers may use a coupon or a loyalty discount, but not both.

D2fx=XOR(B2="Yes", C2="Yes")
ABCD
1OrderCouponLoyaltyValid?
22001YesNoTRUE
32002YesYesFALSE
42003NoNoFALSE
52004NoYesTRUE
=XOR(B2="Yes", C2="Yes") Explain

Example 2 — Flagging the problem rows

Label the orders that break the rule.

=IF(XOR(B2="Yes", C2="Yes"), "", "Check discounts") Explain

Common mistakes

  • Three or more conditions. XOR counts TRUEs and returns TRUE for an odd count — so three TRUEs gives TRUE. For “exactly one of many”, use =SUM(--(B2:E2="Yes"))=1.

Notes

Kyle Stott

Author

Kyle Stott

Certified Microsoft Excel Expert

Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.