Excel XOR Function
The excel XOR function performs “exclusive OR” of all arguments. The XOR function has two logical statements, and it returns returns TRUE if either statement is TRUE. It returns FALSE if both statements are TRUE. If none is TRUE, XOR also returns FALSE.
In this section:
- Syntax of XOR function
- Create started and finished exam with XOR
- Create employee IN/OUT with XOR function
- One or more conditions with XOR function
1. Syntax of XOR function:
XOR(logical1, [logical2],…)
where:
- logical 1: A logical expression, constant, or reference that evaluates to either TRUE or FALSE.
- logical 2: Same as logical 1, and it is optional.
2. Create started or finish exam:
To create started and finished exam, users need to combine XOR function with IF. Let’s think about a student’s starting and finishing exam. John will start at 8:00 AM and finish the exam at 2:00 PM. Now, the name John is present in the list twice. The first one (1) is for starting, and the second one (2) is for finishing. The odd number of presence means starting, and the even number of presence means finishing. For starting (1), the excel XOR function will return “TRUE“. In the example below, the formula is =IF(XOR(C6=C$6:C6), “Started”, “Finished”), which returns started if the student name is first time present.
The formula for:
Count =COUNTIF(C$6:C6, C6)
Odd: =ISODD(COUNTIF(C$6:C6, C6))
3. Employee IN/OUT with XOR function:
Applying the same logic, we can create employee IN/OUT. For odd number of presence of a name, XOR returns IN, and for even number of presence XOR returns OUT. In the example below, the formula is
4. One/More conditions with XOR function:
For one or more conditions, users need to remember the following information:
- For a single argument, if the result is TRUE, XOR returns TRUE.
- For two arguments, if the results is TRUE, XOR returns TRUE.
- For more than two arguments, ODD number are true, then TRUE.
More readings:
I appreciate, cause I found exactly what I was looking for. You’ve ended my four day long hunt! God Bless you man. Have a great day. Bye