Excel function · Logic
IF
Returns one value when a test is true and another when it's false.
What it does
IF makes a decision. It checks a test, such as whether a score is at least 60, and returns one result if the test is TRUE and another if it's FALSE. The results can be text, numbers or other formulas.
Syntax
=IF(logical_test, value_if_true, [value_if_false])Arguments in square brackets are optional, and … means you can add more of the same. In this Excel language, arguments are separated by ,
Arguments
- logical_test
- Anything that is TRUE or FALSE, usually a comparison like
B2>=60. - value_if_true
- What to return when the test is TRUE. Text goes in quotes.
- value_if_false
- What to return when it's FALSE. Leave it out and Excel shows FALSE.
Example
Ana needs 60 points to pass. Did she?
| A | B | C | |
|---|---|---|---|
| 1 | Student | Score | Result |
| 2 | Ana | 72 | Pass |
The formula in C2:
=IF(B2>=60,"Pass","Fail")Result: Pass
Ana scored 72. The test 72>=60 is TRUE, so IF returns its second argument: Pass.
Common mistakes
- Forgetting the quotes around text results. Without them Excel looks for a name and shows #NAME?.
- Putting quotes around numbers.
"10"is text, so a later sum may skip it. - Using
>when the limit itself should pass.>=includes it.
In other Excel languages
Excel translates function names, and in some languages the argument separator too. Type the name your Excel shows.
| Excel language | Function name | Separator |
|---|---|---|
| English | IF | , |
| Deutsch | WENN | ; |
| Français | SI | ; |
| Español (España) | SI | ; |
| Español (México) | SI | , |
| 日本語 | IF | , |
| 한국어 | IF | , |
| 繁體中文 | IF | , |
| ไทย | IF | , |
| ខ្មែរ | IF | , |
| Tiếng Việt | IF | ; |