Published on 2025-12-08T00:02:25+08:00
IF Function: Logical Tests and Nested IFs
IF Function: Logical Tests and Nested IFs
Basic IF Syntax
=IF(logical_test, value_if_true, value_if_false)
Simple Examples
=IF(A1>100, "High", "Low")=IF(B1="Yes", 1, 0)=IF(C1>=60, "Pass", "Fail")
Nested IF
For multiple conditions:
=IF(A1>=90, "A", IF(A1>=80, "B", IF(A1>=70, "C", "F")))
IFS Function (Modern Alternative)
=IFS(A1>=90, "A", A1>=80, "B", A1>=70, "C", TRUE, "F")
Combining with AND/OR
=IF(AND(A1>10, B1>10), "Both high", "Not both")=IF(OR(A1="Red", A1="Blue"), "Primary", "Other")
SWITCH Function
For matching specific values:
=SWITCH(A1, 1, "One", 2, "Two", 3, "Three", "Other")
Best Practices
- Avoid deeply nested IFs (max 3-4 levels)
- Use IFS for multiple conditions
- Use SWITCH for value matching
- Consider lookup tables for complex logic
Conclusion
IF is fundamental, but explore IFS and SWITCH for cleaner, more maintainable formulas.
Share this article
Related Posts
Master the TEXT function to format numbers, dates, and times exactly how you want them displayed in Excel.
2025-12-08T00:02:25+08:00
Learn to use Excel IF function for logical tests, create nested IF statements, and use modern alternatives like IFS and SWITCH.
2025-12-08T00:02:25+08:00
Master conditional summing in Excel with SUMIF for single criteria and SUMIFS for multiple criteria calculations.
2025-12-08T00:02:25+08:00