Spreadsheet Practice

How to write an IF formula with three outcomes in Excel

Formula (Excel and Google Sheets)

=IF(C2>B2,"Over budget",IF(C2<B2,"Under budget","On budget"))

Nest a second IF in the FALSE branch: =IF(C2>B2,"Over budget",IF(C2<B2,"Under budget","On budget")).

Result on the example
one result per row in D2, filled down to D6
Works in
Every current version
Google Sheets
Same formula

See it work

The formula is already in D2, filled down to D6. Change any input and the result updates, or edit the formula to experiment.

How it works

The first IF settles one outcome. Its FALSE branch holds a second IF that separates the other two. When neither test is TRUE the amounts are equal, so the last result needs no test of its own.

=IF(C2>B2,"Over budget",IF(C2<B2,"Under budget","On budget"))

Result"Over budget"

  1. C2$53,200

    The value in C2.

  2. B2$50,000

    The value in B2.

  3. C2>B2TRUE

    The > operator tests greater than.

  4. C2<B2FALSE

    The < operator tests less than.

  5. IF(C2<B2,"Under budget","On budget")"On budget"not used

    IF: Returns one value if a test is true, another if false.

    • logical_testC2<B2FALSE
    • value_if_true"Under budget"not used
    • value_if_false"On budget"
  6. IF(C2>B2,"Over budget",IF(C2<B2,"Under budget","On budget"))"Over budget"

    IF: Returns one value if a test is true, another if false.

    • logical_testC2>B2TRUE
    • value_if_true"Over budget"
    • value_if_falseIF(C2<B2,"Under budget","On budget")"On budget"not used

In Google Sheets

The same formula works in Google Sheets: =IF(C2>B2,"Over budget",IF(C2<B2,"Under budget","On budget")). We ran it in Google Sheets mode on the same data and it returns the same results.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=IFS(C2>B2,"Over budget",C2<B2,"Under budget",TRUE,"On budget")Over budget, Under budget, On budget…IFS lists the cases without nesting. Excel 2019 and later, and Google Sheets.
=SWITCH(SIGN(C2-B2),1,"Over budget",-1,"Under budget","On budget")Over budget, Under budget, On budget…SIGN returns 1, -1 or 0, and SWITCH maps each to a label.

Common mistakes

  • Exact equality is rare with real amounts. Allow a tolerance: =IF(ABS(C2-B2)<=B2*1%,"On budget",IF(C2>B2,"Over budget","Under budget")).
  • Each IF you open needs its own closing bracket at the end. Count them when Excel reports a problem with the formula.

Try it yourself

Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.

Write an IF formula with three outcomes

In D2, show "Over budget", "Under budget" or "On budget" by comparing the actual with the budget. Fill down to D6.

Questions

How do I label numbers as positive, negative or zero?

=IF(A2>0,"Positive",IF(A2<0,"Negative","Zero")).

How do I add a fourth outcome?

Nest another IF in the last FALSE branch, or switch to IFS, which reads better past three outcomes.

Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.