Back to Functions

XOR

The XOR function performs an exclusive or of 2 numbers that returns a 1 if the numbers are different, and a 0 otherwise.

LogicalXOR(logical_expression1, [logical_expression2, ...])

The XOR function in Google Sheets performs a logical exclusive or across two or more expressions, returning TRUE if an odd number of the arguments are true, and FALSE otherwise. It's a less common but powerful complement to AND and OR for building precise conditional logic. Dive into our comprehensive guide to master its application.

Parameters

  • logical_expression1: The first logical expression or value to evaluate.
  • [logical_expression2, ...]: [Optional] Additional logical expressions or values to evaluate.

Step-by-Step Tutorial

  1. Using XOR with two conditions:

    • Example: =XOR(TRUE, FALSE)
    • Result: TRUE
  2. Using XOR with two true conditions:

    • Example: =XOR(A1>10, A1<20) where A1 is 15
    • Result: FALSE (both conditions are true, so they cancel out)

Working with a Single Value, a List, and a Range

XOR accepts logical expressions one at a time, as a comma-separated list, or as a range — mix and match freely.

  • Single value: =XOR(A1) — returns TRUE if A1 is TRUE, FALSE otherwise.
  • List of values: =XOR(A1, A2, A3) — evaluates each cell individually and returns TRUE if an odd number of them are TRUE.
  • Range: =XOR(A1:A3) — evaluates every cell in the range and returns TRUE if an odd number of them are TRUE. If A1:A3 holds TRUE, TRUE, TRUE, the result is TRUE (three, an odd count, are true).
  • Mixed: =XOR(A1, A3:A6) — you can combine single cells and ranges in one call.

Use Cases and Scenarios

  1. Conditional Logic: Trigger an action only when exactly one of two conditions is met, not both.
  2. Data Validation: Flag records where exactly one of two required fields is filled in, but not both.
  3. Game Logic: Build toggle-style logic, such as determining a winner when exactly one of two criteria is satisfied.

Related Functions

  • AND: Returns TRUE if all supplied logical expressions are true.
  • OR: Returns TRUE if any of the supplied logical expressions are true.
  • IF: Returns one value if a logical expression is true and another if false.

Related Articles

Newsletter

More XOR examples coming soon.

We are building short, practical updates for Sheets power users.