Spreadsheet Practice

XOR function

XOR returns TRUE when an odd number of its conditions are TRUE. With two conditions that means "one or the other, but not both", which is useful for spotting records that disagree with themselves: an order marked shipped with no tracking number, or a discount on an order too small to qualify.

Available in
Excel 2013 and later
Category
Logical functions
Returns
TRUE if an odd number of arguments are TRUE, otherwise FALSE.
Google Sheets
Available in Google Sheets.

Syntax

=XOR(logical1, [logical2], ...)

ArgumentRequired?What it is
logical1RequiredThe first condition.
logical2OptionalMore conditions, up to 254 in total.

Examples

Each result below is calculated from the sample sheet by our formula engine, the same one that grades the practice.

CellFormulaResultWhat it shows
D2=XOR(B2="Yes",C2="Yes")FALSEBoth are TRUE, so there is no mismatch: FALSE
D3=XOR(B3="Yes",C3="Yes")TRUEShipped without tracking: exactly one is TRUE
D4=IF(XOR(B4="Yes",C4="Yes"),"Check","OK")OKInside IF to label the row

Try it live

This is the sample sheet. Change any number or text, or edit a formula, and the results update.

Show the sample data as a table
OrderShippedHas trackingResult
K-210YesYesFALSE
K-211YesNoTRUE
K-212NoNoOK

Practice XOR

Graded instantly, then re-checked on changed data.

Discount rule check

Orders of $500 or more should get a discount and smaller orders should not. In D2, return TRUE when a row breaks that rule: the amount is at least 500 or the discount is above 0, but not both. Fill down to D7.

Common mistakes

What you seeWhy, and how to fix it
Expecting "exactly one" with three conditionsWith three conditions XOR is TRUE when one or all three are TRUE. To require exactly one, count them: =(B2="Yes")+(C2="Yes")+(D2="Yes")=1.
Using XOR where OR is meantOR is TRUE when both conditions are TRUE; XOR is FALSE in that case. Use XOR only when "both" should count as a problem.
#NAME?XOR arrived in Excel 2013. In older versions, compare the two tests directly: =(B2="Yes")<>(C2="Yes").

Tips

  • For two conditions, XOR(a,b) gives the same answer as a<>b.

Questions

What does XOR mean in Excel?

Exclusive OR: TRUE when one condition is TRUE but not both. With more than two conditions it is TRUE when an odd number of them are TRUE.

What is the difference between OR and XOR?

OR is TRUE if any condition is TRUE, including all of them. XOR is FALSE when both of two conditions are TRUE.

Last reviewed October 2026. Every example result on this page is calculated live by the Spreadsheet Practice formula engine.