The IF function returns one value if a condition is true and another if it's false. This guide explains how IF works and includes practical examples you can use immediately.
WHAT THE IF FUNCTION DOES
IF evaluates a logical condition and returns different results based on whether that condition is true or false. It's commonly used to test numbers against thresholds, check if cells contain specific text, or classify data based on criteria.
WHEN TO USE IF
Use IF when you want to:
- Show different results based on a condition
- Test numbers, text, or logical outcomes
- 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
Need help applying this? Try this in Numstro Builder
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
Need help applying this? Try this in Numstro Builder
COMMON MISTAKES & 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
IFfunctions for complex logic (but this can get messy)
RELATED FUNCTIONS
FURTHER READING
Official Microsoft documentation:
IF — Microsoft Support