Going Stellar

Home/Google Sheets reference

Google Sheets function · Logical

IFS in Google Sheets: syntax and examples

IFS replaces a long chain of nested IF calls. It reads test and result pairs from left to right and returns the result of the first test that is TRUE.

Syntax

IFS(condition1, value1, [condition2, value2], …)

Arguments

ArgumentTypeRequiredWhat it does
condition1booleanyesThe first test. If it is TRUE, value1 is returned.
value1anyyesThe result when condition1 is TRUE.
condition2, value2, …anynoMore test and result pairs, checked in order. The first TRUE test wins.

Examples

The examples use this table, starting in A1:

NameScoreRegion
Ana95North
Bob72South
Cris55East
=IFS(B2>=90, "A", B2>=70, "B", B2>=50, "C")

Result: A

A score of 95 meets the first test, so the result is A. Later tests are not used.

Run in a Google Sheet (English US locale) on .

=IFS(B3>=90, "A", B3>=70, "B", TRUE, "F")

Result: B

72 fails the first test and meets the second. TRUE as the last test works as a catch-all.

Run in a Google Sheet (English US locale) on .

=IFS(B4>=90, "A", B4>=70, "B", TRUE, "F")

Result: F

55 reaches the catch-all TRUE and returns F.

Run in a Google Sheet (English US locale) on .

=ARRAYFORMULA(IFS(B2:B4>=90, "A", B2:B4>=70, "B", TRUE, "F"))

Result:

A
B
F

The same grading on the whole column, one result per row.

Run in a Google Sheet (English US locale) on .

=IFS(C3="North", 1, C3="South", 2, C3="East", 3)

Result: 2

Text conditions work too. South is the second test, so the result is 2.

Run in a Google Sheet (English US locale) on .

Common errors

  • If no test is TRUE, IFS returns #N/A. Add TRUE as the last test with a default value, for example TRUE, "other".
  • The arguments must come in pairs. An odd number, such as a test without a value, returns #N/A.
  • Tests run in order, so put the narrowest one first. With B2>=50 before B2>=90, a score of 95 would return the lower grade.

Compared with Excel

Same syntax as Excel IFS. Excel has no catch-all argument either, so TRUE as the last test is the usual trick in both.

Questions and answers

Is IFS better than nested IF?

For three or more branches, yes: each test and result sits next to each other. For one or two branches, a plain IF is shorter.

Sources

  1. IFS (Docs Editors Help)

Markdown version · All functions