IF function practice

IF checks whether something is true, and shows one answer if it is and another if it isn’t. It’s how a sheet makes a decision on every row.

=IF(, click to change"Met", hover to view"Missed") hover to view

D2 = Met Imani’s sales are above the target, so the answer is yes, and IF shows its second argument.

Say you have a list of sales reps, each with their sales and a target. IF looks at every row and writes Met or Missed beside it, so nobody reads down the list comparing numbers by hand. The same formula marks a test score Pass or Fail, flags an invoice as Overdue, or works out a bonus only for the people who earned one.

It’s one of the first functions an Excel test for job applicants asks about, and its mistakes are quiet: the formula runs and the column fills, with one row wrong. Below you build one step by step, then see it taken apart one piece at a time, each with a small sheet where you can make the classic mistakes yourself.

Lesson

This is Witsheet, Witsy’s in-browser spreadsheet. It works like Excel and checks each step as you go.

How IF picks an answer

IF takes three arguments: a question with a yes or no answer, what to show for yes, and what to show for no. It works out the question first, then shows one of the two answers and ignores the other.

D2 = Met Imani sold 48200 against a target of 45000. The test is true, so IF shows value_if_true and never looks at value_if_false.

=IF(, click to change"Met", hover to view"Missed") hover to view
B2>=C2 logical_test
A question with a yes or no answer: are the sales at least the target?
"Met" value_if_true
What to show when the answer is yes.
"Missed" value_if_false
What to show when it’s no.

Get the boundary right

The question is usually a comparison: = equal to, <> not equal to, > and < more and less than, >= and <= at least and at most. Two of them are easy to mix up, because they agree on every row but one.

D4 = Met Sofia’s sales equal the target, and >= counts equal as reaching it.

=IF(, "Met", "Missed") click to change
B4>=C4 logical_test
The rule says a rep who reaches the target has met it. Which comparison says that?

Whether a value exactly on the line counts is a business rule, not an Excel one. Read the rule (“reaches”, “at least”, “over”), pick the operator that says it, and test the formula on a row that sits exactly on the line.

Words in quotes, numbers without

The two answers can be words, numbers, or calculations of their own. Words need double quotes, so Excel knows they’re text. Numbers and calculations must not have them.

D2 = Met In quotes, Met is text, and IF shows it as written.

=IF(B2>=C2, , 0) click to change
"Met" value_if_true
Words go in double quotes. A number or a calculation goes in as it is.

A quoted number is the quiet version of this mistake: a bonus column of "500" looks right, but it’s text, so a total over it comes to 0 without any error.

Two conditions are still one question

“Reached target and rated 4 or more” sounds like two IFs, but it’s one question with two parts. Put them in AND when both must be true, or OR when either will do, and the whole thing goes where the single comparison went.

E2 = No Sofia reached target but is rated 3. AND needs both, so the answer is No. Still one question, so still one IF.

=IF(, "Yes", "No") click to change
AND(B2>=C2, D2>=4) logical_test
A top rep reached target and is rated 4 or more. AND needs both tests to be true, OR needs either.

Three answers: a second IF, or IFS

When there are more than two answers, such as Star, Met and Missed, put a second IF where the first one’s “no” answer goes. Excel asks the questions in order and stops at the first yes, so the order matters.

D2 = Met Priya isn’t 20% over, so the first IF passes the question to the second, which finds the target reached: Met.

=IF(, "Star", click to change) click to change
B2>=C2*1.2 logical_test
The first question. Star means 20% over target.
IF(B2>=C2, "Met", "Missed") value_if_false
What to do when the answer is no: ask again with a second IF, or settle on Missed.

In Microsoft 365, Excel 2019 and later and Google Sheets, IFS does the same without the nesting: =IFS(B2>=C2*1.2, "Star", B2>=C2, "Met", TRUE, "Missed"). It lists question, answer, question, answer, and also stops at the first yes. It has no “otherwise”, so the last question is TRUE, which is always yes. Past three or four answers, a lookup table usually reads better than either: VLOOKUP practice shows how.

Download the IF practice sheet

To carry on in your own Excel, download the workbook: 150 employees with departments, start dates and salaries, and a sheet of IF tasks to work through, such as salary bands, tenure flags and department rules.

Employee directory

150 employees across departments and offices, with start dates and salaries. Practice lookups by ID, IF logic on salary bands, sorting, filtering, and date arithmetic.

150 rows · Employee ID · Full Name · Department · Office · Start Date · Annual Salary

Free · fictional data · opens in Excel and Google Sheets

Learn the rest of Excel the same way

Witsy’s Excel course teaches a few hundred small skills, called Wits, the way this page teaches IF: in a real spreadsheet, a step at a time. The placement test finds the ones you already have.

Your Wit map

Test your spreadsheet Wits.

Take a few minute test to see how good you actually are with spreadsheets. Witsy creates a map of the Wits you should learn next.

Take the placement test Or just start learning →
new unproven weak mid strong very strong super strong