← Functions
iflogicalfunctionsbeginner

Excel IF Function

How to use IF in Excel to test a condition and return different values based on true or false. Covers syntax, nested IFs, and errors.

IF tests a condition and returns one value if it's true, a different value if it's false. It's the building block behind most conditional logic in Excel, from a simple pass/fail check to a nested formula five conditions deep. The most common mistake: leaving out the third argument, which makes IF return the word FALSE instead of a blank cell.

Syntax

=IF(logical_test, value_if_true, [value_if_false])
ParameterRequiredDescription
logical_testYesThe condition you're checking. Must evaluate to TRUE or FALSE — usually a comparison like B2>100 or C2="Yes".
value_if_trueYesWhat the formula returns when logical_test is TRUE. Can be a number, text, a calculation, or another formula.
value_if_falseNoWhat the formula returns when logical_test is FALSE. If you leave this out, IF returns the literal value FALSE instead of a blank cell.

IF returns the boolean value FALSE when value_if_false is omitted — not an empty cell. If you want a blank result instead, use "" as the third argument: =IF(B2>100, "Over", "").

Basic Example

You're tracking whether each sales rep hit their monthly quota. Column B holds actual sales, column C holds the quota target.

=IF(B2>=C2, "Met Quota", "Missed Quota")

// B2   the rep's actual sales
// C2   the quota target for that rep

If B2 is greater than or equal to C2, the formula returns "Met Quota." Otherwise it returns "Missed Quota." That's the whole pattern — one test, two possible outcomes.

How IF Works

The condition has to resolve to TRUE or FALSE

logical_test can be a direct comparison (B2>100), a formula that returns TRUE or FALSE (ISBLANK(A2)), or a cell that already holds a boolean. Anything else — a number, a text string with no comparison operator — won't work as a logical test.

Text results need quotation marks

=IF(A2>10, High, Low) throws an error because Excel treats High and Low as undefined names. Wrap text in quotes: =IF(A2>10, "High", "Low"). Numbers and formulas don't need quotes.

IF isn't case-sensitive

=IF(A2="yes", "Approved", "Denied") matches "Yes," "YES," and "yes" identically. If you need a case-sensitive comparison, wrap the test in EXACT: =IF(EXACT(A2,"Yes"), "Approved", "Denied"). A stray space causes the same kind of mismatch — IF won't match "Chicago" against a cell that actually holds " Chicago" with a leading space. Wrap the reference in TRIM to strip that out: =IF(TRIM(A2)="Chicago", "Match", "No Match").

Common Use Cases

Flagging pass or fail results

Grade a test score against a passing threshold of 70.

=IF(D2>=70, "Pass", "Fail")   // D2 = test score

Calculating a conditional bonus

Pay a $500 bonus only to reps who exceeded their quota, otherwise pay nothing.

=IF(B2>C2, 500, 0)

// B2   actual sales
// C2   quota target

Combining IF with AND or OR

A single IF only checks one condition on its own. Nest AND or OR inside logical_test to check several at once — approve a loan only if income is above $50,000 and credit score is above 700:

=IF(AND(E2>50000, F2>700), "Approved", "Review Required")

Nesting IF for more than two outcomes

Assign a letter grade with four possible results by nesting IF inside the value_if_false argument:

=IF(D2>=90, "A", IF(D2>=80, "B", IF(D2>=70, "C", "F")))

Each nested IF only runs if the one before it was FALSE. Once a score clears 90, the formula stops and returns "A" without checking the rest.

Notes & Gotchas

Why does my IF formula return FALSE instead of a blank cell?

Because the third argument was left out. IF defaults to the boolean FALSE when value_if_false is omitted, not an empty string. Use =IF(logical_test, value_if_true, "") if you want a genuinely blank result instead.

How many IF statements can I nest?

Technically, quite a few — but readability breaks down long before you hit any real limit. Anything past three or four levels is a strong signal to switch to IFS, which evaluates a list of conditions without the nested parentheses:

=IFS(D2>=90, "A", D2>=80, "B", D2>=70, "C", TRUE, "F")

Does IF work with dates?

Yes, as long as the dates are stored as actual date values and not text. Compare them the same way you'd compare numbers:

=IF(A2<TODAY(), "Overdue", "On Track")

If the comparison returns unexpected results, the date is probably stored as text — check with ISNUMBER(A2) to confirm.

When a nested IF formula gets hard to read, build it one level at a time in a helper column first. Confirm each condition works before combining them into a single cell.

What happens if logical_test references a blank cell?

Excel treats a blank cell as 0 in numeric comparisons and as an empty string in text comparisons. =IF(A2>0, "Yes", "No") returns "No" for a blank A2, since blank evaluates to 0. This is usually fine, but it can mask the difference between "zero" and "no data entered" — use ISBLANK if that distinction matters.

Related Functions

FunctionUse this when...
IFSYou have more than two or three outcomes and nested IFs are getting hard to read.
IFERRORYou want to catch a formula error and return a fallback value instead of testing a condition.
VLOOKUPYou need to pull a value from a table based on a match, rather than testing a condition directly.