Excel function guide · Logic
IF function in Excel
IF checks whether a condition is true and returns one value if it is and another if it isn't, for example "Hit" when sales reach the target and "Miss" when they don't. Either result can be text, a number or another calculation.
Syntax
=IF(logical_test, value_if_true, [value_if_false])
| Argument | Required? | What it means |
|---|---|---|
| logical_test | Required | A comparison that is TRUE or FALSE, such as C2>=B2. |
| value_if_true | Required | What to return when the test is TRUE: text in quotes, a number, a cell or a formula. |
| value_if_false | Optional | What to return when the test is FALSE. Left out, IF returns FALSE. |
IF examples
Every example uses this small table. The results are what Excel shows in the cell.
| A | B | C | |
|---|---|---|---|
| 1 | Rep | Target | Sales |
| 2 | Aisha | 20,000 | 23,500 |
| 3 | Marco | 18,000 | 16,200 |
| 4 | Priya | 22,000 | 22,000 |
| 5 | Jonas | 15,000 | 17,900 |
| 6 | Lena | 25,000 | 21,000 |
1. Label a result
=IF(C2>=B2, "Hit", "Miss")
Result: Hit
Aisha's 23,500 is at least her 20,000 target.
2. Calculate in a branch
=IF(C2>=B2, (C2-B2)*0.1, 0)
Result: 350
A bonus of 10% of the amount above target, or 0 if the target was missed: (23,500 − 20,000) × 0.1.
3. > versus >=
=IF(C4>B4, "Hit", "Miss")
Result: Miss
Priya sold exactly her 22,000 target, but > means strictly greater. Use >= when meeting the target counts.
Try it now
Practise IF in a live sheet.
Type each formula yourself. Answers are checked by the same engine as the full course. No account needed.
Step 1 of 3
In D2, show Hit if Sales are at least the Target, otherwise Miss.
Common IF mistakes
Text without quotes
=IF(C2>=B2, Hit, Miss) returns #NAME? because Excel reads Hit as a name. Text results need quotes: "Hit".
> when you mean >=
Decide whether the boundary counts. A rep who exactly meets the target is a Miss with > and a Hit with >=.
Numbers in quotes
=IF(C2>"20000", …) compares with text, not the number. Leave numbers unquoted, or better, point at a cell.
Leaving out value_if_false
=IF(C2>=B2, "Hit") shows FALSE for every miss. Give both results, even if one is "" or 0.
Deeply nested IFs
More than two or three nested IFs are hard to read and easy to break. Use IFS, or a lookup table with XLOOKUP.
Practise this in Excel Quest
IF: hit or missFree
Course 4 · Logic & Error Handling · 10 min
Make formulas decide: target status, bonuses, shortfalls and next steps for a sales team.
This lesson is free: create an account and it opens straight away.