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], ...)
| Argument | Required? | What it is |
|---|---|---|
logical1 | Required | The first condition. |
logical2 | Optional | More 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.
| Cell | Formula | Result | What it shows |
|---|---|---|---|
| D2 | =XOR(B2="Yes",C2="Yes") | FALSE | Both are TRUE, so there is no mismatch: FALSE |
| D3 | =XOR(B3="Yes",C3="Yes") | TRUE | Shipped without tracking: exactly one is TRUE |
| D4 | =IF(XOR(B4="Yes",C4="Yes"),"Check","OK") | OK | Inside 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
| Order | Shipped | Has tracking | Result |
| K-210 | Yes | Yes | FALSE |
| K-211 | Yes | No | TRUE |
| K-212 | No | No | OK |
Practice XOR
Graded instantly, then re-checked on changed data.
Discount rule check
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 see | Why, and how to fix it |
|---|---|
| Expecting "exactly one" with three conditions | With 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 meant | OR 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.