WHAT DOES IF DO
The IF
function returns one value if a condition is true and another if it's false. It's commonly used to test logic — for example, whether a number is above a threshold or if a cell contains specific text.
WHEN TO USE IT
- You want to show different results based on a condition
- You're testing numbers, text, or logical outcomes
- You want to flag or classify data (e.g. Pass/Fail, Bonus/No Bonus)
FORMULA SYNTAX
IF(logical_test, value_if_true, value_if_false)
Argument | Description |
---|---|
logical_test | The condition you want to check (e.g. A1>10) |
value_if_true | What to return if the condition is true |
value_if_false | What to return if the condition is false |
EXAMPLE 1: CLASSIFYING PASS/FAIL
We want to show "Pass" if the score is above 60, and "Fail" otherwise.
A | B | |
---|---|---|
1 | Student | Score |
2 | Alice | 75 |
3 | Bob | 58 |
4 | Carol | 91 |
5 | David | 60 |
=IF(B2>60, "Pass", "Fail")
Result: Alice → Pass, Bob → Fail
EXAMPLE 2: APPLYING A BONUS ONLY IF SALES TARGET IS MET
We want to show a bonus of $1,000 if sales are >= 1000, and 0 otherwise.
A | B | |
---|---|---|
1 | Rep | Sales |
2 | John | 1200 |
3 | Jane | 900 |
4 | Raj | 1000 |
5 | Ana | 1100 |
=IF(B2>=1000, 1000, 0)
Result: John → 1000, Jane → 0, Raj → 1000
COMMON PITFALLS AND EDGE CASES
- Use
>
,<
,>=
, etc., for logical comparisons - Text values must be enclosed in quotes
- Make sure your logic expressions are valid or Excel will return an error
- You can nest multiple
IF
functions for complex logic (but this can get messy)
RELATED FUNCTIONS
FURTHER READING
Official Microsoft documentation:
IF – Microsoft Support