fgFormula Gym
Interactive lesson · Excel & Google Sheets

The Excel IF function, explained interactively.

Last updated: April 2026

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.

01 · See it work

How to use IF

Four steps cover every IF you’ll ever write. The rest is choosing good conditions.

  1. Type =IF( in the target cell and pick the logical_test — the condition that returns TRUE or FALSE (usually a comparison like B2>=60).
  2. 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.
  3. 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.
  4. Close the parenthesis and press Enter. Excel re-evaluates the condition for every row the formula is copied to.
FUNCTIONIF
Evaluates a boolean test and returns one of two values. Applied to each row independently — no sums, no lookups, just a fork in the road.
ARG 1logical_test
The condition IF evaluates. Usually a comparison — B2>=60, A2="Pass", or anything that resolves to TRUE / FALSE.
ARG 2value_if_true
What IF returns when the test is TRUE. Can be literal text, a number, a cell reference, or another formula.
ARG 3value_if_false
What IF returns when the test is FALSE. Technically optional — omit it and IF returns FALSE for failing rows.
C2
fx
=IF(B2>=60, "Pass", "Fail")
ABC
1NameScoreResult
2Ava92Pass
3Ben58Fail
4Chloe75Pass
5Dev47Fail
6Elena88Pass
7Farid64Pass
8Grace31Fail
C2 is the active cell (the outlined one with the fill handle) — it evaluates B2 >= 60 and returns Pass. The other C cells show what C3:C8 would return if you dragged the fill handle down.
02 · Syntax, argument by argument

IF syntax and arguments

Three positional arguments: a boolean test and two branch values. See Microsoft’s official IF reference for the canonical specification.

=IF(logical_test, value_if_true, [value_if_false])
logical_test
Any expression that resolves to TRUE or FALSE. Typically a comparison (A2>100, B2="Paid") but can also be a direct boolean reference or a nested function call like ISBLANK(A2).
value_if_true
What IF returns when logical_test is TRUE. Literal text must be quoted ("Pass"). Numbers, cell references, and other formulas do not need quotes.
[value_if_false]
What IF returns when the test is FALSE. Optional in the grammar, but omitting it makes IF return the literal FALSE — almost always a bug. Always supply a meaningful fallback.
03 · In the wild

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.

=IF(B2>=60, "Pass", "Fail")

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.

=IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C", "D")))

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.

=IF(AND(B2>=60, C2="Paid"), "Active", "Pending")

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.

Example 4: IF to suppress blanks

Common dashboard pattern — hide a lookup or computation when the source cell is empty.

=IF(A2="", "", VLOOKUP(A2, catalog, 2, FALSE))

"" (empty string) returns a visually blank cell without breaking downstream formulas. Pairs well with VLOOKUP or XLOOKUP.

04 · Errata

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.

05 · Kindred functions

IF vs IFS, SWITCH & CHOOSE

Four ways to branch in a spreadsheet. Pick by how many outcomes you need and how they’re indexed.

FunctionConditionsIndexed byUse when
IFOneBoolean testBinary yes/no decision — the workhorse.
IFSMany (no default)Boolean testsMulti-tier classification when each tier has a different condition. Replaces 3+ nested IFs.
SWITCHManyExact match on a valueMapping discrete input values to outputs — like a lookup table inline.
CHOOSEManyInteger 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.

06 · Marginalia

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.