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)
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)
| Argument | What it is |
|---|---|
logical_test | Something that is true or false, such as B2>=C2 or A2="North". Combine several with AND or OR. |
value_if_true | What to return when the test is true: text in quotes, a number, or another formula. |
value_if_false | What to return when it's false. Use "" to leave the cell looking empty. |
Examples
B2 are at least her target in C2, so the result is Hit.| A | B | C | D | |
|---|---|---|---|---|
| 1 | Rep | Sales | Target | Result |
| 2 | Ana | 5200 | 5000 | Hit |
| 3 | Ben | 4100 | 5000 | |
| 4 | Cara | 6100 | 5000 | |
| 5 | Dev | 5000 | 5000 |
=IF(B2>=C2,"Hit","Miss") returns Hit.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Rep | Sales | Target | Bonus |
| 2 | Ana | 5200 | 5000 | 260 |
| 3 | Ben | 4100 | 5000 | |
| 4 | Cara | 6100 | 5000 | |
| 5 | Dev | 5000 | 5000 |
=IF(B2>=C2,B2*5%,0) returns 260.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Rep | Sales | Target | Result |
| 2 | Ana | 5200 | 5000 | |
| 3 | Ben | 4100 | 5000 | |
| 4 | Cara | 6100 | 5000 | Star |
| 5 | Dev | 5000 | 5000 |
=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.