# Google Sheets IF Function: Syntax and Examples

The Google Sheets IF function tests a condition and returns one value when the condition is true and another when it is false. You write it as `=IF(logical_expression, value_if_true, value_if_false)`, and it works the same way whether you compare numbers, text, dates, or the output of another formula. This article covers the syntax, a worked grading example, nested IFs, and the mistakes that trip people up most often.

## Quick Answer

- IF takes three arguments: a condition to test, the result if true, and the result if false.
- The condition must evaluate to TRUE or FALSE, for example `B2>=60` or `A2="Ana"`.
- Text results need double quotes, as in `"Pass"`. Numbers do not.
- You can nest IFs inside each other to test several conditions in order.
- If the condition is met, only the true result is returned. The false result is ignored.

## Syntax

| Argument | Required? | Meaning |
|---|---|---|
| `logical_expression` | Yes | The condition to test. It must produce TRUE or FALSE, such as `B2>=60`, `A2="Ana"`, or `B2<>""`. |
| `value_if_true` | Yes | What to return when the condition is TRUE. Can be text in quotes, a number, a cell reference, or another formula. |
| `value_if_false` | No | What to return when the condition is FALSE. Same options as `value_if_true`. |

The first two arguments are required in Google Sheets and `value_if_false` is optional. If you leave out `value_if_false`, the formula returns FALSE when the condition is not met, which is rarely what you want.

## How It Works

IF evaluates the condition first. The condition is a comparison, and comparisons in spreadsheets return exactly one of two values: TRUE or FALSE. Once IF has that answer, it returns the matching result and discards the other one.

The comparison operators you can use inside the condition are:

| Operator | Meaning | Example |
|---|---|---|
| `=` | Equal to | `A2="Ana"` |
| `<>` | Not equal to | `A2<>"Ana"` |
| `>` | Greater than | `B2>60` |
| `<` | Less than | `B2<60` |
| `>=` | Greater than or equal to | `B2>=60` |
| `<=` | Less than or equal to | `B2<=60` |

The difference between numbers and text matters here. Numbers are compared by value, so `78>=60` is TRUE. Text is compared as a string, and text comparisons are case-insensitive in Google Sheets, so `"ana"="Ana"` is TRUE. Text must be wrapped in double quotes inside the formula. If you write `=IF(A2=Ana,...)` without quotes, Sheets treats `Ana` as a named range and returns an error.

You can also test whether a cell is empty with `B2=""` or whether it is not empty with `B2<>""`. This is useful when you want to avoid running a calculation on a blank row.

## Worked Example

The table below grades eight students. Column B holds each score, and column C holds an IF formula that returns Pass when the score is at least 60 and Fail otherwise.

| | A | B | C |
|---|---|---|---|
| **1** | Student | Score | Result |
| **2** | Ana | 78 | `=IF(B2>=60,"Pass","Fail")` -> displays Pass |
| **3** | Ben | 45 | `=IF(B3>=60,"Pass","Fail")` -> displays Fail |
| **4** | Cara | 92 | `=IF(B4>=60,"Pass","Fail")` -> displays Pass |
| **5** | Dan | 60 | `=IF(B5>=60,"Pass","Fail")` -> displays Pass |
| **6** | Eve | 55 | `=IF(B6>=60,"Pass","Fail")` -> displays Fail |
| **7** | Finn | 81 | `=IF(B7>=60,"Pass","Fail")` -> displays Pass |
| **8** | Gia | 39 | `=IF(B8>=60,"Pass","Fail")` -> displays Fail |
| **9** | Hana | 67 | `=IF(B9>=60,"Pass","Fail")` -> displays Pass |

The formula in C2 reads: if Ana's score is at least 60, show Pass, otherwise Fail. Ana scored 78, so the condition `78>=60` is TRUE and C2 displays Pass.

The same logic is filled down for the remaining students. Ben scored 45, so C3 displays Fail. Cara scored 92, so C4 displays Pass. Dan scored exactly 60, and because the operator is `>=` rather than `>`, C5 displays Pass. Eve scored 55, so C6 displays Fail. Finn scored 81, so C7 displays Pass. Gia scored 39, so C8 displays Fail. Hana scored 67, so C9 displays Pass.

The boundary case is worth studying. Dan sits exactly on the cutoff, and the choice between `>=` and `>` decides whether he passes. Always check which operator your rule actually requires before filling a formula down a column.

## More Examples

**Text condition.** To flag a specific student by name:

```
=IF(A2="Ana","Found","Not found")
```

This returns Found for Ana and Not found for everyone else. Remember that text comparisons ignore case, so `"ana"` matches `"Ana"`.

**Blank cell check.** To avoid dividing by an empty cell:

```
=IF(B2="","",A2/B2)
```

When B2 is empty, the formula returns an empty string instead of a division error.

**Nested IF for letter grades.** When you have more than two outcomes, nest IFs so each one handles the next band:

```
=IF(B2>=90,"A",IF(B2>=80,"B",IF(B2>=70,"C",IF(B2>=60,"D","F"))))
```

Sheets evaluates the conditions from the outside in. A score of 92 fails the first test? No, it passes `B2>=90`, so it returns A and stops. A score of 85 fails the first test, moves to the second, passes `B2>=80`, and returns B. Order matters. If you put the lowest band first, every score above it would match that band and the rest of the formula would never run.

For long chains of bands, the [IFS function in Excel](/blog/data-analysis/ifs-function-excel) and its Sheets equivalent read more cleanly than deeply nested IFs, because each condition sits next to its result.

**Combining conditions.** To require two things to be true at once, wrap them in AND:

```
=IF(AND(B2>=60,C2="Yes"),"Pass","Fail")
```

To accept either of two conditions, use OR. The [IF AND statements in Excel](/blog/data-analysis/if-and-statements-excel) article walks through the AND pattern in detail, and [Excel IF OR](/blog/data-analysis/excel-if-or-combine-functions) covers the OR version.

**Returning a number.** The true and false results do not have to be text. This returns a bonus of 100 or 0:

```
=IF(B2>=90,100,0)
```

If you are moving between spreadsheet apps, the [step-by-step guide to the IF function in Excel](/blog/data-analysis/excel-if-function-step-by-step) shows the same syntax in Excel, and [nested IF statements in Excel](/blog/data-analysis/nested-if-statements-excel) covers the multi-condition case.

## Errors and How to Fix Them

**`#NAME?`** usually means you wrote text without quotes, such as `=IF(A2=Ana,...)`. Sheets reads `Ana` as a name it does not recognize. Wrap text values in double quotes.

**`#ERROR!` with a parse message** means the argument count or the parentheses are wrong. Count the commas. IF needs exactly two commas between its three arguments, and one closing parenthesis for every opening one.

**`#VALUE!`** appears when the condition cannot be evaluated, for example when it does arithmetic on text, as in `A2*2>10` with text in A2. Comparing a number to text with `>` or `<` does not raise an error, it silently treats text as larger than any number, so check that both sides of the comparison are the same type.

**`#DIV/0!`** is not caused by IF itself. It happens when the true or false result performs a division by a zero or empty cell. Guard the division with an inner IF, as shown in the blank cell example above.

**A wrong result with no error** is the most common problem. The formula runs fine but returns the wrong branch. Check the operator first, then check the order of nested conditions.

## Common Mistakes

- **Forgetting quotes around text.** `=IF(A2=Ana,"Yes","No")` fails. Write `=IF(A2="Ana","Yes","No")`.
- **Using `>` when the rule says "at least".** "At least 60" means `>=60`. With `>60`, a score of exactly 60 fails, as the Dan row shows.
- **Ordering nested IFs from low to high.** Put the highest band first so each score falls into the correct range and stops there.
- **Leaving out the false result.** The third argument is optional, but omitting it returns FALSE instead of the value you intended.
- **Comparing numbers stored as text.** A score typed as text will not compare correctly against a number. Convert the column to numbers first.
- **Hardcoding values that should be cell references.** Write `=IF(B2>=60,...)` and fill down, so each row tests its own score.

## Limitations

IF handles one condition at a time. When you need several conditions, you either nest IFs or combine them with AND and OR, and both approaches get hard to read past three or four levels. Deep nesting also makes errors hard to spot, because a single wrong operator or a misordered band can silently send every row down the wrong branch.

IF cannot look across an entire table or return multiple values at once. It works on one cell at a time and returns one result. For conditional sums, counts, or lookups, other functions are the right tool. IF is also not a filter. It labels rows, it does not remove them, so a column of Pass and Fail values still contains every original row.

## Frequently Asked Questions

### How do I write an IF statement in Google Sheets?

Type `=IF(` followed by your condition, a comma, the value to return when true, a comma, and the value to return when false, then close the parenthesis. For example, `=IF(B2>=60,"Pass","Fail")` returns Pass when B2 is 60 or more and Fail otherwise. Press Enter to confirm the formula.

### Can I use IF with text instead of numbers?

Yes. Put the text you are comparing against in double quotes, as in `=IF(A2="Ana","Yes","No")`. Text comparisons in Google Sheets are case-insensitive, so `"ana"` and `"Ana"` match the same cells. The values you return can also be text, and those need quotes too.

### How do I nest multiple IF functions?

Place a second IF formula in the `value_if_false` position of the first one, and repeat for each additional condition. Order the conditions from the most restrictive to the least, so each value matches the first band it belongs to. Keep the chain to three or four levels before switching to a cleaner approach.

### Why does my IF formula return FALSE instead of my value?

You probably left out the third argument, `value_if_false`. When the condition is not met and no false result is supplied, Sheets returns the logical value FALSE. Add the missing argument, for example `=IF(B2>=60,"Pass","Fail")` instead of `=IF(B2>=60,"Pass")`.

### What is the difference between IF and IFS?

IF tests a single condition and returns one of two results. IFS tests a list of conditions in order and returns the result paired with the first one that is true, so it replaces a nested IF chain with a flatter formula. Use IF for two outcomes and IFS when you have three or more bands.

## References

This article draws on the standard references listed under Further Reading.

## Further Reading

- [Broman KW, Woo KH (2018). Data Organization in Spreadsheets. The American Statistician](https://doi.org/10.1080/00031305.2017.1375989)
- [Ziemann M, Eren Y, El-Osta A (2016). Gene name errors are widespread in the scientific literature. Genome Biology](https://doi.org/10.1186/s13059-016-1044-7)
- [Microsoft Support: Excel help and learning](https://support.microsoft.com/en-us/excel)
- [McCullough B, Heiser DA (2008). On the accuracy of statistical procedures in Microsoft Excel 2007. Computational Statistics &amp; Data Analysis](https://doi.org/10.1016/j.csda.2008.03.004)
- [Abeysooriya M, Soria M, Kasu MS et al. (2021). Gene name errors: Lessons not learned. PLOS Computational Biology](https://doi.org/10.1371/journal.pcbi.1008984)
- [Wilson G, Bryan J, Cranston K et al. (2017). Good enough practices in scientific computing. PLOS Computational Biology](https://doi.org/10.1371/journal.pcbi.1005510)

## Related Articles

- [IFS Function in Excel: Syntax and Examples](/blog/data-analysis/ifs-function-excel)
- [IF AND Statements in Excel: Syntax and Examples](/blog/data-analysis/if-and-statements-excel)
- [How to Use the IF Function in Excel (Step by Step)](/blog/data-analysis/excel-if-function-step-by-step)
- [Excel IF OR: How to Combine IF and OR Functions](/blog/data-analysis/excel-if-or-combine-functions)
- [Excel FIND Function: Syntax, Examples and SEARCH Comparison](/blog/data-analysis/excel-find-function-syntax-examples)