IF Function for Beginners: Make Your Spreadsheet Decide

The IF function asks one question and returns one of two answers: is this condition true or false? If it is true, show this result. If it is false, show that one. Almost every automated decision in a spreadsheet, from a stock warning to a pass mark, is built from that single idea.

This guide covers how IF works, how to write it correctly, how to choose between IF and its alternatives, and where it tends to fail. A worked example at the end ties the parts together.

What the IF Function Does

IF belongs to the group of logical functions in Excel, Google Sheets and most other spreadsheet tools. It checks a condition and returns a value based on the result. It does not change the data it reads, so you can use it freely without risking the source numbers.

The Three Arguments

Every IF formula has the same structure:

=IF(logical_test, value_if_true, value_if_false)

  • logical_test is the condition. It must produce TRUE or FALSE, for example B2<=C2 or A2="Paid".
  • value_if_true is what the cell shows when the condition is met. It can be text in quotation marks, a number, a cell reference or another formula.
  • value_if_false is what the cell shows when the condition is not met. It is optional in the syntax, but leaving it out returns FALSE, which is rarely what you want on a finished sheet.

Some European versions of Excel use semicolons instead of commas between arguments. If your formula returns an error that looks like a syntax problem, check the separator your installation expects before you check anything else.

Comparison Operators

The logical test relies on comparison operators. The ones you will use most are:

  • = equal to
  • <> not equal to
  • > and < greater than and less than
  • >= and <= greater than or equal to, and less than or equal to

Beginners often write = where they mean “not equal”. The correct form is <>. A formula such as =IF(A2="Paid","Done","Chase") works, but =IF(A2<>"Paid","Chase","Done") reads more naturally when the exception is the case you care about.

Text, Numbers and Cell References

Text in a formula must sit inside double quotation marks. Numbers do not. Cell references do not either. The difference matters:

  • =IF(B2>100,"High","Low") compares a cell with the number 100 and returns text.
  • =IF(B2>C2,B2-C2,0) compares two cells and returns a calculated value or zero.

If you forget the quotation marks around text, the spreadsheet looks for a named range or function with that name, and usually returns a #NAME? error.

Cell Rangers: Google Sheets Lessons for Kids

Skip the setup

Cell Rangers: Google Sheets Lessons for Kids

Self-checking spreadsheet activities that teach formulas, sorting and charts step by step.

See it on Taskdale →

Writing Your First IF Formula

The fastest way to learn IF is to build a status column for a list you already keep. Stock levels are a good start because the rule is clear: reorder when the count falls to or below a set level.

Stock Reorder Flag: Step by Step

Assume the following layout:

ColumnHeadingExample value
AProductCopper washer M6
BUnits in stock12
CReorder level15
DStatus(formula)

Follow these steps to build the status column:

  1. Click cell D2, the first data row under the header.
  2. Type =IF(B2<=C2,"Reorder","OK") and press Enter.
  3. Check the result. A stock of 12 against a reorder level of 15 should show “Reorder”.
  4. Drag the fill handle down the column, or double-click it, so the formula copies to every row.
  5. Scroll through the results and spot-check three or four rows against the raw numbers before you rely on the column.

Notice what the formula does when it copies down. Excel and Sheets adjust relative references, so D3 automatically reads B3 and C3. That is why you only need to write the formula once.

Adding a Fixed Threshold

Hardcoding 15 inside the formula works for one product, but it becomes a problem the moment the rule changes. Put the threshold in its own cell instead. Suppose you place a default reorder level of 15 in cell F1.

The formula becomes =IF(B2<=$F$1,"Reorder","OK").

The dollar signs lock the reference to F1 so it does not shift as the formula copies down. When the threshold changes, you edit one cell and every row updates. This is the single most useful habit in IF formulas: keep the numbers that drive decisions in visible cells, not buried in formulas.

Choosing the Right Logical Test

Most beginner trouble comes from choosing the wrong test rather than from syntax. Before you write the formula, state the rule in plain language. “If the invoice is more than 30 days old and not paid, flag it” translates directly into a logical test. If you cannot state the rule plainly, the formula will not be right either.

Test one condition at a time. A rule with three conditions is three tests, and each test needs its own check before you combine them.

When IF Is the Right Tool

IF suits a single yes or no decision, or a choice between two outcomes. It is also the right tool when the output is a calculation rather than a label, for example =IF(B2>1000,B2*0.05,B2*0.02) to apply a higher commission rate above a sales threshold.

When to Use Something Else

Once a rule has three or more outcomes, IF on its own becomes harder to read. The table below compares the main options.

OptionBest forConditions handledAvailabilityMain drawback
IFYes or no decisions, two outcomesOneAll versionsGets unreadable when stacked
Nested IFShort ranges of three or four outcomesSeveral, stackedAll versionsHard to audit beyond about three levels
IFSMultiple outcomes checked in orderMany, flat listExcel 2019 and 365, Google SheetsNot available in older Excel versions
SWITCHExact matches against a list of valuesMany exact valuesExcel 2019 and 365, Google SheetsMatches exact values only, not ranges
Lookup table with VLOOKUP or XLOOKUPBands, rates, tiers kept in a separate tableUnlimited, held as dataAll versions (XLOOKUP needs 365 or 2021)Requires a properly sorted or structured table
IFERRORReplacing error messages with a fallbackOne error checkExcel 2007 and later, Google SheetsHides errors if overused

The practical rule: use IF for one decision, IFS or a lookup table for several, and IFERROR only to tidy up known error cases, never to bury unknown ones.

Nesting IF Functions and When to Stop

A nested IF places one IF inside another. It is how you handle three or more outcomes using only the basic function.

A grade band example shows the pattern:

=IF(B2>=70,"Distinction",IF(B2>=50,"Pass","Fail"))

Read it from the outside in. The formula first asks whether the score is 70 or above. If not, it moves into the inner IF and asks whether the score is 50 or above. Anything left over is a fail.

The Order Rule

The order of the tests decides the result. Had the formula checked B2>=50 first, every score of 70 or above would also return “Pass”, and “Distinction” would never appear. Always test the strictest condition first, then work down.

Where Nesting Breaks Down

Nested IFs are hard to read once they pass about three levels. Each added level makes the formula harder to check, and a missing bracket at the end can shift every result. Excel allows up to 64 nested levels, but that limit is a warning, not a target. If you find yourself scrolling sideways through a formula, switch to IFS or move the bands into a lookup table.

Bellmark Teacher Planner and Gradebook

Ready-made template

Bellmark Teacher Planner and Gradebook

Weighted gradebook, attendance and lesson plans, with grades that calculate as you enter marks.

See it on Taskdale →

Combining Conditions with AND and OR

Real rules often depend on two things at once. AND and OR sit inside the logical test and combine conditions.

  • AND(condition1, condition2) returns TRUE only when both conditions are true.
  • OR(condition1, condition2) returns TRUE when at least one condition is true.

For example, an invoice flag might need to catch unpaid invoices that are overdue:

=IF(AND(D2="Unpaid",E2<TODAY()-30),"Chase","")

Here, D2 holds the payment status and E2 holds the due date. The formula returns “Chase” only when both parts are true. Otherwise it returns an empty string, which keeps the column clean.

Keep AND and OR for two or three conditions. Beyond that, the formula becomes a puzzle, and a helper column that tests one condition per column is easier to check.

Common Mistakes and How to Fix Them

Most IF errors fall into a small set of patterns. Check these first when a formula returns something unexpected.

  • Missing quotation marks around text. Symptom: #NAME? error. Fix: wrap every text value in double quotation marks.
  • Hardcoded numbers that should be cells. Symptom: the formula needs editing every time a threshold changes. Fix: move the number to a labelled cell and reference it with $ anchors.
  • Relative references that drift. Symptom: the formula copies down but compares the wrong rows. Fix: check whether fixed references need $ signs.
  • Wrong order in nested IFs. Symptom: some results never appear. Fix: test the strictest condition first.
  • Using = for “not equal”. Symptom: the wrong rows are flagged. Fix: use <>.
  • Numbers typed in quotation marks. Symptom: arithmetic fails or sorting goes wrong. Fix: remove the quotation marks so the value is stored as a number.
  • Unbalanced brackets. Symptom: the formula will not accept, or returns an error near the end. Fix: count opening and closing brackets, or let the formula bar highlight the matching pairs.
  • Wrong argument separator. Symptom: an error message on entry in a locale that expects semicolons. Fix: change the separator to match your regional settings.
  • Leaving out value_if_false. Symptom: FALSE appears in cells. Fix: always supply a fallback, even if it is an empty string "".

Worked Example: Flagging Late Invoices

This example builds a complete flagging workflow using several ideas from above. It suits a small business tracking customer invoices, but the same method applies to any dated list with a status.

The Setup

Suppose your sheet has these columns:

  • A: Invoice number
  • B: Customer
  • C: Amount
  • D: Due date
  • E: Status (“Paid” or “Unpaid”)
  • F: Action

Place a grace period in cell H1, labelled “Days after due date”, with the value 7. This keeps the rule visible and adjustable.

The Workflow

Follow these steps to build the flag:

  1. Confirm that column D contains real dates, not text. Click a date cell and check that the formula bar shows a date value.
  2. In cell F2, enter the formula =IF(E2="Paid","Closed",IF(TODAY()-D2>$H$1,"Chase","Monitor")).
  3. Read the formula from the outside in. A paid invoice returns “Closed” and stops there. An unpaid invoice is then tested for age. If it is more than the grace period past its due date, it returns “Chase”. Anything else returns “Monitor”.
  4. Drag the formula down to the last row of data.
  5. Test the result with three sample rows: a paid invoice, an unpaid invoice dated last week, and an unpaid invoice dated two months ago. Each should show the expected label.
  6. Add a filter to column F so you can view only the “Chase” rows when you need to act.

Why It Is Built This Way

The strict test comes first. A paid invoice should never be flagged, whatever its date, so the formula handles that case before anything else. The grace period sits in a labelled cell, so changing it from 7 days to 14 requires one edit. The output uses three clear labels, so a filter can separate the work without reading the formula.

Testing the Edge Cases

Before relying on the flag, check two things. First, make sure a blank due date does not produce a misleading result. A blank date counts as day zero, so TODAY()-D2 returns a very large number and the invoice would show “Chase”. If blank dates are possible, wrap the test: =IF(D2="","Check date",IF(E2="Paid","Closed",IF(TODAY()-D2>$H$1,"Chase","Monitor"))).

Second, confirm that a due date in the future returns “Monitor” rather than “Chase”. TODAY()-D2 will be negative, which is not greater than 7, so the formula behaves correctly.

Checklist Before You Trust an IF Formula

Run through these checks before you share a sheet or act on its output:

  • The rule is written down in one plain sentence.
  • Each logical test checks one condition, or uses AND or OR for no more than two or three.
  • Nested IFs test the strictest condition first.
  • Text values are in quotation marks, and numbers are not.
  • Thresholds sit in labelled cells, with $ anchors where they must stay fixed.
  • Blank cells, zeros and empty strings are handled on purpose.
  • Dates are real dates and numbers are real numbers.
  • Decimal comparisons use ROUND where precision matters.
  • The formula works in the spreadsheet version your colleagues use.
  • Three sample rows, covering each possible outcome, return the labels you expect.

When a rule has more than three outcomes, stop nesting and move to IFS or a lookup table. When a formula needs a comment to explain it, consider splitting the logic across helper columns. The goal is a sheet that decides consistently and that anyone on the team can check.

Client Billing Hub

Get the finished file

Client Billing Hub

Generate invoices from a client list and see who has paid, who hasn’t and how late they are.

See it on Taskdale →

Scroll to Top