Pass or fail
| A | B | |
|---|---|---|
| 1 | Student | Score |
| 2 | Ana | 72 |
Formula: D2: =IF(B2>=70,"Pass","Fail")
Result: Pass
72 is at least 70, so the true branch is returned. Text results go in quotes.
Chooses between two outcomes based on a condition.
IF(logical_test, [value_if_true], [value_if_false])Example: =IF(B2>=60,"Pass","Fail")
Available in: All versions
IF tests a condition and returns one value when it is true and another when it is false: =IF(condition, value_if_true, value_if_false). It is the building block of almost every decision in a spreadsheet, such as pass or fail, late or on time, discount or none.
| A | B | |
|---|---|---|
| 1 | Student | Score |
| 2 | Ana | 72 |
Formula: D2: =IF(B2>=70,"Pass","Fail")
Result: Pass
72 is at least 70, so the true branch is returned. Text results go in quotes.
| A | B | |
|---|---|---|
| 1 | Student | Score |
| 2 | Ben | 84 |
Formula: D2: =IF(B2>=90,"A",IF(B2>=80,"B","C"))
Result: B
The second IF sits in the false branch of the first. For more than three outcomes prefer IFS.
| A | B | C | |
|---|---|---|---|
| 1 | Name | Age | Member |
| 2 | Cara | 21 | Yes |
Formula: E2: =IF(AND(B2>=18,C2="Yes"),"Eligible","Not eligible")
Result: Eligible
AND is true only when both tests are true. Use OR when one is enough.
A tiny spreadsheet with example data. Edit the formula or any number and see the result.
Formula in F2: =IF(B2>=60,"Pass","Fail")
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Student | Score | Extra credit | Attempts | Result | |
| 2 | Ann | 92 | Yes | 2 | Pass | |
| 3 | Bob | 74 | No | 0 | ||
| 4 | Cy | 58 | Yes | 3 | ||
| 5 | Dee | 81 | No | 1 | ||
| 6 | Eli | 66 | 2 |
Enter — commit · F2 — edit · F4 — $ in a reference · Ctrl+C/Ctrl+V — copy and paste · Ctrl+Z — undo
Esc or F6 — leave the sheet for the «Check» button · Shift+Tab in the first cell — back to the page