Sub topic 9
A cleaner alternative: IFS
Nested IF formulas work, but each extra outcome adds another IF( at the front and another ) at the end. IFS removes that nesting. You list pairs of a test and a result, and Sheets returns the result for the first test that is true.
This chapter assumes you can write a single IF with a test, a value if true, and a value if false. It also assumes you know comparison operators, AND and OR, and the difference between B2 and $B$2. If nested IF is new to you, read the previous chapter first, because IFS is easiest to understand as a rewrite of it.
The shape of IFS
The syntax is a repeating pattern of test and result:
=IFS(test1, result1, test2, result2, test3, result3, ...)Sheets works through the pairs from left to right. It returns the result of the first test that evaluates to TRUE and ignores every pair after that one. Here is the grade formula from the nested IF chapter, rewritten:
=IFS(B2>=90, "A", B2>=80, "B", B2>=70, "C", TRUE, "F")Here is the same logic as a nested IF, for comparison:
=IF(B2>=90, "A", IF(B2>=80, "B", IF(B2>=70, "C", "F")))Both formulas give the same grades. The IFS version has one pair per outcome, one closing parenthesis, and no counting of brackets at the end.
How Sheets evaluates it
For a score of 83, the first test is FALSE and the second is TRUE, so the formula returns "B". The tests for 70 and for the default are never reached.
The default value: why TRUE appears at the end
IF has a built-in "otherwise" argument, the value if false. IFS has no such argument. If every test is FALSE, IFS returns the error #N/A. Look at this formula:
=IFS(B2>=90, "A", B2>=80, "B", B2>=70, "C")A score of 65 matches none of the tests, so the cell shows #N/A. The usual fix is to add a final pair whose test is always true:
=IFS(B2>=90, "A", B2>=80, "B", B2>=70, "C", TRUE, "F")TRUE is a test that can never fail, so it catches every row that reached it. It plays the same role as the last value-if-false in a nested IF. Any other expression that is always true, such as 1=1, also works, but TRUE is the clearest.
You may sometimes want the #N/A. If a row should never fall through, an error is a visible signal that the data contains something unexpected. A silent default of "F" would hide that. Decide on purpose which behavior you want.
Order still decides the answer
IFS stops at the first true test, so the order of the pairs matters just as it does in nested IF. With thresholds that use >=, list the largest threshold first:
=IFS(B2>=70, "C", B2>=80, "B", B2>=90, "A", TRUE, "F")This formula is wrong. A score of 95 satisfies B2>=70 first, so the result is "C", and the tests for 80 and 90 are never checked. No error appears. The formula runs and returns a wrong answer, which makes this mistake easy to miss.
The rule is the same one you used for nested IF:
- With
>=or>, go from the highest threshold to the lowest. - With
<=or<, go from the lowest threshold to the highest. - If the tests are mutually exclusive, such as
A2="Paid"andA2="Pending", the order does not affect the result.
IFS with text tests
IFS is not limited to numbers. When you map several status labels to actions, each pair compares a cell to a quoted string:
=IFS(A2="Paid", "Done", A2="Pending", "Follow up", A2="Refunded", "Close", TRUE, "Check status")Remember two rules from the comparison chapter. Text must be in straight double quotes, and = ignores case, so "paid" and "PAID" both match the first test. A cell containing "Paid " with a trailing space does not match, and falls to the default. If a status column gives surprising results, a stray space is a common cause.
Combining AND and OR inside IFS
Each test can be any expression that returns TRUE or FALSE, including AND, OR, and NOT. Here is a three-way outcome based on two scores:
=IFS(AND(B2>=50, C2>=50), "Pass both", OR(B2>=50, C2>=50), "Pass one", TRUE, "Fail both")The order helps here. By the time Sheets checks the second test, it already knows the first test failed. So OR(B2>=50, C2>=50) can only be true when exactly one score passes. You do not need to write "one passes and the other fails" explicitly. This is one of the places where IFS reads more naturally than nested IF, because each line states a single case.
Thresholds in cells
Hard-coded numbers in a formula are hard to change. As with a single IF, you can move thresholds into cells and use absolute references so they stay fixed when you copy the formula down. Suppose F1 holds 90, F2 holds 80, and F3 holds 70:
=IFS(B2>=$F$1, "A", B2>=$F$2, "B", B2>=$F$3, "C", TRUE, "F")When the grade boundaries change, you edit three cells instead of every formula. This keeps the formula the same in every row, which makes it easier to check.
Blank cells and IFS
A blank cell compared with a number behaves like zero. In the grade formula, an empty B2 fails the three score tests and falls to the TRUE pair, so the row shows "F" even though no score was entered. Guard against this with an outer IF, as you did with a single IF:
=IF(B2="", "", IFS(B2>=90, "A", B2>=80, "B", B2>=70, "C", TRUE, "F"))The outer IF handles the blank case and returns an empty string. Only rows with a score reach the IFS. You can also put the blank test inside IFS as the first pair:
=IFS(B2="", "", B2>=90, "A", B2>=80, "B", B2>=70, "C", TRUE, "F")Both versions work. The second is a single function call, and the blank case reads as one more outcome in the list. Because the blank test is first, it runs before the others.
Errors you may see
| Symptom | Likely cause | Fix |
|---|---|---|
| `#N/A` in some rows | No test was true and there is no default pair | Add `TRUE, "default"` at the end, or confirm the error is intended |
| A parse error about the number of arguments | An odd number of arguments, so one test has no result or one result has no test | Count the arguments and check each test has a result after it |
| `#VALUE!` | A test returns text or something other than TRUE or FALSE, such as `A2` alone holding a word | Turn it into a comparison, for example `A2="Paid"` |
| A wrong result with no error | Pairs are in the wrong order | Reorder so the most specific or highest threshold is first |
| Text never matches | Missing quotes, curly quotes, or a trailing space in the cell | Use straight quotes and check the cell contents with `LEN` |
The argument-count error is worth understanding. IFS needs an even number of arguments, because every test needs a result. When you add a new outcome in the middle of a long formula, it is easy to add the test and forget the result.
Should you wrap IFS in IFERROR?
You can write =IFERROR(IFS(...), "No match") to replace the #N/A from an unmatched row. This works, but it also hides every other error, such as a divide-by-zero inside one of the tests. A TRUE pair handles the "nothing matched" case without hiding real problems. Use IFERROR when you want to catch errors from the data itself, as the IFERROR chapter shows. Use a TRUE default for unmatched cases.
IFS or nested IF?
| Point | Nested IF | IFS |
|---|---|---|
| Reading | Each level sits inside the previous one | One test and result per outcome |
| Closing parentheses | One per IF, easy to miscount | One at the end |
| Default value | The final value-if-false | Needs an explicit `TRUE` pair |
| Unmatched row | Returns the final fallback | Returns `#N/A` without a default |
| Best for | Two or three outcomes | Four or more outcomes |
For a simple two-outcome decision, a plain IF is still the shortest choice. IFS pays off from about three outcomes upward, when the nesting would start to obscure the logic. Whichever you choose, use the same one throughout a sheet so that other people know what to expect.
Worked example: shipping tiers
A sheet has order weights in kilograms in column B. Orders up to 1 kg ship for 4, up to 5 kg for 9, up to 20 kg for 25, and anything heavier needs a manual quote. Blank rows should stay blank.
=IFS(B2="", "", B2<=1, 4, B2<=5, 9, B2<=20, 25, TRUE, "Quote needed")The tests use <=, so the thresholds run from smallest to largest. The first pair handles blanks. The numbers 4, 9, and 25 are returned as numbers, so you can sum the column later, while "Quote needed" is text and SUM ignores it. The TRUE pair catches weights above 20 kg.
For a weight of 3, the blank test is FALSE, B2<=1 is FALSE, and B2<=5 is TRUE. The formula returns 9 and stops.
Exercise
This formula should label scores as "High" (80 or more), "Medium" (50 to 79), or "Low" (below 50). It returns "Medium" for a score of 95. Explain why, and write the corrected formula: =IFS(B2>=50, "Medium", B2>=80, "High", TRUE, "Low")
Show answer
IFS stops at the first true test. A score of 95 satisfies B2>=50 first, so "Medium" is returned and the test for 80 is never reached. List the highest threshold first: =IFS(B2>=80, "High", B2>=50, "Medium", TRUE, "Low")
Exercise
A column holds the statuses "Open", "Closed", and "On hold". Write an IFS formula for A2 that returns "Work on it", "Archive", and "Wait" respectively. Any other value, including a blank cell, should return "Check status". What does the formula return if you leave out the TRUE pair and A2 contains "Cancelled"?
Show answer
=IFS(A2="Open", "Work on it", A2="Closed", "Archive", A2="On hold", "Wait", TRUE, "Check status"). Without the TRUE pair, "Cancelled" matches no test, so the formula returns #N/A.
Exercise
Write one formula that returns "Bonus" when both B2 (sales) and C2 (calls) are at least 100, "Coach" when only one of them is at least 100, "Review" when neither is, and an empty string when B2 is blank.
Show answer
=IFS(B2="", "", AND(B2>=100, C2>=100), "Bonus", OR(B2>=100, C2>=100), "Coach", TRUE, "Review"). The blank test goes first so that empty rows are not graded. The AND test goes before OR, so by the time OR is checked, at most one condition can be true.