Skip to main content

Nested IF and IFS in Excel

Last updated

IFS checks several conditions in order and returns the result of the first one that is TRUE: =IFS(B2>=95,"A",B2>=85,"B",B2>=70,"C",TRUE,"D"). A nested IF does the same with one IF inside another. In both, put the strictest condition first, because Excel stops at the first TRUE test.

IFS syntax

=IFS(logical_test1, value_if_true1, [logical_test2, value_if_true2], …)

logical_test1
The first condition, such as B2>=95. With >= tests, start with the highest threshold.
value_if_true1
What to return when that test is the first TRUE one: a number, a text in double quotes or a calculation.
logical_test2, value_if_true2, …
More test and result pairs, up to 127. End with TRUE and a result to catch everything else, otherwise IFS returns #N/A when no test matches.

Practice nested IF and IFS here

Type your formula straight into the sheet. It’s checked like real Excel, and you can write it with commas or semicolons.

Exercise 1 of 1

Shipping fee with nested IF

Shipping costs 5 up to 1 kg, 9 up to 5 kg, and 15 above that. Fill C2:C6 with a nested IF.

OrderWeight (kg)Shipping ($)
SO-20510.8
SO-20523.5
SO-205312
SO-20541
SO-20555

How to write an IFS formula, step by step

  1. Write the bands down from the strictest to the loosest, for example 95, 85, 70.
  2. Type =IFS(, then the first test and its result: B2>=95,"A",.
  3. Add the next pairs in the same order: B2>=85,"B",B2>=70,"C",.
  4. Finish with TRUE,"D") for everything else, press Enter and check a value exactly on each threshold.

Nested IF and IFS examples

Shipping fee with nested IF

=IF(B2<=1,5,IF(B2<=5,9,15))

With <= tests, start with the smallest band: up to 1 kg costs 5, up to 5 kg costs 9, anything heavier 15.

Supplier rating with IFS

=IFS(B2>=95,"A",B2>=85,"B",B2>=70,"C",TRUE,"D")

Pairs of test and result, highest band first, and TRUE as the “otherwise”.

Commission tiers

=IF(B2>=50000,B2*8%,IF(B2>=20000,B2*5%,IF(B2>=10000,B2*3%,0)))

Each result can be a calculation. Three IFs need three closing brackets at the end.

Two conditions in one band

=IFS(AND(B2>=5000,C2>=10),"Platinum",B2>=5000,"Gold",TRUE,"Silver")

The test with the most conditions goes first, or every Platinum customer would stop at Gold.

Common nested IF and IFS mistakes and how to fix them

ResultCauseFix
Wrong band, no errorThe conditions are in the wrong order, e.g. B2>=100 before B2>=1000. A large value passes the small threshold first and stops there.With >= tests, go from the highest threshold down; with <= tests, from the lowest up.
#N/AIFS found no TRUE test because the last “otherwise” pair is missing.End the formula with TRUE,"…".
Value on the limit in the wrong band> used where the rule says “from” or “at least”.Use >= for “from”, and test a value exactly on each threshold.
#NAME?IFS in a version of Excel older than 2019, which doesn’t have it.Use a nested IF instead: it works in every version.

IFS vs nested IF vs a lookup table

IFS is easier to read when there are many bands: each test sits next to its result, and there is only one closing bracket. Nested IF works in every version of Excel and has a built-in “otherwise” in the last value_if_false. Both follow the same rule: the first TRUE test wins. When the bands are long or change often, put them in a small table and use VLOOKUP or XLOOKUP with an approximate match instead.

Frequently asked questions

What is the difference between IF and IFS?

IF tests one condition and has a result for TRUE and for FALSE. IFS lists several test and result pairs and returns the first TRUE one, so it replaces a chain of nested IFs.

Why does my nested IF always return the same band?

The tests are in the wrong order. With >=, a large value also passes the smaller thresholds, so test the largest first: =IF(B2>=10000,"Gold",IF(B2>=5000,"Silver","Bronze")).

How do I add an “else” to IFS?

Use TRUE as the last test: =IFS(B2>=90,"A",B2>=80,"B",TRUE,"C"). TRUE always matches, so it catches everything the other tests didn’t.

How many conditions can IFS take?

Up to 127 test and result pairs. Nested IF accepts up to 64 levels, but both get hard to read long before that.

Keep practising

All 5 nested IF and IFS exercises, with explanations and progress tracking.

Open the IFS practice set