The IF function is the foundation of logic in Excel. It checks whether a condition is true and returns one thing if it is, another if it isn't. Master IF and you unlock conditional logic across all your spreadsheets.
The syntax
=IF(logical_test, value_if_true, value_if_false)
- logical_test — a condition that evaluates to TRUE or FALSE.
- value_if_true — what to return when the condition is true.
- value_if_false — what to return when it's false.
Example — label sales as "Pass" or "Fail" based on hitting 100:
=IF(B2>=100, "Pass", "Fail")
Building the logical test
The condition uses comparison operators:
=equal to>greater than,<less than>=at least,<=at most<>not equal to
You can compare cells, numbers, or text: A2="Complete", B2>C2, D2<>0.
Returning different types
The true/false results can be text, numbers, or even other formulas:
=IF(B2>=100, B2*0.1, 0)
This returns a 10% bonus if sales hit 100, otherwise 0.
Text results need quotes; numbers and formulas don't.
Nesting IF statements
For more than two outcomes, you nest IFs — putting another IF in the false slot:
=IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C", "F")))
This checks each threshold in order. Read it left to right: if 90+, "A"; otherwise if 80+, "B"; otherwise if 70+, "C"; otherwise "F".
Watch the order. Nested IFs evaluate top to bottom, so put your conditions in the right sequence (usually highest to lowest, or most to least specific), or earlier conditions will catch values meant for later ones.
When nesting gets messy: use IFS
Deeply nested IFs become hard to read and easy to break. In Excel 2019 and later, the IFS function handles multiple conditions more cleanly:
=IFS(B2>=90, "A", B2>=80, "B", B2>=70, "C", TRUE, "F")
Each condition/result pair is listed in sequence, and TRUE at the end acts as the catch-all "otherwise."
Combining conditions with AND / OR
To require multiple conditions, combine IF with AND or OR:
=IF(AND(B2>=100, C2="East"), "Bonus", "No bonus")
AND is true only if all conditions are; OR is true if any are.
The takeaway
IF is simple on its own but combines endlessly — with AND, OR, nested IFs, or IFS for multiple outcomes. It's the logical backbone that most other conditional work in Excel builds on.