# IF in Google Sheets: syntax and examples

URL: https://goingstellar.ro/reference/sheets/if/

IF runs a test and returns one result when it is TRUE and another when it is FALSE. Combine it with AND, OR and ARRAYFORMULA for multi-condition checks over whole columns.

## Syntax

```
IF(logical_expression, value_if_true, value_if_false)
```

## Arguments

- `logical_expression` (boolean, required: yes): The test. Anything that evaluates to TRUE or FALSE, such as B2>0.
- `value_if_true` (any, required: yes): What to return when the test is TRUE.
- `value_if_false` (any, required: no): What to return when the test is FALSE. If left out, a false test returns FALSE.

## Examples

The examples use this table, starting in A1:

| Item | Stock | Price |
|---|---|---|
| Lamp | 12 | 79.9 |
| Chair | 0 | 549 |
| Stand | 7 | 129.5 |
| Tray | 40 | 34 |

```
=IF(B2>0, "In stock", "Sold out")
```

Result: `In stock`

A basic yes or no label based on a number. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=IF(B3>0, "In stock", "Sold out")
```

Result: `Sold out`

The same formula on the row with zero stock. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=IF(C2>100, "Premium", IF(C2>50, "Mid", "Budget"))
```

Result: `Mid`

Nested IF: the second IF runs only when the first test is false, giving three tiers. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=IF(AND(B4>0, C4<150), "Offer", "Skip")
```

Result: `Offer`

AND inside the test: both conditions must hold for TRUE. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=ARRAYFORMULA(IF(B2:B5>0, "ok", "empty"))
```

Result: 

| ok |
|---|
| empty |
| ok |
| ok |

With ARRAYFORMULA one IF runs over the whole column and returns one label per row. Run in a Google Sheet (English US locale) on 2026-11-29.

## Common errors

- If you leave out value_if_false and the test fails, the cell shows FALSE, not an empty cell. Write "" as the third argument for a blank.
- IF takes three arguments at most. A fourth argument is not another branch: the formula returns #N/A. Nest a second IF, or use IFS for many branches.
- A number works as a test: 0 counts as FALSE and any other number as TRUE.
- Over a range, a plain IF returns #VALUE!. Wrap it in ARRAYFORMULA to get one result per row.

## Compared with Excel

Same syntax as Excel IF. In Excel 365 a range in the test spills on its own, while Google Sheets needs ARRAYFORMULA.

## Related functions

- [IFS](https://goingstellar.ro/reference/sheets/ifs/)
- [IFERROR](https://goingstellar.ro/reference/sheets/iferror/)
- [IFNA](https://goingstellar.ro/reference/sheets/ifna/)
- [AND](https://goingstellar.ro/reference/sheets/and/)
- [OR](https://goingstellar.ro/reference/sheets/or/)
- [SWITCH](https://goingstellar.ro/reference/sheets/switch/)

## Sources

- [IF (Docs Editors Help)](https://support.google.com/docs/answer/3093364)

