Free IF practice

IF practice exercises

IF checks a condition and returns one value when it is true and another when it is false. 4 reps, from easy to hard, each checked in a real spreadsheet engine. 2 free, 2 with Pro.

=IF(logical_test, value_if_true, value_if_false)
Skill: IF Change skill (45)

IF guide

How to use IF in Excel

IF checks a condition and returns one value when it's true and another when it's false: Hit or Miss, a bonus or nothing, Pass or Fail. It's the start of almost every decision a spreadsheet makes, and it appears in nearly every Excel test.

The condition is usually a comparison such as B2>=C2. Text results go in double quotes; numbers and formulas don't.

Syntax

=IF(logical_test, value_if_true, value_if_false)
ArgumentWhat it is
logical_testSomething that is true or false, such as B2>=C2 or A2="North". Combine several with AND or OR.
value_if_trueWhat to return when the test is true: text in quotes, a number, or another formula.
value_if_falseWhat to return when it's false. Use "" to leave the cell looking empty.

Examples

Example 1 Label who hit their target. Ana's sales in B2 are at least her target in C2, so the result is Hit.
D2fx=IF(B2>=C2,"Hit","Miss")
ABCD
1RepSalesTargetResult
2Ana52005000Hit
3Ben41005000
4Cara61005000
5Dev50005000

=IF(B2>=C2,"Hit","Miss") returns Hit.

Example 2 Return a calculation. A 5% bonus for reps who hit their target, otherwise 0. Ana gets 5% of 5200.
D2fx=IF(B2>=C2,B2*5%,0)
ABCD
1RepSalesTargetBonus
2Ana52005000260
3Ben41005000
4Cara61005000
5Dev50005000

=IF(B2>=C2,B2*5%,0) returns 260.

Example 3 Three outcomes with a nested IF and AND. Star for 6000 or more that also hits the target, Hit for the target alone, otherwise Miss. Cara in row 4 is a Star.
D4fx=IF(AND(B4>=C4,B4>=6000),"Star",IF(B4>=C4,"Hit","Miss"))
ABCD
1RepSalesTargetResult
2Ana52005000
3Ben41005000
4Cara61005000Star
5Dev50005000

=IF(AND(B4>=C4,B4>=6000),"Star",IF(B4>=C4,"Hit","Miss")) returns Star.

Common mistakes

Text without quotes

Without quotes, Excel reads Hit and Miss as names of something in the workbook and returns #NAME?.

Wrong=IF(B2>=C2,Hit,Miss) → #NAME?

Right=IF(B2>=C2,"Hit","Miss") → Hit

> when the task says "at least"

Dev's sales equal the target exactly. > means more than, so Dev misses; "at least" or "meets the target" needs >=.

Wrong=IF(B5>C5,"Hit","Miss") → Miss

Right=IF(B5>=C5,"Hit","Miss") → Hit

IF questions

How do I use IF with more than one condition?

Put AND or OR inside the test: =IF(AND(B2>=C2,B2>=6000),"Star","") needs both, and =IF(OR(B2>=C2,B2>=6000),"OK","") needs either.

When should I use IFS instead of nested IFs?

When you have three or more outcomes. IFS lists each test and result in order, =IFS(B2>=6000,"Star",B2>=C2,"Hit",TRUE,"Miss"), which is easier to read than IFs inside IFs. It needs Excel 2019 or later.

How do I make IF return a blank cell?

Use two double quotes with nothing between them: =IF(B2>=C2,"Hit","").

Why does my IF always return the false value?

Check the comparison: numbers stored as text, extra spaces in text, or > where you meant >= are the usual causes.

Related functions

Reading is the warm-up

The reps are what make it stick. Try IF in the practice sheet above.

Practise IF ↑