The XOR function is a comparison function that returns a Boolean value after executing an Exclusive Or logic operation. It returns TRUE if specified arguments contain both TRUE and FALSE values. If all conditions are TRUE or all are FALSE, the return value is FALSE. In this guide, we’re going to show you how to use the XOR function and also go over some tips and error handling methods.


Supported versions

  • Excel 2013 and later

Syntax

XOR(logical1, [logical2], …)


Arguments

XOR(logical1, [logical2], …)



Examples

Example 1

=XOR(84>=100,78>=100)
formula tests each case, and returns FALSE, since both tests return FALSE in this example.

XOR-1

Example 2

=IF(XOR("FIRE, FLYING"="Fairy","I"="I",AVERAGE({78,84,78,109,85,100})>=100),"Pass","Fail")
returns Pass because the second test ("I"="I") returns TRUE and others return FALSE. Like the AVERAGE function, other functions can be combined with the XOR function.

XOR-2Download Workbook


Tips

  • Logical equations cheat sheet
CalculationReturns
TRUE XOR TRUEFALSE
TRUE XOR FALSETRUE
FALSE XOR FALSEFALSE
  • Use the XOR function in combination with other functions that use logical tests for parameters, like the IF function.
  • Combine with other logical functions (AND, OR, NOT) to generate even more complex scenarios.
  • Comparison operators:
OperatorDescriptionCriteria SampleCriteria Meaning
=Equal to“=10000”Equal to 10000
<> Not equal to“<>10000”Not equal to 10000
Greater than“>10000”Greater than 10000
Less than“>10000”Less than 10000
>=Greater than or equal to“>=10000”Greater than or equal to 10000
<=Less than or equal to“<=10000”Less than or equal to 10000

Issues

#VALUE!

The XOR function returns an #VALUE! error if an argument doesn't provide a Boolean value.

Empty cells

Empty cells are ignored by the function.