Excel functions / Logical
IF
Returns one value if a condition is true and another if it is false.
Syntax
=IF(logical_test, value_if_true, value_if_false)Arguments
logical_test | A comparison that is TRUE or FALSE, such as B2>=50. |
|---|---|
value_if_true | What to show when the test is TRUE. |
value_if_false | What to show when it is FALSE. |
How it works
IF lets a spreadsheet make decisions: Pass or Fail, Paid or Overdue, a bonus or nothing. It checks the test and returns one of the two values.
Text results go in double quotes. The results can be numbers or formulas too: =IF(C2>1000,C2*0.1,0) pays a 10% bonus on sales over 1,000.
Example
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Student | Score | Attended | ||
| 2 | Ana | 72 | Yes | Pass | |
| 3 | Ben | 45 | Yes | ||
| 4 | Cal | 88 | No | ||
| 5 |
Result: Pass. Ana's 72 is at least 50.
Tips
- For more than two outcomes, IFS is easier to read than IFs inside IFs.
- Combine IF with AND or OR to test several things at once.
Practise IF
Try it yourself in a real spreadsheet, with instant feedback on every answer.