The Excel IF formula checks a condition and returns one result when it is true and another when it is false.

These examples show how to build and adapt IF formulas, including a few edge cases that often cause unexpected results.

Excel IF formula syntax

The IF function uses three arguments: a condition to test, the value to return if that condition is true, and the value to return if it is false.

=IF(logical_test, value_if_true, value_if_false)

For example, if cell A2 contains a test score, this formula labels scores of 70 or higher as passing:

=IF(A2>=70, "Pass", "Try again")

If A2 contains 82, the result is Pass.

If it contains 65, the result is Try again.

The comparison operator >= means “greater than or equal to.”

In many English-language Excel installations, commas separate function arguments.

Some regional settings use semicolons instead, so the same formula may need to be written as =IF(A2>=70; "Pass"; "Try again").

Basic Excel IF formula examples

Compare a number with a threshold

Suppose column A contains order totals and an order qualifies for free shipping at $50.

Enter this formula in B2 and copy it down:

=IF(A2>=50, "Free shipping", "Shipping fee")

For a total of 64, the result is Free shipping.

For a total of 38, the result is Shipping fee.

Return a number instead of a label

IF can return numbers that you can use in later calculations.

If A2 contains sales and a bonus of 100 applies at 1,000 or more, use:

=IF(A2>=1000, 100, 0)

This returns 100 when the condition is true and 0 otherwise.

You can sum the resulting values in column B with =SUM(B2:B20).

Show a blank when a condition is false

To display a due date only when a status cell says Open, use:

=IF(A2="Open", B2, "")

The empty string "" makes the cell appear blank when the status is not Open.

The cell still contains a formula, so it is not truly empty.

Functions that count nonempty cells, such as COUNTA, may count it.

IF formulas with text and dates

Check whether a cell contains specific text

Text comparisons in formulas use quotation marks.

To flag rows where the category in A2 is Urgent, enter:

=IF(A2="Urgent", "Prioritize", "Standard")

Excel's usual text comparisons are not case-sensitive, so urgent and Urgent generally match.

To test case exactly, use EXACT inside IF:

=IF(EXACT(A2, "Urgent"), "Prioritize", "Standard")

Compare a date with today

If B2 contains a due date, this formula checks whether it is overdue:

=IF(B2<TODAY(), "Overdue", "On time")

TODAY() returns the current date and updates when the workbook recalculates.

A date equal to today is labeled On time because the test uses <, not <=.

Make sure B2 contains a real Excel date value; text that merely looks like a date may not compare as expected.

Combine IF with AND and OR

Use AND when every condition must be true.

For example, if a student passes with a score of at least 70 and attendance of at least 80%, with score in A2 and attendance in B2:

=IF(AND(A2>=70, B2>=80%), "Pass", "Review")

Use OR when any listed condition is enough.

This example grants a discount when the order total is at least 100 or the customer is marked as a member in B2:

=IF(OR(A2>=100, B2="Yes"), "Discount", "Regular price")

In both formulas, IF returns one outcome for a true logical test and the other for a false test.

If a cell may contain an error, such as #N/A, the condition may also return an error instead of either label.

Use multiple outcomes with nested IF

A nested IF places another IF function in one of the result arguments.

For score bands—90 or above is A, 80 or above is B, 70 or above is C, and anything lower is D—use:

=IF(A2>=90, "A", IF(A2>=80, "B", IF(A2>=70, "C", "D")))

Excel evaluates the tests from left to right.

A score of 85 fails the first test but passes the second, so the result is B.

Put the most demanding threshold first; reversing the order can cause a high score to match a lower band too early.

For several categories, IFS can be easier to read:

=IFS(A2>=90, "A", A2>=80, "B", A2>=70, "C", TRUE, "D")

IFS is available in Excel 2019 and Microsoft 365.

For older Excel versions, nested IF is a more compatible option.

Google Sheets supports both IF and IFS.

Common IF formula mistakes

  • Missing quotation marks around text: Write "Complete", not Complete, when returning a text label.
  • Using the wrong comparison operator: = tests equality, while >, <, >=, and <= test number or date relationships. “Not equal to” is <>.
  • Testing a blank cell incorrectly: To check whether A2 is blank, use =IF(A2="", "Missing", "Entered").

    A formula that returns "" also compares as an empty string here.
  • Forgetting the false result: If you omit the third argument, Excel returns FALSE when the condition is false.

    Add a result such as "No" or 0 if that is clearer.
  • Expecting IF to handle errors automatically: IF evaluates its condition first.

    To replace errors from a calculation, use IFERROR, for example =IFERROR(A2/B2, "Check values").

Compatibility and choosing a formula

The basic IF, AND, OR, and TODAY functions are available in modern Excel versions and Google Sheets.

Use nested IF for broad compatibility when you need several outcomes.

Use IFS when your Excel version supports it and a sequence of conditions is easier to maintain that way.

For a single two-way decision, a straightforward IF formula is usually easiest to check.

For a large mapping of categories to results, a lookup table with XLOOKUP or VLOOKUP may be more manageable than a long chain of nested conditions.