Practice file to follow along
The fastest way to learn IF is to type the formulas yourself. The practice file has five tasks. Next to each row there is a check cell that says "correct" or "not yet" as soon as you have entered a formula. No email address needed.
- IF practice file with basics, a number as result, several levels, IF with OR and leaving a cell blank
- Answers with every formula filled in, plus each formula written out the way you type it
All items and amounts in the file are invented example data.
What does the IF function do?
IF asks Excel a question with a yes or no answer. If the answer is yes, Excel returns the first value, otherwise the second. That way your sheet makes the decision itself instead of you checking every row by hand.
Typical tasks at work
- compare actual costs with the budget and show "over budget"
- calculate shipping based on the order value
- sort sales into levels such as A, B and C
- flag travel expenses that need approval
Syntax and how to write it
=IF(logical_test,value_if_true,[value_if_false])
These are the argument names Excel shows while you type. In English Excel you separate them with commas. German and French Excel use semicolons.
| Excel language | The same formula |
|---|---|
| English | =IF(C5>B5,"over budget","within budget") |
| German | =WENN(C5>B5;"über Budget";"im Budget") |
| French | =SI(C5>B5;"hors budget";"dans le budget") |
You find every name in three languages in our Excel functions list.
The three arguments
| Argument | Required? | What you enter | Example |
|---|---|---|---|
| logical_test | yes | a condition that is true or false | C5>B5 |
| value_if_true | yes | what appears when the condition is true | "over budget" |
| value_if_false | no | what appears when the condition is false | "within budget" |
Do not leave out the value_if_false anyway. Without it, Excel shows FALSE when the condition is not met, and in a table that looks like an error.
The comparison operators
For the test you need a comparison. These are the signs Excel knows.
| Sign | Meaning | Example |
|---|---|---|
| = | equal to | C5="Flight" |
| <> | not equal to | C5<>"Flight" |
| > | greater than | B5>500 |
| < | less than | B5<50 |
| >= | greater than or equal to | B5>=50 |
| <= | less than or equal to | B5<=100 |
Watch the limit. B5>50 is false at exactly 50, while B5>=50 is true. You practice this in task 2.
Step by step to show over or within budget
This is how you solve task 1 of the practice file. Column B has the plan, column C the actual value.
- Click cell D5, where the status should go.
- Type
=IF(and then the testC5>B5, which asks whether the actual value is greater than the plan. - Type a comma and the value_if_true in quotation marks,
"over budget". - Type a comma, the value_if_false
"within budget"and close the bracket. - Press Enter. With an actual value of $1,350 and a plan of $1,200 the cell shows "over budget". Fill the formula down to D9.
Look at row 7, where plan and actual are both $500. 500 is not greater than 500, so Excel shows "within budget".
Text, numbers and blank cells as results
What you enter as value_if_true and value_if_false decides what appears in the cell.
- Text always goes in quotation marks, as in
"over budget". Only TRUE and FALSE work without quotes. - Numbers go without quotation marks, so Excel can keep calculating with them.
=IF(A5>=50,0,4.95)returns 0 or 4.95. - Calculations work too.
=IF(B5>=50,0,B5*0.1)charges 10% shipping only below $50. - Blank cell. Two quotation marks with nothing between them show an empty cell.
=IF(B5="","",B5*C5)only calculates when B5 has a quantity. You practice this in task 5.
Several conditions with AND and OR
To check two things at once, put AND or OR into the test.
| Function | True when | Example |
|---|---|---|
| AND | all conditions are met | =IF(AND(B5>=5000,C5<=2),"bonus","no bonus") |
| OR | at least one condition is met | =IF(OR(B5>500,C5="Flight"),"needs approval","ok") |
In the first example there is a bonus only with sales of at least $5,000 and no more than two days off sick. In the second, a trip needs approval when it costs more than $500 or is a flight. You practice the OR example in task 4.
Several levels with nested IF or IFS
If you need more than two results, put a second IF into the value_if_false of the first.
=IF(A5>=10000,"A",IF(A5>=5000,"B","C"))
Excel checks from left to right. From $10,000 the result is A. If not, the second IF checks whether it is at least $5,000, then B, otherwise C. The order matters. Start with the highest limit. If you test >=5000 first, sales of $12,500 only get a B.
With Excel 2019 or Microsoft 365 the IFS function is easier to read.
=IFS(A5>=10000,"A",A5>=5000,"B",TRUE,"C")
IFS takes pairs of test and value and returns the value of the first true test. The TRUE at the end is the default for every other case. Without that default, IFS returns #N/A when no test is met.
With many levels, such as a commission table with ten limits, every version gets hard to read. Then put the limits into a small table and return the level with VLOOKUP and TRUE at the end.
IF not working and how to fix common errors
| What you see | Cause | Fix |
|---|---|---|
| #NAME? | Text without quotation marks, as in =IF(C5>B5,over,within), or a misspelled function name. | Put text in quotation marks, as in "over budget". |
| #NAME? | WENN or SI typed in English Excel. | Type the English name IF. |
| 0 or FALSE instead of a result | value_if_true or value_if_false is missing. | Give both values, use "" for blank if needed. |
| Wrong level with nested IF | The limits are in the wrong order. | Start with the highest limit. |
| A value right at the limit lands in the wrong group | > instead of >= or the other way round. | Decide whether the limit itself belongs to the group. |
| A comparison with a number is wrong | The number is stored as text, so Excel does not compare it as a number. | Turn the text number into a number. |
| Two amounts that look the same compare as FALSE | Tiny rounding rests. | Round inside the comparison, as in =IF(ROUND(A5,2)=ROUND(B5,2),"same","different") |
| Excel reports a problem with the formula | Semicolons from a German or French guide. | In English Excel, replace every semicolon between the arguments with a comma. |
Why amounts that look the same are sometimes not equal is explained in our guide to sum, average and round. Every error value is explained in our guide to Excel errors.
Which Excel versions have IF?
IF, AND and OR are available in every Excel version, including Excel for the web and Excel for Mac. According to Microsoft, IFS is available from Office 2019 and in Microsoft 365. In older versions you use a nested IF.
Related functions
- IFERROR shows your own text when a formula returns an error
- SUMIF adds up only the rows that meet a condition
- COUNTIF counts only the cells that meet a condition
- VLOOKUP returns values from a list, including tier tables
- Sum, average and round covers the basics for the calculations inside IF
You find all functions with their English, German and French names in the Excel functions list.
What to learn next
Once the practice file works, add an IF to a list of your own, such as your travel expenses. You can practice formulas like this in our Excel exercises with instant feedback. The Excel test shows you where you stand.
Sources
Function and argument names, rules for text, missing arguments, the IFS default and versions from Microsoft's help pages, November 2026.
- Microsoft, IF function
- Microsoft, IFS function
- Microsoft, AND function
- Microsoft, OR function