Logical · the decision foundation · Nov 2026

The IF function,
decided & explained.

Syntax, a live decision playground, the short-circuit rule that guards your divides, and a real-world error library: make every branch return exactly what you mean — and know when to reach for IFS instead.

D1
fx
=IF(B2>=60, "Pass", "Fail")
0
arguments
0
max nested levels
0
sourced errors fixed
// 01 — Anatomy

How IF works

IF runs a logical test and returns one of two values. It is the foundation of every conditional formula — and the building block you nest, combine with AND/OR, or replace with IFS when branches multiply.

=IF(logical_test, value_if_true, value_if_false)
logical_testAny expression that resolves to TRUE or FALSE: B2>=60, A2="Yes", AND(...), ISBLANK(...).
value_if_trueReturned when the test is TRUE. A value, text, reference, or another formula.
value_if_falseReturned when the test is FALSE. Optional — omit it and FALSE returns the logical value FALSE.
// 02 — The decision gallery

How IF actually decides

Three arguments, two branches, one short-circuit rule. The gallery below is the mental model — load any row into the playground to watch the engine evaluate it live.

The truth table

logical_testreturns
TRUEvalue_if_true
FALSEvalue_if_false
B2>=60 (92)"Pass"
B4>=60 (58)"Fail"

If you omit value_if_false, a FALSE test returns the logical value FALSE — not 0, not blank.

The short-circuit proof

IF evaluates only the branch it returns. The unused branch is never computed — even if it would error.

=IF(TRUE(),"safe",1/0)"safe"
=IF(FALSE(),"safe",1/0)#DIV/0!

This is why nested IF guards a divide safely, while AND(B2<>0, A2/B2>1) does not — AND evaluates every argument.

Nested IF vs IFS

Nested IFIFS
Max depth64 levels127 pairs
Readabilitypyramidflat
Else / defaultbuilt-inadd TRUE()
SincealwaysExcel 2016

Rule of thumb: ≤2 branches → IF; 3+ flat bands → IFS with a TRUE(),"default" tail.

// 03 — Try it live

Interactive IF playground

Edit the score data or type any formula — the HyperFormula engine evaluates it instantly. Load a preset to see nesting, AND/OR, blank checks and the short-circuit rule in action.

A1Sample data — click any cell to edit, the formula re-evaluates live
Result
—
✓ readyHyperFormula 3.5
// 04 — Error library

The real-world error library

14 failure patterns mined from actual user reports on Reddit, Stack Overflow and Super User — each with the authentic symptom, root cause, a fix, and a runnable formula. Not textbook theory.

// 05 — Cross-platform

Where IF works

IF is universal; the modern helpers (IFS, SWITCH) are not. Where each lands across eight platforms.

PlatformSupportNotesGotcha
✓ Supported full IF◐ Partial works with caveatsCompiled from public docs · verify against your build
// Go deeper

Master the logical family

IF is the gateway. The full course walks the decision toolkit end to end — AND/OR/XOR, IFS & SWITCH, the IS* tests, and how to compose them with lookups without the classic short-circuit and blank-cell traps.

  • IF · IFS · SWITCH — choosing the right branch tool
  • AND / OR / XOR / NOT — combining conditions safely
  • ISBLANK / ISERROR / ISNUMBER — bulletproof tests
  • Composing IF with VLOOKUP / XLOOKUP for real workflows
Free while in beta
Browse the function library

No account needed. Every page has a live playground.

// 07 — FAQ

Frequently asked