
Excel · Logic
Mastering IF, AND, and OR Conditions (Complete Practical Examples)
Eighty percent of a report depends on its conditional formulas. Master IF/AND/OR fundamentals, IFS, IFERROR, and SWITCH combinations, tiered calculations, grade calculations, and exception handling all at once.
Basic Syntax Summary
| Function | Syntax | Description |
|---|---|---|
| IF | =IF(condition, value_if_true, value_if_false) | Returns value_if_true when the condition is TRUE; otherwise returns value_if_false |
| AND | =AND(condition1, condition2, ...) | Returns TRUE only when all conditions are TRUE |
| OR | =OR(condition1, condition2, ...) | Returns TRUE when at least one condition is TRUE |
| IFS | =IFS(condition1, result1, condition2, result2, ...) | Returns the result for the first TRUE condition |
Single Condition – IF
Example 1) Pass/Fail
=IF(B2>=60, "Pass", "Fail")
Example 2) Handling Blank Cells
=IF(B2="", "", B2*1.1)
Skipping calculations when there is no input keeps the report clean.
Multiple Conditions – AND/OR
Example 3) Bonus Payment (tenure ≥3 years AND rating A)
=IF(AND(C2>=3, D2="A"), "Bonus Paid", "Not Eligible")
Example 4) Free Shipping (VIP status OR purchase amount ≥ 50,000)
=IF(OR(E2="VIP", F2>=50000), "Free Shipping", "Shipping Fee Charged")
- TIP Group conditions with AND/OR first rather than using complex nested IF statements for better readability and performance.
Improved Readability – IFS
Example 5) Score → Grade
=IFS(B2>=90,"A", B2>=80,"B", B2>=70,"C", B2>=60,"D", TRUE,"F")
TRUE,"F" serves as a default value. Adding it at the end covers all exceptions.
Example 6) Nested IF vs. IFS
| Method | Formula |
|---|---|
| Nested IF | =IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","D"))) |
| IFS | =IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"D") |
Tiered Calculations (Fees, Commissions, and Grades)
Example 7) Commission Rates by Sales Tier
| Sales (Cumulative) | Rate |
|---|---|
| 0 | 2% |
| 10,000,000 | 3% |
| 30,000,000 | 5% |
Keep it simple with LOOKUP:
=LOOKUP(H2, {0,10000000,30000000}, {0.02,0.03,0.05}) * H2
Example 8) Shipping Fee (Free for VIPs or purchases of 50,000 or more)
=IF(OR(G2="VIP", H2>=50000), 0, 3000)
Example 9) Shift Differential (Night Shift AND Weekend)
=IF(AND(I2="Night", WEEKDAY(J2,2)>=6), 15000, 0)
10 Common Patterns
- Whether text is included →
=IF(ISNUMBER(SEARCH("VIP",A2)),"Special Price","Regular") - Date range →
=IF(AND(A2>=DATE(2025,8,1), A2<=DATE(2025,8,31)),"August","Other") - Handling blanks/zeros →
=IF(A2="","",A2),=IF(A2=0,"-",A2) - Error safeguard →
=IFERROR(formula,"Check Required") - Boolean → number →
--(condition)orN(condition) - Map codes with SWITCH →
=SWITCH(K2,"A","Excellent","B","Average","C","Needs Improvement","Other") - Return multiple results (365) →
=IF(condition, range1, range2)(dynamic array) - Conditional formatting formula →
=AND($C2="Delayed",$D2>TODAY()) - Data validation rule → In Custom, use
=AND(A2>=0, A2<=100) - Shorten multiple OR conditions →
=ISNUMBER(MATCH(A2,{"Gold","VIP","Admin"},0))
Errors, Pitfalls, and Solutions
- Numbers stored as text vs. numbers → Convert with
VALUE()and check cell formatting - Date comparison failure → Use
DATE()and watch for regional-format mismatches - Whitespace characters → Clean up with
TRIM()andCLEAN() - Unreadable nesting → Refactor with IFS, LOOKUP, or tables
- Precedence mistakes → Use parentheses to clarify the intended logic so AND is evaluated before OR
Performance and Maintenance Tips
- Move conditions and thresholds into an Excel table → formulas only need references
- Avoid unnecessary full-column references (X:X); specify exact ranges
- When the same logic is used across multiple sheets, reuse it with defined names
- Documentation: Place a
Rules Summarytext box at the top of the worksheet
Summary
| Key Point | Checklist |
|---|---|
| Cover all conditional formulas with IF/AND/OR combinations | Make parentheses and precedence clear |
| Improve readability with IFS/LOOKUP | Use tables + LOOKUP for tiers and grades |
| Handle exceptions and errors first | Use IFERROR and blank-cell handling |
FAQ
My nested IF formula is too long. How can I shorten it?
Replace it with IFS, LOOKUP, or CHOOSE, and put the thresholds in a table to shorten the formula.
What is the precedence when mixing AND and OR?
Because AND tends to be evaluated before OR, use parentheses to make your intended logic clear: IF(OR(AND(...), AND(...)), ...)
My comparisons are incorrect because numbers and numbers stored as text are mixed.
Convert with VALUE() or standardize the format in the data source.