Sub topic 3
IFS: testing several conditions in order
Prerequisites: You should know how to enter formulas in Google Sheets, use cell references such as B2, compare values with operators such as >=, and write a basic IF formula.
IFS evaluates several logical tests in sequence. It returns the value associated with the first condition that evaluates to TRUE. This makes IFS useful when one cell can fall into several categories, such as grade bands, price levels, or status labels.
The basic structure
The syntax is:
=IFS(condition1, value1, condition2, value2, ...)Each condition is followed by the result to return when that condition is true. The pairs are checked from left to right.
Suppose B2 contains a test score:
=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F")The formula checks whether the score is at least 90. If not, it checks whether it is at least 80, then 70. The final TRUE condition matches every remaining value, so scores below 70 receive "F".
| Score | First matching condition | Result |
|---|---|---|
| 95 | `B2>=90` | A |
| 84 | `B2>=80` | B |
| 72 | `B2>=70` | C |
| 61 | `TRUE` | F |
The result values can be text, numbers, dates, or formulas. Text results must be enclosed in quotation marks.
Why the order matters
IFS stops at the first true condition. It does not search for the most specific or highest threshold automatically.
This formula has the conditions in the wrong order:
=IFS(B2>=70,"C",B2>=80,"B",B2>=90,"A",TRUE,"F")For a score of 95, B2>=70 is already true. Sheets therefore returns "C" and never reaches the tests for 80 or 90.
Put broader lower thresholds after narrower higher thresholds:
=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F")For range-based tests, arrange conditions from the highest threshold to the lowest, or otherwise ensure that an earlier condition cannot incorrectly capture a value intended for a later condition.
Use a fallback condition
If no condition is true, IFS returns #N/A. A final TRUE condition provides a fallback:
=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F")Because TRUE is always true, it catches every value that did not match an earlier test. You can use a text fallback for unexpected input:
=IFS(B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"Check score")Be aware that comparisons with blank or non-numeric input may produce an unintended classification. If the input must be validated first, add a condition for that case before the numeric tests.
=IFS(B2="","Missing",B2<0,"Invalid",B2>=90,"A",B2>=80,"B",B2>=70,"C",TRUE,"F")This formula checks exceptional cases first, then applies the grade rules.
Check your formula
When an IFS result seems wrong, inspect the conditions in order. Ask:
- Could an earlier condition match values intended for a later condition?
- Is every condition followed by its result?
- Is there a final fallback such as
TRUE,"Unknown"? - Are text results enclosed in quotation marks?
- Could a blank, text value, or negative number need its own condition?
Exercise
Write an IFS formula that returns "High" for values of 100 or more, "Medium" for values of 50 through 99, and "Low" for values below 50 in cell C2.
Show answer
=IFS(C2>=100,"High",C2>=50,"Medium",TRUE,"Low")