Sub topic 3
IFS: testing several conditions in order
This chapter assumes you can enter and edit formulas in Google Sheets and use cell references and ranges such as B2 and A:A. It also assumes you know the comparison operators (=, <>, >, >=, <, <=) and have used the basic IF function. By the end you will be able to write an IFS formula that returns a value for the first condition that is true, and you will know the mistakes that most often break one.
Why IFS exists
IF chooses between two outcomes. To choose between four, you nest one IF inside another. A letter-grade formula with three thresholds looks like this:
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C","F")))This works, but every tier adds another IF( at the front and another ) at the end. When you edit the middle tier, you have to keep track of which closing parenthesis belongs to which IF. A missing parenthesis is easy to make and hard to find.
IFS writes the same decision as a flat list of pairs:
=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F")There is no nesting. Each tier is one condition followed by one result, so adding a tier means adding one pair.
The syntax
=IFS(condition1, value1, condition2, value2, ...)- A condition is any expression that evaluates to
TRUEorFALSE, such asB2>=90,A2="Paid", orAND(B2>0,C2<10). - A value is what the formula returns if the condition before it is true. It can be text, a number, a cell reference, or another formula.
- The arguments always come in condition and value pairs, so the total count must be even. If you leave out a value, Sheets rejects the formula with an error message about the number of arguments.
Sheets evaluates the pairs from left to right. At the first condition that is true, it returns that pair's value and stops looking. Every pair after it is ignored, even if its condition would also be true.
A worked example
Suppose a sheet holds exam scores in column B, and you want a letter grade in column C.
| Row | A | B | C |
|---|---|---|---|
| 1 | Student | Score | Grade |
| 2 | Ana | 95 | |
| 3 | Ben | 84 | |
| 4 | Chloe | 72 | |
| 5 | Dev | 58 |
Enter this in C2 and fill it down:
=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F")Here is what happens for each row:
- Ana scores 95.
95>=90is true, so the result is"A". The later pairs are never used. - Ben scores 84.
84>=90is false, so Sheets moves on.84>=80is true, so the result is"B". - Chloe scores 72. The first two tests are false and
72>=70is true, so the result is"C". - Dev scores 58. The first three tests are false. The last condition is the literal value
TRUE, which is always true, so the result is"F".
Notice that the conditions do not say "between 80 and 90". The test B2>=80 is enough for Ben, because anyone at 90 or above was already caught by the first pair. Each condition relies on the ones before it having failed. That is what makes IFS short, and it is also why the order matters.
Order changes the result
Because the first true condition wins, you must put the most restrictive condition first. Here the same tiers are in the wrong order:
=IFS(B2>=70,"C",B2>=80,"B",B2>=90,"A",TRUE,"F")For a score of 95, the first test 95>=70 is true, so the formula returns "C". The tests for "B" and "A" are never reached. Nothing in Sheets flags this as a problem, because the formula is valid and returns a plausible-looking value.
For descending thresholds like grades, test the highest threshold first. For ascending limits such as "under 10", "under 50", "under 100", test the smallest limit first. The next chapter covers ordering rules and the TRUE fallback in more detail.
What happens when nothing matches
If no condition in an IFS is true, the formula returns #N/A. Here is the grade formula without the final TRUE pair:
=IFS(B2>=90,"A",B2>=80,"B")A score of 95 gives "A" and a score of 84 gives "B". A score of 72 matches neither condition, so the cell shows #N/A. A blank score also fails every test, because a blank cell is treated as 0 in a comparison like B2>=90.
A final TRUE pair prevents this. Since TRUE is always true, it acts as an "everything else" branch, similar to the final ELSE in other languages. Unlike IF, IFS has no built-in else argument, so you add this branch yourself.
Conditions that combine tests
Each condition can be as complex as you need. Use AND, OR, and NOT to combine tests. For example, a support team might route tickets using priority in column B and hours open in column C:
=IFS(AND(B2="High",C2>24),"Escalate",B2="High","Handle today",C2>72,"Review",TRUE,"Normal")Read it as a list of rules, top to bottom:
- A high-priority ticket open more than 24 hours is escalated.
- Any other high-priority ticket is handled today.
- Any other ticket open more than 72 hours is reviewed.
- Everything else is normal.
The first rule is more specific than the second, so it must come first. If you swapped them, the second rule would catch every high-priority ticket and "Escalate" could never appear.
Conditions can also compare text. Comparisons with = are not case-sensitive in Sheets, so B2="high" matches "High" and "HIGH". Stray spaces still count, so "High " does not match "High". If your data comes from a form or an import, wrapping the cell in TRIM(B2) is a cheap safeguard.
Using IFS on a whole column
To grade every row with one formula instead of filling down, wrap IFS in ARRAYFORMULA:
=ARRAYFORMULA(IFS(B2:B20>=90,"A",B2:B20>=80,"B",B2:B20>=70,"C",TRUE,"F"))Use a bounded range such as B2:B20. With an open range like B2:B, the empty rows below your data are also tested. Blank cells fail the first three conditions, so the TRUE fallback fills every empty row down to the bottom of the sheet with "F".
Common mistakes
| Symptom | Likely cause | Fix |
|---|---|---|
| Every row returns the same low tier | Conditions are in the wrong order | Put the most restrictive condition first |
| `#N/A` in some rows | No condition matched and there is no `TRUE` fallback | Add `TRUE, "default"` at the end, or fix the data |
| An error about the number of arguments | A condition has no value, or a value has no condition | Count the arguments and make sure they pair up |
| A result is correct for most rows but wrong for exact boundary values | `>` used where `>=` was meant (or the reverse) | Check each threshold against the rule you were given |
| Text conditions do not match | Extra spaces or different spelling in the data | Use `TRIM` or check the source values |
When IFS is not the right tool
IFS is built for conditions that involve comparisons or ranges. If you are only checking one cell against a list of exact values, such as state codes or status labels, repeating A2="NY", A2="CA", and so on is more typing than necessary. SWITCH, covered later in this tutorial, is a shorter fit for that case. If you have only two outcomes, plain IF is still the clearest choice.
Exercise
A sheet has order totals in column B. Write one IFS formula for C2 that returns "Free" for totals of 100 or more, "Reduced" for totals of 50 or more but below 100, and "Standard" for everything else. Then say what the formula would return for a total of 100 if you wrote the "Reduced" pair first.
Show answer
=IFS(B2>=100,"Free",B2>=50,"Reduced",TRUE,"Standard"). If the "Reduced" pair (B2>=50) came first, a total of 100 would return "Reduced", because 100>=50 is true and IFS stops at the first true condition, so the "Free" pair would never be reached.
Exercise
What does =IFS(B2>=90,"A",B2>=80,"B") return when B2 is 72, and how would you change it so it returns "Below B" instead?
Show answer
It returns #N/A, because neither condition is true and IFS has no default. Add a final pair: =IFS(B2>=90,"A",B2>=80,"B",TRUE,"Below B").