ShareYourGroupShareYourGroupGoogle Sheets

Logical

IF and IFS functions in Google Sheets

IF returns one value when a condition is true and another when it is false; IFS checks several conditions in turn.

IF is how a sheet decides. It asks a question with a yes-or-no answer and shows one thing for yes and another for no. IFS handles several questions in a row without brackets nesting inside each other.

Syntax

=IF(logical_expression, value_if_true, value_if_false)
=IFS(condition1, value1, [condition2, value2], ...)
ArgumentWhat it is
logical_expressionA test that is true or false, such as C2>=33.
value_if_true, value_if_falseWhat to return in each case.
condition1, value1, ...For IFS: pairs of test and result. The first true test wins.

Examples

Sample sheet: Marks of eight students in three subjects. One Science mark is missing (cell D6 is empty).
ABCDE
1NameClassMathsScienceEnglish
2Asha8A788591
3Ravi8B455260
4Meena8A928879
5Kabir8B334138
6Tara8A6772
7Joy8B889084
8Neha8A546158
9Imran8B787369

IF

Three parts: the test, the result when it is true, the result when it is false.

The test is a comparison using =, <>, >, <, >= or <=. Text inside the formula goes in double quotation marks. Numbers and cell references do not.

In Sheets, the third argument may be left out. A false test then returns FALSE. Returning "" leaves the cell looking empty.

IFS

IFS takes pairs: a test, then the result if it is true. It reads them from left to right and stops at the first true one. Order therefore matters. Test the highest boundary first.

IFS has no "otherwise". If no test is true, it returns #N/A. End the list with TRUE and a default value to catch everything else, as in the fourth example.

AND, OR, NOT

Combine tests inside IF: AND(a, b) needs both, OR(a, b) needs one, NOT(a) reverses.

IF down a whole column

Inside ARRAYFORMULA, IF evaluates row by row:

=ARRAYFORMULA(IF(A2:A="", "", IF(C2:C>=33, "Pass", "Fail")))

The outer IF keeps empty rows empty. This pattern, a guard on a column that is always filled, appears in almost every self-filling column in Sheets.

Two cautions for arrays:

Blank is not zero

An empty cell compared with a number counts as 0, so D6>=33 is false for an absent student, and the formula would say "Fail". Test for the blank first, as the second example does.

Tick boxes

A tick box in Sheets holds TRUE or FALSE. That makes it a ready-made test: =IF(B2, "Done", "Pending").

Other ways to choose

Common mistakes

In Excel

IF and IFS are the same in Excel. IFS needs Excel 2019 or later. In Excel, IF's value_if_false is also optional.

Related functions

The results on this page were worked out by us from the sample sheet; they were not produced by a script running Google Sheets. If Sheets shows you something different, please tell us.

This is an independent help site. It is not connected with or approved by Google. Google Sheets is a trademark of Google LLC, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.