XOR


Computes the logic exclusive Or of all arguments

Syntax:

XOR(logicalOne, [logicalTwo],…)

The first logical value is required. The other logical values are optional. TRUE/FALSE, or arrays/references containing TRUE/FALSE values, are the only acceptable argument evaluations for the logical values.

XOR returns TRUE only when an odd number of its arguments are TRUE, otherwise returns FALSE.


Example:

If the arguments contain 1<4, 2<4 and 3<4:

XOR(1<4, 2<4, 3<4)

returns TRUE


If the arguments contain 1<4, 2<4 and 4<4:

XOR(1<4, 2<4, 4<4)

returns FALSE


logicalOne:


logicalTwo:


logicalThree:


Result:

TRUE

Application:

Identifying Customer Order Discrepancies


Imagine you run an e-commerce business, and you offer free shipping under two distinct conditions:

  1. The customer is a "Premium Member" OR
  2. The "Order Total" is greater than or equal to $100.


You want to use the XOR function to quickly identify orders where exactly one of these conditions is met for free shipping, but not both, or neither. This might be useful for auditing, special promotions, or identifying edge cases in your shipping logic.


Scenario: You want to find orders where a customer either received free shipping because they were a premium member or because their order was over $100, but not if they qualified under both conditions.


Here's a table demonstrating this:

Order ID

Customer Name

Premium Member

Order Total

Free Shipping Applied

XOR Condition Met (For Audit)

A
B
C
D
E
F
1
1001
Alice
TRUE
$75.00
TRUE
TRUE
2
1002
Bob
FALSE
$120.00
TRUE
TRUE
3
1003
Carol
TRUE
$150.00
TRUE
FALSE
4
1004
David
FALSE
$50.00
FALSE
FALSE
5
1005
Emily
TRUE
$100.00
TRUE
FALSE
6
1006
Frank
FALSE
$90.00
FALSE
FALSE
7
1007
Grace
TRUE
$95.00
TRUE
TRUE
8
1008
Henry
FALSE
$110.00
TRUE
TRUE

Explanation of the XOR Formula:

Let's assume:

  • "Premium Member" status is in Column C (TRUE/FALSE)
  • "Order Total ($)" is in Column D (numeric)


In cell F1 (for "XOR Condition Met"), you would enter the following formula:

XOR(C1, D1>=100)


How it works for each row:

  • Order 1001 (Alice): XOR(TRUE, 75>=100) -> XOR(TRUE, FALSE) = TRUE. (Alice is a Premium Member, but her order isn't over $100. Exactly one condition is true, so XOR is TRUE).
  • Order 1002 (Bob): XOR(FALSE, 120>=100) -> XOR(FALSE, TRUE) = TRUE. (Bob is not a Premium Member, but his order is over $100. Exactly one condition is true, so XOR is TRUE).
  • Order 1003 (Carol): XOR(TRUE, 150>=100) -> XOR(TRUE, TRUE) = FALSE. (Carol is a Premium Member AND her order is over $100. Both conditions are true, so XOR is FALSE).
  • Order 1004 (David): XOR(FALSE, 50>=100) -> XOR(FALSE, FALSE) = FALSE. (Neither condition is true, so XOR is FALSE).
  • Order 1005 (Emily): XOR(TRUE, 100>=100) -> XOR(TRUE, TRUE) = FALSE. (Emily is a Premium Member AND her order total is exactly $100, which meets the $100 condition. Both conditions are true, so XOR is FALSE).
  • Order 1006 (Frank): XOR(FALSE, 90>=100) -> XOR(FALSE, FALSE) = FALSE. (Frank is not a Premium Member, and his order is less than $100. Neither condition is true, so XOR is FALSE).
  • Order 1007 (Grace): XOR(TRUE, 95>=100) -> XOR(TRUE, FALSE) = TRUE. (Grace is a Premium Member, but her order is less than $100. Exactly one condition is true, so XOR is TRUE).
  • Order 1008 (Henry): XOR(FALSE, 110>=100) -> XOR(FALSE, TRUE) = TRUE. (Henry is not a Premium Member, but his order is over $100. Exactly one condition is true, so XOR is TRUE).




This page is protected by Google reCAPTCHA. Privacy - Terms.
 
Built using Zapof