Excel IF function: return one value or another

Updated October 29, 2026 · 3 min read

IF checks a test and returns one value when it's true and another when it's false. =IF(B2>D2,"Yes","No") shows Yes when the sale in B2 beats the target in D2.

The examples use this small sales table, the same one in the practice box below.

A RepB SalesD TargetE Region
2Dana1,2501,000East
3Luis8301,000West
4Priya2,1001,000East
5Marcus4751,000North
6Jen9901,000West
7Omar1,6001,000East

Syntax

=IF(logical_test, value_if_true, value_if_false)

Examples

  • =IF(B2>D2,"Yes","No") returns Yes for Dana, since 1,250 beats 1,000.
  • =IF(B2>D2,B2*0.1,0) returns a 10% bonus when she beats target, otherwise 0. That's 125 for Dana.

Comparison operators

> greater than, < less than, >= at least, <= at most, = equal to, <> not equal to.

Two tests with AND or OR

=IF(AND(B2>D2,E2="East"),"Bonus","") needs both to be true. Swap in OR when either one is enough.

Nested IFs

=IF(B2>=2000,"Gold",IF(B2>=1000,"Silver","Bronze")) checks from the top down and stops at the first true test. Order matters: put the highest bar first.

Common mistakes

  • No quotes around text. =IF(B2>D2,Yes,No) gives #NAME?. Text results need quotes. Numbers don't.
  • Typing the number instead of the cell. =IF(B2>1000,...) works until the target changes. Point to D2.
  • Wrong order in nested IFs. Testing >=1000 before >=2000 labels Priya Silver instead of Gold, because her 2,100 passes the first test.

Try it: Hit target?

In C2, show Yes if Dana's sale (B2) is above her target (D2), otherwise No.

C2

Graded live, like a real Excel test. Press New numbers to prove you didn't memorize the answer. More practice

Questions people ask

How many IFs can I nest?

Excel allows up to 64, but more than three gets hard to read. Newer Excel and Google Sheets also have IFS for long chains.

How do I return a blank cell?

Use two quotes with nothing between them, like =IF(B2>D2,"Yes","").

Practice on a real spreadsheet

CellReady grades your formula the moment you press Enter and tells you why a wrong answer is wrong. The first 7 lessons are free, with no sign-up to start.

Start lesson one

Related guides

Excel IFERROR function: replace errors with a clean value

How to use IFERROR in Excel to replace #N/A, #DIV/0! and other errors, when not to use it, and a live exercise with VLOOKUP.

Excel COUNTIF function: count cells that meet a condition

How to use COUNTIF in Excel with numbers, text and cell references, plus COUNTIFS for two conditions and a live exercise.

Excel SUMIF function: add only the rows you want

How to use SUMIF in Excel, the argument order that trips people up, using cell references in the condition, and a live exercise.