Formula Guide

The Excel IF Function
explained simply

IF is Excel's decision-maker. Once you understand it you will use it in almost every spreadsheet. Here is the complete guide with 6 real examples.

ExcelPro · 6 min read · Updated June 2026
Contents
  1. What does IF do?
  2. Syntax
  3. 6 real examples
  4. Nested IF
  5. IF with AND / OR
  6. Common mistakes
  7. FAQ

What does IF do?

IF makes Excel make a decision. You give it a condition to test — if the condition is TRUE, it returns one result; if FALSE, it returns another. This lets your spreadsheet respond differently to different data automatically.

IF is the gateway to logic in Excel. Once you understand it, you can flag overdue invoices, calculate variable bonuses, label data automatically, and build dynamic dashboards that respond to changing numbers.

Syntax

=IF(logical_test, value_if_true, value_if_false)
ArgumentDescription
logical_test requiredA condition that evaluates to TRUE or FALSE. Examples: A2>100, B2="Yes", C2<>""
value_if_true requiredWhat to return when the condition is TRUE. Can be text (in quotes), a number, a formula, or a cell reference.
value_if_false requiredWhat to return when the condition is FALSE. Same options as value_if_true.
💡 Comparison operators

> greater than · < less than · >= greater or equal · <= less or equal · = equal · <> not equal

6 real examples

Example 1
Pass or fail
=IF(B2>=50, "Pass", "Fail")

If the score in B2 is 50 or above, show Pass. Otherwise show Fail.

Example 2
Calculate a bonus

Pay a 10% bonus only if sales exceed £5,000.

=IF(B2>5000, B2*0.1, 0)

Note: when returning a number or formula, no quotes are needed.

Example 3
Flag overdue invoices
=IF(C2<TODAY(), "Overdue", "Current")
Example 4
Check if a cell is empty
=IF(A2="", "Missing", "Complete")
Example 5
Avoid division by zero
=IF(B2=0, 0, A2/B2)

If the denominator is zero, return 0 instead of a #DIV/0! error.

Example 6
Apply different tax rates
=IF(B2>50000, B2*0.4, B2*0.2)

40% tax above £50,000; 20% below. The formula picks the right rate automatically.

Nested IF — more than two outcomes

Put an IF inside another IF to handle multiple outcomes. This is called nesting.

=IF(B2>=70, "First", IF(B2>=60, "2:1", IF(B2>=50, "2:2", "Fail")))
⚠️ Don't nest more than 3 deep

Deeply nested IFs are hard to read and maintain. Use IFS() for multiple conditions — it's cleaner and less error-prone.

Cleaner version using IFS: =IFS(B2>=70, "First", B2>=60, "2:1", B2>=50, "2:2", TRUE, "Fail")

IF with AND and OR

Test multiple conditions at once by combining IF with AND or OR.

Both conditions must be true (AND): =IF(AND(B2>=50, C2="Attended"), "Pass", "Fail") At least one condition must be true (OR): =IF(OR(B2>=90, C2="Distinction"), "Award", "Standard")

Common mistakes

⚠️ Forgetting quotes around text results

=IF(A2>10, Pass, Fail) will error. Text results need quotes: =IF(A2>10, "Pass", "Fail").

⚠️ Using = instead of == for comparison

In Excel, a single = is used for equality comparison inside IF. =IF(A2=10, ...) is correct. Do not use == like in other programming languages.

⚠️ Omitting the value_if_false argument

If you leave out value_if_false, Excel returns FALSE when the condition is not met, which can look confusing. Always include a third argument, even if it's just 0 or "".

FAQ

What is the difference between IF and IFS?
IF tests one condition and returns one of two results. IFS tests multiple conditions in order and returns the result for the first true one. Use IFS when you have three or more possible outcomes to avoid nested IFs.
Can IF return another formula as the result?
Yes. Both the true and false results can be formulas: =IF(A2>0, SUM(B2:B10), AVERAGE(C2:C10)). This makes IF very powerful for conditional calculations.
How many IFs can I nest?
Up to 64 levels in modern Excel. In practice, more than 3 or 4 becomes very hard to read and debug. Use IFS() or CHOOSE() for more than 3 outcomes.
Why does IF return TRUE or FALSE instead of my text?
You've probably forgotten the quotes around your text results. =IF(A2>10, Pass, Fail) returns TRUE or FALSE. =IF(A2>10, "Pass", "Fail") returns the text you want.

Practise IF formulas live

ExcelPro's Basics track has 6 IF exercises — from simple pass/fail to nested IFs and AND/OR logic. Free to start.

Try IF exercises free →

Related formulas

IFS IFERROR SUMIF COUNTIF AND OR