The Excel IF Formula: 7 Practical Examples

The IF formula asks a question and returns one answer if it's true and another if it's false. The pattern never changes:

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

Three parts, separated by commas: the test, the answer when it's true, the answer when it's false. Everything else people do with IF is a variation on those three slots.

Below are seven examples taken from real spreadsheet work, roughly in order of how often you'll need them.

The three parts

Part In the example What it does
Logical testB2>=50A question Excel answers with TRUE or FALSE
Value if true"Pass"What appears when the test is TRUE
Value if false"Fail"What appears when the test is FALSE

Text answers go in double quotes. Numbers don't. "50" in quotes is text and will not compare correctly against a number.

1. A simple threshold

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

A score of exactly 50 passes here, because >= means "greater than or equal to". Use > instead and 50 fails. This one character is the most common cause of a boundary value landing in the wrong category, and it never produces an error to warn you.

The comparison operators

Operator Meaning
=Equal to
<>Not equal to
> / <Greater than / less than
>= / <=Greater than or equal / less than or equal
Excel IF formula examples showing a threshold test, nested bands, and a conditional discount

Each formula reads its own row — and >= is what decides the case that sits exactly on the boundary.

2. Matching text

=IF(C2="Approved", "Proceed", "On hold")

Two things to know. Excel ignores case here — "approved", "Approved" and "APPROVED" all match. And a trailing space breaks it silently, because "Approved " is not "Approved". If a status column comes from an export, clean it first; the same invisible-space problem shows up all over spreadsheet work.

=IF(TRIM(C2)="Approved", "Proceed", "On hold")

3. Checking whether a cell is empty

=IF(D2="", "Missing", "Complete")

Two empty double quotes mean "nothing". This is how you flag gaps in a list before sending it on.

⚠️ A cell containing =IF(...,"","") looks empty but isn't — it holds a formula returning empty text. ISBLANK() returns FALSE for such cells, which is why =D2="" is usually the safer test.

4. Banding with nested IFs

=IF(B2>=90, "A", IF(B2>=75, "B", IF(B2>=50, "C", "D")))

Each IF becomes the "false" answer of the one before it. Excel checks them top to bottom and stops at the first TRUE, so the order has to run from highest to lowest. Reverse it and everything above 50 gets a C, because that test is satisfied first.

The closing brackets all pile up at the end — one for each IF you opened.

Beyond three or four bands, nesting gets unreadable. Two better options: IFS on Excel 2019 and later, or an approximate-match lookup against a small band table, which is what VLOOKUP's TRUE argument was designed for.

=IFS(B2>=90,"A", B2>=75,"B", B2>=50,"C", TRUE,"D")

The final TRUE acts as the catch-all. Without it, anything that matches no condition returns #N/A.

5. Two conditions at once: AND and OR

Both must be true:

=IF(AND(B2>=50, C2="Approved"), "Release", "Hold")

Either one is enough:

=IF(OR(B2>=90, C2="Priority"), "Fast track", "Standard")

AND and OR go inside the test slot — they replace the comparison, they don't sit beside it. Both accept more than two conditions, separated by commas.

6. Returning a calculation, not a label

The true and false slots don't have to be text. They can be formulas:

=IF(B2>=1000, B2*0.9, B2)

Orders of 1,000 or more get a 10% discount; everything else stays at full price. This is where IF earns its keep — conditional pricing, tiered commission, tax thresholds.

=IF(D2>E2, D2-E2, 0)

That one returns the overspend against a budget, or zero if you're under. It avoids the negative numbers that make a summary column confusing to read.

7. Showing nothing instead of a zero

=IF(B2="", "", B2*1.15)

Without the guard, blank rows return 0 and your sheet fills with zeros no one asked for. With it, empty input stays empty.

⚠️ Cells returning "" are not truly empty. COUNTA counts them, and charts may plot them as zero. If a chart or a count downstream is behaving oddly, this is a likely cause.

Four errors and their causes

#NAME?

A misspelt function name, or missing quotes around text. =IF(B2>=50, Pass, Fail) fails because Excel reads Pass and Fail as undefined names.

Too few arguments

All three parts are needed. Omit the false value and Excel returns FALSE rather than blank — write "" if you want nothing shown.

The result is always the same

Usually a number stored as text. The text "60" is not greater than the number 50, so the test never passes. Check for the green triangle in the cell corner.

Mismatched parentheses

Nested IFs need one closing bracket per opening one. Click into the formula bar — Excel colour-codes matching pairs, which makes the missing one easy to spot.

Does this work in Google Sheets?

Yes, identically. IF, IFS, AND and OR all behave the same way. Sheets is equally case-insensitive on text comparisons.

Common questions

How many IFs can I nest?

64 in modern Excel. You will lose track of your own formula long before that — switch to IFS or a lookup table after three or four.

Can IF compare dates?

Yes. Dates are numbers to Excel, so =IF(B2>TODAY(), "Upcoming", "Past") works. Wrap literal dates in DATEVALUE: =IF(B2>DATEVALUE("2026-01-01"), ...).

How do I make text comparison case-sensitive?

Use EXACT inside the test: =IF(EXACT(C2,"Approved"), "Yes", "No").

What's the difference between IF and IFERROR?

IF tests a condition you write. IFERROR tests whether another formula failed. They're often used together: =IFERROR(IF(...), "Check input").

The short version

  • Three parts: test, answer if true, answer if false.
  • Text goes in quotes; numbers don't.
  • >= and > behave differently at the boundary, and neither warns you.
  • Nested IFs must run highest to lowest.
  • AND and OR go inside the test, not beside it.
  • Use "" to show nothing — but remember those cells aren't truly empty.

Once conditions start depending on values held in another table, IF stops being the right tool and a lookup formula takes over.

Comments

Popular posts from this blog

How to Use VLOOKUP in Excel (With Real Examples)

SUMIF and SUMIFS: Conditional Totals Made Simple