loading

XOR

Excel XOR Function

Excel has a built-in function called XOR that can return either TRUE or FALSE depending on two or more conditions.

Note: The IF function and the XOR function are frequently used in tandem.

It is typed =XOR:

				
					=XOR([logical1], [logical2], ...)
				
			

We refer to the criteria as [logical1], [logical2], and so on.

The parameters can verify items such as:

  • If a number is greater than another number >
  • If a number is smaller than another number <
  • If a number or text is equal to something =

The XOR function can be understood as “either this or that, but not both” for two conditions.

Note: A symbol, such as a , or ; is used to separate the various components of the function;

The symbol is determined by your language preferences.

Example XOR Function

Verify whether the Pokemon type is Fire or if its HP is less than 60, but not both:

“True” or “False” is returned by the function.

Xor -

Example XOR function, step by step:

  1. Select the cell D2
  2. Type =XOR
  3. Double click the XOR command
Xor -

4. Specify the first condition B2=”Fire”

5. Type ,

6. Specify the second condition C2<60

7. Hit enter

Note: Before pressing enter, repeat steps 5–6 to add more conditions.

If an odd number (1,3,5,..) of criteria are TRUE, the XOR function returns “TRUE”.

Xor -

Since “Fire” is not the value in cell B2, the first condition is FALSE.

Given that cell C2 is value is less than 60, the second condition is TRUE.

For the XOR function to return TRUE when there are two conditions, only one of the conditions needs to be TRUE.

Note: Text values must be encircled with quotes: ” “

To carry out the same check for every Pokemon, the function can be repeated using the filling function for every row:

Xor -

Now, each row contains a check for Fire Type or HP less than 60, but not both:

Xor -

For example:

  • Since the ivysaur is neither fire type not has less than 60 defense, the method returns “FALSE”.
  • The code returns “FALSE” since Charmeleon is of the Fire type and has less than 60 defense.
  • The function returns “TRUE” because Wartortle has less than 60 defense and is not of the Fire type.

Example XOR Function (with IF)

You may verify several conditions for the IF function by combining the XOR and IF functions:

Note: You can define the return values using the IF function.

Typed =IF, the IF function consists of three parts:

				
					=IF(logical_test, [value_if_true], [value_if_false])
				
			

The logical_test condition is replaced by the XOR function.

The IF function gives back “Yes” or “No” in this case.

Step-by-step example of using the XOR function as the condition for the IF function:

  1. Select cell C2
  2. Type =IF
  3. Double click the IF command
Xor -

4. Type XOR

5. Double click the XOR command

Xor -

7. Specify the first condition B2=”Fire”

8. Type ,

9. Specify the second condition C2<60

10. Type ),

11. Specify the value “Yes” for when just one condition is TRUE

12. Type ,

13. Specify the value “No” for when both are FALSE, or TRUE at the same time

14. Type ) and hit enter

Xor -

To carry out the same check for every Pokemon, the function can be repeated using the filling function for every row:

Xor -

A check for either Water Type or Defense greater than 60 is now present in each row, but not both:

Xor -

For example:

  • The code returns “No” since the ivysaur is neither fire type not has less than 60 defensive points.
  • As a Fire type with less than 60 defense, Charmeleon returns “No” from the function.
  • The code returns “Yes” since Wartortle has less than 60 defense and is not a Fire type.
Share this Doc

XOR

Or copy link

Explore Topic