Logical
XOR function: enforce mutually exclusive "either A or B, not both" rules
Validate two-way exclusive choices with XOR—and avoid the 3-condition odd-parity trap when checking 3+ columns.
Two conditions: TRUE when exactly one condition holds
Standard OR returns TRUE when both promos are entered. For two conditions, XOR(logical1, logical2) returns TRUE when one is TRUE and the other is FALSE, and returns FALSE when both are FALSE or both are TRUE.
That makes XOR ideal for validating checkout rules like "Apply Promo Code OR Loyalty Credit, not both", or checking that either Debit or Credit (never both) is non-zero on a journal line.
| Order (A) | PromoAmt (B) | LoyaltyAmt (C) | XOR(B>0, C>0) |
|---|---|---|---|
| ORD-1 | 15 | 0 | TRUE (valid single discount) |
| ORD-2 | 15 | 10 | FALSE (both stacked — block) |
| ORD-3 | 0 | 0 | FALSE (no discount) |
Validate exclusive journal or promo entries
XOR(B2>0, C2>0) returns TRUE for ORD-1 (15 and 0), and FALSE for ORD-2 (15 and 10).
=XOR(B2>0, C2>0)The 3+ argument trap: XOR tests odd parity, not "only one"
With three or more arguments, XOR returns TRUE whenever an ODD number of inputs are TRUE—so XOR(TRUE, TRUE, TRUE) evaluates to TRUE! To enforce "strictly 1 of 3+", sum boolean flags with (N(c1)+N(c2)+N(c3))=1 instead.
=XOR(TRUE, TRUE, TRUE)Try the example
Use the original values or change them to test your understanding.