The Excel IF function, explained interactively.
IF is the simplest decision maker in a spreadsheet: evaluate one condition, return one value if it’s TRUE, another if it’s FALSE. Drop in the score sheet below, tweak the threshold and the branch labels, and watch each row resolve.
How to use IF
Four steps cover every IF you’ll ever write. The rest is choosing good conditions.
- Type
=IF(in the target cell and pick the logical_test — the condition that returns TRUE or FALSE (usually a comparison likeB2>=60). - Add a comma and the value_if_true — what IF returns when the test passes. Can be text, a number, a cell reference, or another formula.
- Add a comma and the value_if_false — what IF returns otherwise. Technically optional, but leaving it off makes IF return the literal
FALSE, which is rarely what you want. - Close the parenthesis and press Enter. Excel re-evaluates the condition for every row the formula is copied to.
B2>=60, A2="Pass", or anything that resolves to TRUE / FALSE.| A | B | C | |
|---|---|---|---|
| 1 | Name | Score | Result |
| 2 | Ava | 92 | Pass |
| 3 | Ben | 58 | Fail |
| 4 | Chloe | 75 | Pass |
| 5 | Dev | 47 | Fail |
| 6 | Elena | 88 | Pass |
| 7 | Farid | 64 | Pass |
| 8 | Grace | 31 | Fail |
B2 >= 60 and returns Pass. The other C cells show what C3:C8 would return if you dragged the fill handle down.IF syntax and arguments
Three positional arguments: a boolean test and two branch values. See Microsoft’s official IF reference for the canonical specification.
A2>100, B2="Paid") but can also be a direct boolean reference or a nested function call like ISBLANK(A2).logical_test is TRUE. Literal text must be quoted ("Pass"). Numbers, cell references, and other formulas do not need quotes.FALSE — almost always a bug. Always supply a meaningful fallback.IF examples
Four patterns that cover 90% of real-world IF use.
Example 1: IF with a numeric threshold
The canonical case — label each row as Pass or Fail based on a score.
Quote the text branches. A bare Pass without quotes would be treated as a named range and usually returns #NAME?.
Example 2: Nested IF for multi-tier grading
When you need three or more outcomes, chain IFs by putting another IF in the false branch.
Order matters — test from highest to lowest. Past three nests, switch to IFS for readability: it takes pairs of condition + result with no nesting.
Example 3: IF combined with AND / OR
Boolean combinations let IF test several conditions at once without nesting.
AND requires every argument to be TRUE; OR requires at least one. Don’t write B2>=60 AND C2="Paid" — that isn’t valid spreadsheet syntax.
Common IF errors and fixes
Four failure modes, each with what to check and how to recover.
IF returns #NAME?
Cause: function misspelled (IFF, FI) or a text value left unquoted.
Check the formula spelling, then verify every literal string uses straight double quotes — smart quotes pasted from a document break IF silently.
IF shows the formula as text
Cause: the cell is formatted as Text, so Excel never evaluates what you typed.
Reformat the cell as General, delete the content, and retype the formula. Reformatting alone doesn’t reparse the existing text — you must re-enter it.
IF returning unexpected FALSE literal
Cause: you omitted the value_if_false argument.
Always provide the third argument, even if it’s "" for an intentional blank. Bare =IF(B2>60,"Pass") returns the literal FALSE when B2 fails the test.
IF evaluating numbers as text
Cause: the value being tested is stored as text, so "9" > "10" evaluates by alphabetic order.
Multiply by 1 (B2*1>=60) or wrap in VALUE() to force numeric comparison. A fast fix is selecting the column and using Data → Text to Columns.
IF vs IFS, SWITCH & CHOOSE
Four ways to branch in a spreadsheet. Pick by how many outcomes you need and how they’re indexed.
| Function | Conditions | Indexed by | Use when |
|---|---|---|---|
| IF | One | Boolean test | Binary yes/no decision — the workhorse. |
| IFS | Many (no default) | Boolean tests | Multi-tier classification when each tier has a different condition. Replaces 3+ nested IFs. |
| SWITCH | Many | Exact match on a value | Mapping discrete input values to outputs — like a lookup table inline. |
| CHOOSE | Many | Integer index (1, 2, 3…) | Pick the Nth item from a list. Often paired with MATCH or WEEKDAY. |
The migration path: one condition stays IF; three tiers rewrite as IFS; exact-value maps move to SWITCH; positional picks go to CHOOSE. Use whichever reads most naturally — the performance differences are negligible for typical sheet sizes.
IF frequently asked questions
6.01How do I write a nested IF in Excel?▸
Replace either branch with another IF. Example: =IF(B2>=90,"A",IF(B2>=80,"B","C")). Modern Excel and Google Sheets allow up to 64 nesting levels, but readability collapses fast — past three branches, reach for IFS or SWITCH instead.
6.02Can IF return different data types?▸
Yes. IF can return text, numbers, dates, cell references, or other formulas. A common pattern is =IF(A2="","",lookup(...)) to suppress a lookup when the input is blank.
6.03What’s the difference between IF and IFS?▸
IF handles one condition with two outcomes. IFS handles many mutually-exclusive conditions without nesting — the modern replacement for 3+ nested IFs. IF is still the right choice for simple binary decisions.
6.04Can IF combine multiple conditions?▸
Yes — wrap them with AND or OR. Example: =IF(AND(B2>=60, C2="paid"), "Pass", "Fail").AND requires every condition to be TRUE; OR requires at least one.
6.05Why does my IF return #NAME? or just the formula text?▸
#NAME? means a misspelled function — Excel saw IFF or FI. If the cell shows the raw formula text, the cell is formatted as Text; change it to General and re-enter the formula.
Microsoft Excel is a registered trademark of Microsoft Corporation. Google Sheets is a trademark of Google LLC. Formula Gym is not affiliated with, endorsed by, or sponsored by either company.