IF

Return one value if a condition is true and another value if it's false.

LogicBeginner
Purpose
Tests a condition and returns one value when it's true, another when it's false.
Returns
Whichever of the two values you specify (text, number, formula, anything)
Syntax
=IF(logical_test, value_if_true, [value_if_false])
Excel version
Every version of Excel ever shipped

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.

= IF(logical_test, value_if_true, [value_if_false])

Arguments

ArgumentTypeRequiredDescription
logical_testexpression✓ RequiredThe 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_trueany✓ RequiredWhat Excel returns when the test passes. Can be text in quotes, a number, a cell reference, a formula, or another IF.
value_if_falseany✗ OptionalWhat 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.)
C2
fx
=IF(B2>=60,"Pass","Fail")
ABCD
1StudentScoreResult
2Alex Kim78Pass
3Sarah Chen92Pass↓ drag down
4James Miller47Fail
5Maria Santos61Pass
6David Brown55Fail
7Emma Davis84Pass
8Carlos Gomez33Fail
9Jenny Liu70Pass
10Mark Reilly59Fail
11Rachel Wood88Pass
Formula entered in cell C2. Drag down and Excel adjusts B2 to B3, B4, etc.
The single rule (>=60) handles all eleven students. Same formula in every row, same logic, no judgment calls.

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
C2
fx
=IF(B2>30,"Overdue","Current")
ABCD
1InvoiceDays outstandingStatus
2INV-104245Overdue
3INV-104312Current↓ drag down
4INV-104467Overdue
5INV-10453Current
6INV-104630Current
7INV-104731Overdue
8INV-104888Overdue
9INV-104914Current
10INV-105052Overdue
11
Formula entered in cell C2. Drag down to flag every invoice on the report.
Pay attention to row 6: 30 days exactly is still Current because the test is strict greater-than. Switch to >=30 if you want 30 to count as overdue.
The boundary value is the easy place to make a quiet mistake. Always read the test out loud and check what happens at the exact threshold.

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.
C2
fx
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C",IF(B2>=60,"D","F"))))
ABCD
1StudentScoreGrade
2Alex Kim94A
3Sarah Chen85B↓ drag down
4James Miller78C
5Maria Santos62D
6David Brown47F
7Emma Davis91A
8Carlos Gomez73C
9Jenny Liu82B
10Mark Reilly55F
11Rachel Wood67D
12
Formula entered in C2. Each nested IF handles the next band down.
Watch the high band first. If you reversed the order and tested >=60 first, every score above 60 would return D.
Past three or four nested IFs the formula gets unreadable and easy to break. For more bands, jump to the IFS function or use VLOOKUP against a small bracket table.

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
C2
fx
=IF(B2>=10000,B2*0.1,B2*0.05)
ABCD
1Sales repMonthly revenueCommission
2Sarah Chen$14,200$1,420
3James Miller$7,800$390↓ drag down
4Maria Santos$22,500$2,250
5David Brown$5,400$270
6Emma Davis$10,000$1,000
7Alex Kim$9,950$498
8Carlos Gomez$18,300$1,830
9Jenny Liu$6,200$310
10Mark Reilly$11,750$1,175
11Rachel Wood$8,900$445
12
Formula entered in C2. The branches are calculations, not text.
Notice Alex at $9,950 just misses the bonus tier and earns less than half what Sarah did at $14,200. That cliff is the cost of a single threshold rule, which is why real comp plans usually use multiple bands.

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
D2
fx
=IF(AND(B2>=3,C2>=4),"Eligible","Not yet")
ABCDE
1EmployeeYearsRatingBonus?
2Sarah Chen54Eligible
3James Miller25Not yet↓ drag down
4Maria Santos83Not yet
5David Brown45Eligible
6Emma Davis14Not yet
7Alex Kim34Eligible
8Carlos Gomez62Not yet
9Jenny Liu75Eligible
10Mark Reilly104Eligible
11Rachel Wood23Not yet
12
Formula entered in D2. AND() is the gate, IF() reacts.
Maria has plenty of tenure but a 3 rating, so AND fails and she's Not yet. James has a great rating but only 2 years. Both conditions must hold.
Reach for AND when every condition has to be true. Reach for OR when any single one is enough. They both return TRUE or FALSE, which makes them perfect first arguments for IF.

Where people go wrong

  1. 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.
  2. 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.
  3. 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.
  4. 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 →
Free account · No credit card · Cancel anytime
Practice IF
IF Function in Excel: Formula, Examples & Nested IFs · CellSkill