Logical

IF Function in Excel

Returns one value if a condition is TRUE and another value if it's FALSE.

Syntax

  • =IF(logical_test, value_if_true, [value_if_false])

Arguments

  • logical_test (required): The condition to evaluate
  • value_if_true (required): Value returned when condition is TRUE
  • value_if_false (optional): Value returned when condition is FALSE

Examples

  • =IF(A1>100, "Over budget", "OK") - Check if value exceeds budget - Result: "Over budget" or "OK"
  • =IF(B1="", "Empty", B1) - Handle empty cells - Result: Cell value or 'Empty'
  • =IF(AND(A1>0, B1>0), "Valid", "Invalid") - Multiple conditions - Result: "Valid" or "Invalid"

Overview

  • IF evaluates a test and returns one of two outcomes. For three or more branches, IFS is clearer than deep nested IFs — especially for grading, tiers, and status labels.

Patterns that stay readable

  • Pass/fail: =IF(A2>=60,"Pass","Fail").
  • Bonus flag: =IF(B2>10000,"Bonus","").
  • Test in helper: =AND(A2>0,B2<100) then IF(helper,...).

Migrate nested IF to IFS

  • Nested: =IF(A2>=90,"A",IF(A2>=80,"B","C")).
  • IFS: =IFS(A2>=90,"A",A2>=80,"B",TRUE,"C").
  • [IF vs IFS](/compare/if-vs-ifs/)

Combine with aggregates

  • IF avoids divide-by-zero: =IF(B2=0,"",A2/B2).
  • Pair with SUMIFS for conditional dashboards.

Quick answer: if function excel

  • IF tests a condition and returns one value if TRUE and another if FALSE. For three or more outcomes, prefer IFS in modern Excel.
  • Test logic in a helper cell (=A2>100) before writing a long IF.
  • IFS example: =IFS(A2>=90,"A",A2>=80,"B",TRUE,"C").
  • See [IF vs IFS](/compare/if-vs-ifs/) for branch-heavy rules.

IF formula strategy

  • Use IF for one clear logical test with one result for TRUE and another result for FALSE.
  • Use AND or OR inside IF when the decision depends on multiple tests.
  • Use IFS or SWITCH when nested IF formulas become difficult to read or maintain.

IFS migration from nested IF

  • Nested IF with three grades: =IF(A2>=90,"A",IF(A2>=80,"B","C")).
  • Same logic with IFS: =IFS(A2>=90,"A",A2>=80,"B",TRUE,"C").
  • See [IF vs IFS](/compare/if-vs-ifs/) when you have four or more branches.

Test logic in a helper cell first

  • Put =A2>100 in a helper column to verify the condition before wrapping a long IF.
  • Combine AND and OR inside IF when multiple tests must pass together.

People also ask

  • How many IFs can you nest? — Technically many, but IFS is clearer after 2–3 branches.
  • Can IF return text and numbers? — Yes, both outcomes can be different types.

Common errors

  • Nested IF limits (up to 64)
  • #VALUE! with incorrect syntax

Use cases

  • Conditional formatting logic
  • Grade calculations
  • Status checks
  • Data validation

Frequently asked questions

  • How many nested IFs can Excel handle? Many, but readability collapses after 2–3 levels. Use IFS instead.
  • Can IF return a number and text? Yes. TRUE and FALSE branches can be different types.
  • IF vs IFS vs SWITCH? IF for one test; IFS for ordered tiers; SWITCH for exact match to a list of values.
  • What is the IF function in Excel and how does it work? The IF function performs a logical test and returns one value if TRUE and another if FALSE. The syntax is =IF(logical_test, value_if_true, value_if_false). For example, =IF(A1>100, "Over Budget", "OK") checks if A1 is greater than 100 and returns "Over Budget" if true, or "OK" if false. It's the foundation of decision-making in Excel.
  • How do I use multiple IF conditions in Excel? For multiple conditions, you can: 1) Nest IF functions: =IF(A1>90, "A", IF(A1>80, "B", "C")); 2) Use IFS function (Excel 2019+): =IFS(A1>90, "A", A1>80, "B", TRUE, "C"); 3) Combine with AND/OR: =IF(AND(A1>50, B1>50), "Pass", "Fail"). IFS is cleaner for multiple conditions and avoids deep nesting.
  • What is the difference between IF and IFS in Excel? IF tests one condition and returns one of two values. IFS (available in Excel 2019/365) tests multiple conditions in sequence without nesting. IF syntax: =IF(test, true, false). IFS syntax: =IFS(test1, value1, test2, value2, ...). IFS is cleaner for multiple conditions but requires Excel 2019 or later. Use TRUE as the last condition in IFS for a default value.
  • How do I use IF with AND and OR functions? Combine IF with AND/OR for complex conditions. AND requires ALL conditions to be true: =IF(AND(A1>50, B1>50), "Pass", "Fail"). OR requires ANY condition to be true: =IF(OR(A1="Yes", B1="Yes"), "Approved", "Pending"). You can nest them: =IF(AND(A1>0, OR(B1="A", B1="B")), "Valid", "Invalid").
  • Why is my IF formula returning wrong results? Common IF formula issues: 1) Text comparisons need quotes: =IF(A1="Yes", not =IF(A1=Yes); 2) Number stored as text won't match numbers; 3) Extra spaces in cells - use TRIM(); 4) Case sensitivity - IF is not case-sensitive for text; 5) Missing value_if_false returns FALSE by default; 6) Comparing dates requires proper date values, not text.

Editorial review

  • Reviewed by Excel.Directory Editorial Team. Updated May 2026.