# IF Function – Google Sheets

The IF function in Google Sheets checks a condition and returns a specific value if it’s true and, optionally, another value if it’s false.

You can use the IF function independently in a single logical test or nest multiple IF statements into a single formula for more complex tests. Optionally, consider using the IFS statements for multiple conditions.

## Syntax

`=IF(logical_expression, value_if_true, value_if_false)`

## Similar Functions

IFS– Evaluates multiple conditions and returns a value

COUNTIF – Count cells that match a criterion

SUMIF – Sum values that match a criterion

COUNTUNIQUEIFS – Count unique values that meet multiple criteria

## Example 1 – IF Greater Than a Number

First, we’ll see if the amounts in column `A` are greater than `10`.

Formula used: `=IF(A2>10, "Yes", "No")`

This formula checks if the value in cell `A2` is greater than `10`. If it is, the formula returns “Yes”. If it is not, the formula returns “No”. The word “No” will be returned for any value other than a number greater than `10`. Therefore, it there is text in the cell, the formula will return “No”.

## Example 2 – IF Contains a Word

Now we will see if a certain word, “Yes” in this case, is in a cell.

Formula used: `=IF(B2="Yes", "Approved", "Not approved"`)

This formula checks if the value in cell `B2` is “`Yes`”. If it is, the formula returns “`Approved`”. If it is not, the formula returns “`Not approved`”.

## Example 3 – Nested IF Statements

Lastly, we’ll combine IF statements to handle a more complex situation.

Formula used: `=IF(A2="Red", "Stop", IF(A2="Yellow", "Slow down", "Go"))`

This formula checks if the value in cell `A2` is “`Red`”. When it is “`Red`”, the formula returns “`Stop`”. If it is not, the formula checks if the value in cell `A2` is “`Yellow`”. If it is, the formula returns “`Slow down`”. When it is neither “`Red`” nor “`Yellow`”, the formula returns “`Go`”.

## Live Examples

Get your copy of this Google Sheet to use the examples yourself.