← Back to blog

Excel IF Function: Syntax, Examples & Nested IF (2026 Guide)

The IF function is the gateway drug to spreadsheet logic. It tests a condition and returns one value if true, another if false. Once you know IF, you unlock nested IFs, IF + AND/OR, IFS, IFERROR and most of Excel's decision-making power. Here's everything you need.

Excel IF syntax

=IF(logical_test, value_if_true, value_if_false)

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

10 useful IF examples

=IF(B2>0, "Profit", "Loss")
=IF(C2="Paid", 0, D2)                    → outstanding amount
=IF(E2>1000, E2*0.1, 0)                  → 10% bonus over 1000
=IF(F2="", "Missing", F2)                → fill blanks
=IF(TODAY()>G2, "Overdue", "On time")
=IF(ISNUMBER(H2), H2*1.2, 0)             → guard against text
=IF(I2>=90,"A",IF(I2>=80,"B",IF(I2>=70,"C","F"))) → nested IF
=IF(AND(J2>0,K2="Yes"), "Ship", "Hold")
=IF(OR(L2="VIP",M2>5000), "Priority","Standard")
=IFERROR(VLOOKUP(N2,List!A:B,2,FALSE),"Not found")

Nested IF — when to use, when to stop

Nesting IFs works but gets ugly fast. After 2–3 levels, switch to IFS or a lookup table.

Old (nested IF):
=IF(A2<10,"XS",IF(A2<20,"S",IF(A2<30,"M",IF(A2<40,"L","XL"))))

Cleaner (IFS — Excel 2019+ / 365):
=IFS(A2<10,"XS",A2<20,"S",A2<30,"M",A2<40,"L",TRUE,"XL")

IF with AND, OR, NOT

=IF(AND(A2>0, B2>0), "Both positive", "")
=IF(OR(A2="VIP", B2>1000), "Discount", "")
=IF(NOT(C2="Cancelled"), "Active", "Inactive")

IFERROR — hide ugly errors

=IFERROR(A2/B2, 0)
=IFERROR(VLOOKUP(...), "—")

Common IF mistakes

  • Using = instead of >= or <= when the boundary matters.
  • Forgetting quotes around text values.
  • Comparing numbers stored as text (use VALUE() to convert).
  • Over-nesting IFs — switch to IFS, SWITCH, or VLOOKUP/XLOOKUP.
  • Returning text in cells later used in math.

Skip the blank spreadsheet

Pick from 90+ ready-made Excel templates or generate your own with AI.