# XOR Function in Excel

Part 1. Introduce:

ðŸ”¹ Definition: The XOR function in Microsoft Excel is a logical function for “exclusive OR.” It checks whether one and only one condition among multiple conditions is TRUE. If precisely one condition is TRUE, the XOR function returns TRUE; otherwise, it returns FALSE.

ðŸ”¹ Purpose: The XOR function is helpful in scenarios where you want to evaluate multiple conditions and determine if precisely one is true. It provides a way to create logical expressions that exclude cases where all conditions are TRUE or FALSE.

ðŸ”¹ Syntax & Arguments: The syntax of the XOR function is as follows:

syntax
`=XOR(logical1, [logical2], ...) `
• `logical1` (required): The first condition to evaluate.
• `logical2`, … (optional): Additional conditions to evaluate. You can include up to 254 logical arguments.

ðŸ”¹ Explain the Arguments in the Function: The XOR function takes one or more logical arguments (TRUE or FALSE) and evaluates if precisely one of them is TRUE. It allows you to test multiple conditions and return a single TRUE or FALSE result based on the exclusivity of the conditions.

ðŸ”¹ Return Value: The XOR function returns TRUE if precisely one of the provided conditions is TRUE. If no conditions are TRUE or more than one is TRUE, it returns FALSE.

ðŸ”¹ Remarks:

• If there is only one argument, the XOR function returns the value of that argument.
• WHEN EVALUATING CONDITIONS, the XOR function considers any non-zero numeric value as TRUE and zero as FALSE.

Part 2. Examples:

ðŸ”¹ Example 1: Checking Exclusive Sales Promotion Eligibility

ABCD
EmployeePurchase APurchase BEligible for Promotion
2JohnTRUEFALSE=XOR(B2, C2)
3JaneFALSETRUE=XOR(B3, C3)
4MarkTRUETRUE=XOR(B4, C4)

Explanation: In this example, we use the XOR function to check the eligibility of employees for an exclusive sales promotion. The XOR function evaluates whether an employee has made purchases of either “Purchase A” or “Purchase B” exclusively. If the employee has made exactly one purchase (not both or none), the XOR function returns TRUE.

ðŸ”¹ Example 2: Evaluating Exclusive Criteria in Employee Evaluation

ABCDEF
Employee NamePunctualityProductivityCommunicationTeam PlayerSatisfactory Evaluation
2SarahTRUEFALSETRUEFALSE=XOR(B2:F2)
3MichaelTRUETRUEFALSETRUE=XOR(B3:F3)
4AlexFALSEFALSETRUEFALSE=XOR(B4:F4)

Explanation: In this example, we use the XOR function to evaluate the performance of employees based on specific criteria (Punctuality, Productivity, Communication, Team Player). The XOR function determines if each employee satisfies exactly one of the criteria (not all or none). If an employee meets exactly one criterion, the XOR function returns TRUE.

ðŸ”¹ Example 3: Validating Unique Product Codes

ABCD
Product CodeSKU ASKU BValid Product Code
2XYZ-123TRUEFALSE=XOR(EXACT(A2,B2), EXACT(A2,C2))
3ABC-987FALSETRUE=XOR(EXACT(A3,B3), EXACT(A3,C3))
4XYZ-123TRUETRUE=XOR(EXACT(A4,B4), EXACT(A4,C4))

Explanation: In this example, we use the XOR and EXACT functions to validate unique product codes (SKU) in two different SKU columns. The XOR function evaluates if a product code matches SKU A or B exclusively. If the product code matches with only one SKU (not both or none), the XOR function returns TRUE.

ðŸ”¹ Example 4: Attendance Tracker

ABCD
Student IDAbsent 1Absent 2Attendance Status
2STU-001TRUEFALSE=IF(XOR(B2, C2), “Present”, “Absent”)
3STU-002FALSETRUE=IF(XOR(B3, C3), “Present”, “Absent”)
4STU-003TRUETRUE=IF(XOR(B4, C4), “Present”, “Absent”)

Explanation: In this example, we use the XOR function with the IF function to track student attendance. Each student’s attendance is recorded for two sessions, represented by columns B and C. Column D uses the XOR function to determine if the student attended only one of the sessions, and the IF function displays “Present” for TRUE (treated) and “Absent” for FALSE (not participated).

ðŸ”¹ Example 5: Product Inventory

ABCD
Product IDIn StockDeliveredStock Status
2PROD-0015030=IF(XOR(B2>C2, B2<50), “Low”, “Normal”)
3PROD-0022025=IF(XOR(B3>C3, B3<50), “Low”, “Normal”)
4PROD-0034545=IF(XOR(B4>C4, B4<50), “Low”, “Normal”)

Explanation: In this example, we use the XOR function with the IF function to check the stock status of products. Column B represents the quantity of products in stock, and column C represents the quantity delivered. Column D uses the XOR function to determine if the product’s supply is below 50 (low stock) but more significant than the given quantity, and the IF function displays “Low” if TRUE or “Normal” if FALSE.

ABCD
2STU-0018090=IF(XOR(B2>=90, C2>=90), “A”, IF(XOR(B2>=80, C2>=80), “B”, “C”))
3STU-0027085=IF(XOR(B3>=90, C3>=90), “A”, IF(XOR(B3>=80, C3>=80), “B”, “C”))
4STU-0039575=IF(XOR(B4>=90, C4>=90), “A”, IF(XOR(B4>=80, C4>=80), “B”, “C”))

Explanation: In this example, we use the XOR and IF functions to grade students based on their scores. Column B represents the first score, and column C represents the second score. Column D uses the XOR function to check if at least one of the scores is above or equal to 90 (A grade). If not, it fits if at least one score is above or similar to 80 (B grade). If neither condition is met, the grade is “C”.

ðŸ”¹ Example 7: Employee Performance

ABCD
Employee IDEvaluation 1Evaluation 2Performance
2EMP-0014.53.8=IF(XOR(B2>4.0, C2>4.0), “High”, IF(XOR(B2>3.5, C2>3.5), “Medium”, “Low”))
3EMP-0023.94.1=IF(XOR(B3>4.0, C3>4.0), “High”, IF(XOR(B3>3.5, C3>3.5), “Medium”, “Low”))
4EMP-0033.23.0=IF(XOR(B4>4.0, C4>4.0), “High”, IF(XOR(B4>3.5, C4>3.5), “Medium”, “Low”))

Explanation: In this example, we use the XOR function with the IF function to evaluate employee performance. Column B represents the first evaluation score, and column C represents the second evaluation score. Column D uses the XOR function to check if at least one of the scores is more significant than 4.0 (High performance). If not, it fits if at least one score exceeds 3.5 (Medium version). If neither condition is met, the arrangement is considered “Low”.

ðŸ”¹ Example 8: Project Status

ABCD
Project IDCompletion 1Completion 2Status
2PROJ-00170%80%=IF(XOR(B2>=100, C2>=100), “Completed”, IF(XOR(B2>=80, C2>=80), “On Track”, “Delayed”))
3PROJ-00250%60%=IF(XOR(B3>=100, C3>=100), “Completed”, IF(XOR(B3>=80, C3>=80), “On Track”, “Delayed”))
4PROJ-00390%95%=IF(XOR(B4>=100, C4>=100), “Completed”, IF(XOR(B4>=80, C4>=80), “On Track”, “Delayed”))

Explanation: In this example, we use the XOR function with the IF function to determine the status of projects based on their completion percentage. Column B represents the first completion percentage, and column C represents the second completion percentage. Column D uses the XOR function to check if at least one of the percentages is 100% or above (Completed). If not, it fits if at least one percentage is 80% or above (On Track). If neither condition is met, the project is considered “Delayed”.

ðŸ”¹ Example 9: Team Performance Bonus

ABCDE
Team IDMember 1 ScoreMember 2 ScoreMember 3 ScoreBonus
2TEAM-001959085=IF(XOR(AVERAGE(B2:D2) >= 90, AND(B2>=80, C2>=80, D2>=80)), 500, 0)
3TEAM-002807075=IF(XOR(AVERAGE(B3:D3) >= 90, AND(B3>=80, C3>=80, D3>=80)), 500, 0)
4TEAM-003858580=IF(XOR(AVERAGE(B4:D4) >= 90, AND(B4>=80, C4>=80, D4>=80)), 500, 0)

Explanation: In this example, we use the XOR function with the IF function to calculate team performance bonuses. Columns B, C, and D represent the scores of three team members. Column E uses the XOR function to check if the team’s average score is 90 or above and if each member’s score is 80 or above. If both conditions are met, the team is eligible for a bonus of \$500; otherwise, no compensation is given.

ðŸ”¹ Example 10: Payment Approval

ABCDE
Invoice IDAmountApproved?ReasonApproval Status
2INV-001\$1,000TRUE“N/A”=IF(XOR(B2>500, C2), “Approved”, “Rejected: ” & D2)
3INV-002\$800FALSE“Incomplete documentation”=IF(XOR(B3>500, C3), “Approved”, “Rejected: ” & D3)
4INV-003\$750TRUE“N/A”=IF(XOR(B4>500, C4), “Approved”, “Rejected: ” & D4)

Explanation: In this example, we use the XOR function with the IF function to approve invoice payments. Column B represents the invoice amount, column C represents whether the invoice is approved, and column D provides a reason for rejection if applicable. Column E uses the XOR function to check if the invoice amount is more significant than \$500 and if it is approved. If both conditions are met, the invoice is approved; otherwise, it is rejected, and the reason for rejection is provided.

ðŸ”¹ Example 11: Stock Investment

ABCDE
Stock IDPurchase PriceCurrent PriceProfit/LossDecision
2STOCK-001\$50\$70=IF(XOR(C2>B2, (C2-B2)/B2>=0.2), “Sell”, “Hold”)
3STOCK-002\$30\$25=IF(XOR(C3>B3, (C3-B3)/B3>=0.2), “Sell”, “Hold”)
4STOCK-003\$80\$90=IF(XOR(C4>B4, (C4-B4)/B4>=0.2), “Sell”, “Hold”)

Explanation: In this example, we use the XOR function with the IF function to decide whether to sell a stock investment. Column B represents the purchase price, and column C represents the current price. Column D calculates the profit/loss percentage. Column E uses the XOR function to check if the current price is higher than the purchase price and if the profit/loss percentage is at least 20%. If both conditions are met, it suggests “Sell”; otherwise, it recommends “Hold.”

ðŸ”¹ Example 12: Customer Subscription

ABCDE
Customer IDSubscription StartSubscription EndRenewal DateSubscription Status
2CUST-0012023-01-012023-12-31=IF(XOR(TODAY()>=B2, TODAY()<=C2, TODAY()<=D2), “Active”, “Expired”)
3CUST-0022023-02-152023-06-30=IF(XOR(TODAY()>=B3, TODAY()<=C3, TODAY()<=D3), “Active”, “Expired”)
4CUST-0032023-03-202023-03-25=IF(XOR(TODAY()>=B4, TODAY()<=C4, TODAY()<=D4), “Active”, “Expired”)

Explanation: In this example, we use the XOR function with the IF function to check the subscription status of customers. Columns B and C represent the subscription start and end dates, and column D indicates the renewal date. The XOR function checks if today’s date is within the subscription period or before renewal. If either condition is met, the subscription status is “Active”; otherwise, it is “Expired.”

These examples demonstrate how the XOR function can be combined with various other functions to make conditional calculations based on different scenarios in Excel. Remember to use the correct syntax and arguments for each function to ensure accurate results.

Part 3. Tips and Tricks:

• The XOR function is handy when ensuring exclusivity between multiple conditions.
• Combine the XOR function with other logical functions (such as AND, OR) to build complex logical expressions that match your specific requirements.
• When using the XOR function with text values, consider using the EXACT function to compare text case-sensitively and avoid unexpected results.