# The IF function (Excel lesson 5 of 45)

> IF asks a yes-or-no question and returns one of two answers.

Source: https://spreadsheetpractice.com/learn/if-function · Updated October 29, 2026

- **Course:** [Excel course](https://spreadsheetpractice.com/learn), track "Logic & conditions"
- **Time:** about 7 minutes, 2 graded exercises
- **Functions:** `IF`
- **Access:** free
- **Key formula:** `=IF(B2>=70,"Pass","Fail")`: Text answers

## How it works

`=IF(test, value_if_true, value_if_false)`. The test compares something with `=`, `<>`, `>`, `<`, `>=` or `<=`.

Text answers go in double quotes; numbers don't. Answers can be calculations too: pay a bonus of `B2*5%` or 0.

## Syntax

| Formula | What it does |
|---|---|
| `=IF(B2>=70,"Pass","Fail")` | Text answers |
| `=IF(C2="Yes",B2*0.1,0)` | Calculated answer |
| `=IF(B2>=$F$2,B2*$F$3,0)` | Rules in input cells |

## Watch out for

- Text in a test needs quotes: C2="Yes". Without them you get #NAME?.
- Check the boundary: does exactly 70 pass? That decides > versus >=.

## The exercises

Solve them in the live grid at [The IF function](https://spreadsheetpractice.com/learn/if-function). Each answer is graded, then re-checked on changed data so typed-in numbers don't pass.

1. **Pass or fail.** In C2, show Pass if the score is 70 or higher, otherwise Fail. Fill down to C7.
2. **Bonus calculator.** In C2, pay a bonus of sales × the rate in F3 if sales meet the target in F2; otherwise 0. Fill down to C6.

Previous: [Percentages & growth](https://spreadsheetpractice.com/learn/percentages-and-growth) · Next: [AND, OR & IFS](https://spreadsheetpractice.com/learn/and-or-ifs)

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
