0Pricing
Excel Formulas Academy · Lesson

How the IF Function Thinks

Learn the test, value-if-true, and value-if-false structure of IF.

How the IF Function Thinks is a free Excel Formulas Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Excel Formulas Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Meet the IF Function

So far your formulas always gave the same kind of answer. The IF function lets a spreadsheet decide between two outcomes based on a question.

Think of it like a fork in the road: if something is true, go one way; otherwise, go the other way. This single idea powers grading, status labels, discounts, and much more.

The Three Parts of IF

Every IF formula has exactly three pieces, separated by commas:

  • The test — a question that is either true or false
  • Value if true — what to show when the test passes
  • Value if false — what to show when it fails

In plain words: IF (this is true), show this, otherwise show that.

=IF(test, value_if_true, value_if_false)

A First Real Example

Imagine a quiz score sits in cell A2. You want to label it Pass or Fail. A passing score is 60 or more.

The test is A2 >= 60. If that is true, show "Pass"; if false, show "Fail".

Notice the text outcomes are wrapped in double quotes so the spreadsheet treats them as words, not formulas.

=IF(A2 >= 60, "Pass", "Fail")

How the Spreadsheet Reads It

When you press Enter, the spreadsheet does this in order:

  • Looks at the value in A2
  • Checks the question A2 >= 60 and gets back TRUE or FALSE
  • If TRUE, it returns the first result; if FALSE, it returns the second

If A2 holds 72, the answer is Pass. If it holds 45, the answer is Fail.

The Test Is Always a Yes/No Question

The first argument of IF must boil down to just two possibilities: TRUE or FALSE. Nothing in between.

Questions like "Is this number bigger than 100?" or "Does this cell equal Yes?" work perfectly. A vague request like "How big is this?" does not, because there is no single yes-or-no answer.

=IF(B2 = "Yes", "Confirmed", "Pending")

Returning Numbers Instead of Text

The two outcomes do not have to be text. They can be numbers, blank, or even other formulas.

Say orders over 100 units earn a bonus of 50, and smaller orders earn 0. Put the order size in A2:

Numbers are not wrapped in quotes. Only text needs quotation marks.

=IF(A2 > 100, 50, 0)

Reading IF Out Loud

A great habit is to read your formula like a sentence before trusting it.

The formula =IF(A2 >= 60, "Pass", "Fail") reads as: If A2 is at least 60, show Pass, otherwise show Fail.

If the sentence makes sense out loud, the formula usually works. If it sounds confusing, the logic probably needs fixing.

Worked Example: Stock Status

A store tracks how many units remain in column B. They want a clear label in column C.

The rule: 10 or fewer left means Reorder, otherwise OK. For row 2:

Drag this down and every product instantly gets a status that updates the moment the stock numbers change.

=IF(B2 <= 10, "Reorder", "OK")

IF Reacts to Changes

The magic of IF is that it is live. The result is not typed by hand; it is calculated.

If you change the stock number in B2 from 8 to 25, the status flips from "Reorder" to "OK" automatically. You never edit the label yourself.

This is why a formula beats typing answers manually: it keeps your sheet correct as the data changes.

Comparing Two Cells

The test can compare one cell to another, not just to a fixed number.

Suppose A2 holds actual sales and B2 holds the target. To see whether the target was met:

Here the question is "Is A2 at least as big as B2?" and the answer drives the label.

=IF(A2 >= B2, "Target met", "Below target")

Both Excel and Google Sheets

Good news: IF works identically in Microsoft Excel and Google Sheets. The same formula you write in one will run unchanged in the other.

The structure never varies: a test, a true result, and a false result, separated by commas and wrapped in parentheses after =IF.

Quick Check

Test your understanding of how IF is structured.

Recap: How IF Thinks

You learned the heart of logical formulas:

  • IF chooses between two outcomes based on a test
  • It always has three parts: test, value_if_true, value_if_false
  • The test must be a yes/no question that resolves to TRUE or FALSE
  • Text outcomes need quotes; numbers do not
  • Results update live as your data changes

Next you will sharpen the comparisons that power the test itself.

=IF(A2 >= 60, "Pass", "Fail")

Frequently asked questions

Is the “How the IF Function Thinks” lesson free?

Yes — the full text of “How the IF Function Thinks” is free to read here on the web, and the Excel Formulas Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Excel Formulas Academy course, upgrade to CoddyKit PRO.

What will I learn in “How the IF Function Thinks”?

Learn the test, value-if-true, and value-if-false structure of IF. You practise Excel Formulas Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Excel Formulas Academy?

No prior experience is required. Excel Formulas Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “How the IF Function Thinks” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Excel Formulas Academy lesson?

Yes. Every Excel Formulas Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. How the IF Function Thinks
  2. Comparing Values With Operators
  3. Returning Text or Numbers From IF
  4. Common IF Mistakes to Avoid
← Back to Excel Formulas Academy