How IF works
IF asks one yes-or-no question and reacts. If the answer is yes, it returns the second argument. If the answer is no, it returns the third. That's the whole function.
The first argument is a comparison: is this number bigger than that one, does this cell equal that text, is this date in the past. Excel evaluates it to TRUE or FALSE, then picks the matching branch.
IF is the building block for almost every business rule in Excel. Every flag, every threshold, every conditional calculation eventually traces back to one or more IFs.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
| logical_test | expression | ✓ Required | The condition Excel checks. Anything that evaluates to TRUE or FALSE: a comparison like B2>=60, an equality test like A2="yes", or a function call like AND(B2>3,C2<10). |
| value_if_true | any | ✓ Required | What Excel returns when the test passes. Can be text in quotes, a number, a cell reference, a formula, or another IF. |
| value_if_false | any | ✗ Optional | What Excel returns when the test fails. Technically optional, but skip it and Excel returns the literal value FALSE which almost never reads correctly. Always supply something, even "" for blank. |
IF basic: turn a quiz score into Pass or Fail
You're a teaching assistant grading a midterm. Anything 60 or above is a pass, anything below is a fail. You have 200 students. One formula handles all of them.
=IF(B2>=60,"Pass","Fail")- •
B2>=60→ the question being asked: is the score 60 or higher? - •
"Pass"→ what to write when the answer is yes - •
"Fail"→ what to write when the answer is no - •
B2→ the cell being checked (drag down and it becomes B3, B4, etc.)
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Student | Score | Result | |
| 2 | Alex Kim | 78 | Pass | |
| 3 | Sarah Chen | 92 | Pass | ↓ drag down |
| 4 | James Miller | 47 | Fail | |
| 5 | Maria Santos | 61 | Pass | |
| 6 | David Brown | 55 | Fail | |
| 7 | Emma Davis | 84 | Pass | |
| 8 | Carlos Gomez | 33 | Fail | |
| 9 | Jenny Liu | 70 | Pass | |
| 10 | Mark Reilly | 59 | Fail | |
| 11 | Rachel Wood | 88 | Pass |
IF on dates: flag invoices that are overdue
You manage receivables. The aging report has a column for days outstanding. Anything over 30 days needs a phone call today. You want a column that says "Overdue" or "Current" so you can filter and call.
=IF(B2>30,"Overdue","Current")- •
B2>30→ is days outstanding strictly greater than 30? - •
"Overdue"→ label when yes - •
"Current"→ label when no (30 days or less) - •
B2→ the days-outstanding cell on the row being checked
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Invoice | Days outstanding | Status | |
| 2 | INV-1042 | 45 | Overdue | |
| 3 | INV-1043 | 12 | Current | ↓ drag down |
| 4 | INV-1044 | 67 | Overdue | |
| 5 | INV-1045 | 3 | Current | |
| 6 | INV-1046 | 30 | Current | |
| 7 | INV-1047 | 31 | Overdue | |
| 8 | INV-1048 | 88 | Overdue | |
| 9 | INV-1049 | 14 | Current | |
| 10 | INV-1050 | 52 | Overdue | |
| 11 |
Nested IF: convert scores to letter grades
One IF asks one question. To handle multiple bands you nest them: each "value if false" branch holds another IF that asks the next question. Letter grades are the textbook example: 90 and above is A, 80s are B, 70s are C, 60s are D, anything else is F.
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C",IF(B2>=60,"D","F"))))- •
First test→ is the score 90 or higher? If yes, return A and stop. - •
Second test→ if not, is it 80 or higher? Return B. - •
Third test→ if not, is it 70 or higher? Return C. - •
Fourth test→ if not, is it 60 or higher? Return D. - •
Final fallback→ if every test failed, return F. - •
Order matters→ Excel reads top to bottom and stops at the first match. Test the highest band first.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Student | Score | Grade | |
| 2 | Alex Kim | 94 | A | |
| 3 | Sarah Chen | 85 | B | ↓ drag down |
| 4 | James Miller | 78 | C | |
| 5 | Maria Santos | 62 | D | |
| 6 | David Brown | 47 | F | |
| 7 | Emma Davis | 91 | A | |
| 8 | Carlos Gomez | 73 | C | |
| 9 | Jenny Liu | 82 | B | |
| 10 | Mark Reilly | 55 | F | |
| 11 | Rachel Wood | 67 | D | |
| 12 |
IF in a calculation: commission at two tiers
The branches don't have to be text. They can be cell references, formulas, anything Excel can evaluate. A classic example: salespeople earn 10% commission on anything at or above $10,000 in monthly revenue, and 5% otherwise. One IF, doing math.
=IF(B2>=10000,B2*0.1,B2*0.05)- •
B2>=10000→ did this rep clear the $10K bar? - •
B2*0.1→ 10% of revenue if yes - •
B2*0.05→ 5% of revenue if no - •
B2→ the rep's monthly revenue cell
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Sales rep | Monthly revenue | Commission | |
| 2 | Sarah Chen | $14,200 | $1,420 | |
| 3 | James Miller | $7,800 | $390 | ↓ drag down |
| 4 | Maria Santos | $22,500 | $2,250 | |
| 5 | David Brown | $5,400 | $270 | |
| 6 | Emma Davis | $10,000 | $1,000 | |
| 7 | Alex Kim | $9,950 | $498 | |
| 8 | Carlos Gomez | $18,300 | $1,830 | |
| 9 | Jenny Liu | $6,200 | $310 | |
| 10 | Mark Reilly | $11,750 | $1,175 | |
| 11 | Rachel Wood | $8,900 | $445 | |
| 12 |
IF with AND: bonus eligibility on two conditions
Real business rules rarely depend on one number. Bonus eligibility might require both tenure of three years or more AND a performance rating of 4 or higher. Wrap both conditions in AND() and feed that into IF as the test.
=IF(AND(B2>=3,C2>=4),"Eligible","Not yet")- •
AND(B2>=3,C2>=4)→ both must be true: at least 3 years AND rating 4 or higher - •
B2→ the years-of-service cell - •
C2→ the latest performance rating - •
"Eligible" / "Not yet"→ the two outcomes - •
Swap AND for OR→ if either condition is enough on its own
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Employee | Years | Rating | Bonus? | |
| 2 | Sarah Chen | 5 | 4 | Eligible | |
| 3 | James Miller | 2 | 5 | Not yet | ↓ drag down |
| 4 | Maria Santos | 8 | 3 | Not yet | |
| 5 | David Brown | 4 | 5 | Eligible | |
| 6 | Emma Davis | 1 | 4 | Not yet | |
| 7 | Alex Kim | 3 | 4 | Eligible | |
| 8 | Carlos Gomez | 6 | 2 | Not yet | |
| 9 | Jenny Liu | 7 | 5 | Eligible | |
| 10 | Mark Reilly | 10 | 4 | Eligible | |
| 11 | Rachel Wood | 2 | 3 | Not yet | |
| 12 |
Where people go wrong
- Wrapping numbers in quotes
Writing =IF(B2>"60","Pass","Fail") looks fine but the quotes turn 60 into text. Excel then compares text to text, which gives wrong results because "9" is greater than "60" in alphabetical order.
Fix: Drop the quotes around numeric thresholds. Quotes belong around words, not numbers. - Forgetting the false branch
Writing =IF(B2>=60,"Pass") and skipping the third argument means Excel returns the literal value FALSE for any score under 60. Your column ends up with a mix of "Pass" and FALSE, which breaks filters and looks broken.
Fix: Always supply the third argument, even if it is just "" for blank. - Stacking too many nested IFs
By the fifth nested IF the formula becomes unreadable and one stray parenthesis breaks everything. You'll lose half a morning hunting the bug.
Fix: When you reach four bands, switch to IFS, SWITCH, or a small bracket table you VLOOKUP against. - Comparing numbers stored as text
Numbers imported from a website or pasted from a PDF often arrive as text. =IF(B2>30, ...) silently misbehaves because text doesn't compare numerically.
Fix: Wrap the cell in VALUE() to force a number, or fix the column type once at the source. Watch for left-aligned 'numbers' in a column that should be right-aligned.
Notes
- IF is case-insensitive when comparing text. "apple" equals "APPLE"
- The third argument (value_if_false) is technically optional. If you skip it, Excel returns the literal value FALSE, which is almost never what you want
- IF can be nested up to 64 levels deep, but anything past three is hard to maintain and worth refactoring
- Both branches can be formulas, cell references, or other functions. Not just static text or numbers
- Comparison operators: = equals, <> not equal, > greater than, < less than, >= at least, <= at most
- For multiple AND conditions wrap them in AND(). For any-of conditions wrap them in OR(). NOT() inverts a test
- In Excel 2019 and later, IFS handles multi-band logic much more cleanly than nested IFs
Now prove it
Reading about IF is one thing.
Writing one under pressure when your manager asks you to flag every customer at risk of churn before lunch is completely different.
These exercises put you in real job scenarios where one well-placed IF saves the day.
Here's the thing about IF.
You can read this page twice and still freeze when your manager hands you a 5,000-row spreadsheet at 4:30pm and asks for the flagged ones in twenty minutes.
That gap, between knowing what IF does and being able to write one cleanly under pressure, is exactly what CellSkill is built to close.
Not with more reading.
With practice on scenarios that look like your actual job.
Start practicing IF for free →