Logical Branching & Multi-Tier Rules: IF, IFS, AND, OR, XOR
Overview & Learning Objectives
Logical formulas let your spreadsheet make decisions automatically. If an order exceeds ₹1,000, apply a 15% discount; otherwise, apply 5%. We combine IF, IFS, AND, OR, and XOR to handle multi-tiered business logic with complete accuracy.
- Write clear IF statements with condition, value_if_true, and value_if_false.
- Use modern IFS to replace messy, deeply nested IF statements.
- Combine conditions with AND (all must match) and OR (at least one matches).
- Deploy XOR for mutually exclusive business promo rules.
Industry Standard
Standard: Business rules engines, commission structures, and credit scoring pipelines in banks and FinTechs are built on structured logical branching formulas.
Real-World Example: Pizza Hub Order Discounts & Priority Flags
At Pizza Hub, delivery orders over ₹800 get "Free Delivery", orders between ₹400 and ₹800 pay ₹40, and orders under ₹400 pay ₹60. Plus, VIP members get special perks. Logical formulas automate this calculation instantly for every customer bill.
| Order ID | Order Value (₹) | Customer VIP? | Promo Code A? | Promo Code B? |
|---|---|---|---|---|
| PZ-101 | 950 | No | Yes | No |
| PZ-102 | 520 | No | No | No |
| PZ-103 | 310 | No | Yes | Yes |
| PZ-104 | 350 | Yes (VIP) | No | Yes |
Functions Covered in this Chapter
Here is the definition, exact syntax, parameter breakdown, and real-world business example for each function covered in this chapter:
IF Function
Definition: Evaluates a condition and returns one specified value if the condition is TRUE, and another specified value if it is FALSE.
=IF(logical_test, value_if_true, [value_if_false])
logical_test: The comparison or condition to check (e.g. `B2 >= 500` or `C2 = "Yes"`).value_if_true: The value, text, or formula returned when the condition is TRUE.[value_if_false]: The value returned when the condition is FALSE. If omitted, Excel displays FALSE.
=IF(B2>=500, "Free Garlic Bread", "No Freebie")IFS Function
Definition: Evaluates multiple conditions sequentially without nesting multiple parentheses, returning the value for the first condition that evaluates to TRUE.
=IFS(logical_test1, value_if_true1, [logical_test2, value_if_true2], ..., [TRUE, default_value])
logical_test1, value_if_true1: First condition and its corresponding result if TRUE.logical_test2, value_if_true2: Second condition checked only if condition 1 was FALSE.TRUE, default_value: Catch-all fallback placed at the end; executes if no previous condition was met.
=IFS(B2>=800, 0, B2>=400, 40, TRUE, 60)AND Function
Definition: Logical operator that evaluates up to 255 conditions and returns TRUE only if ALL conditions are TRUE. If any condition is FALSE, it returns FALSE.
=AND(logical1, [logical2], ...)
logical1: First condition to evaluate.[logical2], ...: Additional conditions that must also be TRUE.
=IF(AND(B2>=800, C2="Yes (VIP)"), B2*0.15, 0)OR Function
Definition: Logical operator that evaluates conditions and returns TRUE if AT LEAST ONE condition is TRUE. Returns FALSE only when all conditions are FALSE.
=OR(logical1, [logical2], ...)
logical1: First condition to evaluate.[logical2], ...: Additional conditions to evaluate.
=IF(OR(B2>=800, C2="Yes (VIP)"), "Free Express Delivery", "Standard Delivery")XOR Function
Definition: Exclusive OR operator that returns TRUE if an ODD number of conditions are TRUE. For two conditions, it returns TRUE if exactly ONE is TRUE, and FALSE if both or neither are TRUE.
=XOR(logical1, [logical2], ...)
logical1, logical2: Conditions being evaluated for mutual exclusivity.
=IF(XOR(D2="Yes", E2="Yes"), 50, 0)Common Mistakes & Limitations
- Nesting 7 messy IF statements instead of using the modern, clean `IFS` or `SWITCH` function.
- Checking conditions in the wrong order in IFS (e.g. checking `>= 400` before `>= 800` intercepts the 800 orders first).
- Forgetting quotes around text criteria (e.g. writing `C2=Yes` instead of `C2="Yes"`), which causes `#NAME?` error.
Keyboard Shortcuts
| Action | Windows | Mac |
|---|---|---|
| Evaluate Formula Step-by-Step | Alt + M + V | Formulas Ribbon |
| Calculate Highlighted Portion | F9 inside formula bar | F9 |
| Exit Formula Bar without Saving | Esc | Esc |
Pro Tips & Modern Alternatives
- Use `SWITCH()` when checking a single cell against a list of exact matches (e.g. Day 1 -> Monday, Day 2 -> Tuesday).
- Use Boolean multiplication `=(B2>=800)*40` to perform conditional logic without IF functions.