# IF

logical · from excel · excel: verified match · sheets: verified match

returns one value if condition is true, another if false

## signature

```
IF(condition, value_if_true, [value_if_false])
```

returns: `any`

## arguments

- condition: boolean: required
- value_if_true: any: required
- value_if_false: any: optional

## examples

formula and result, asserted in the engine test suite.

| formula | result | with |
| --- | --- | --- |
| `=IF(A1>100, "High", "Low")` | `Low` | A1=10 |
| `=IF(A1>5, B1, 0)` | `2` | A1=10, B1=2 |

## related

- [AND](https://deepcalc.com/docs/functions/and.md): returns TRUE if all arguments are true
- [EQ](https://deepcalc.com/docs/functions/eq.md): true when two values are equal
- [FALSE](https://deepcalc.com/docs/functions/false.md): returns the logical value FALSE
- [GT](https://deepcalc.com/docs/functions/gt.md): true when the first number is greater
- [GTE](https://deepcalc.com/docs/functions/gte.md): true when the first number is greater or equal
- [IFERROR](https://deepcalc.com/docs/functions/iferror.md): returns value if no error, otherwise alternate
- [IFNA](https://deepcalc.com/docs/functions/ifna.md): returns value if not #N/A, otherwise alternate
- [IFS](https://deepcalc.com/docs/functions/ifs.md): checks multiple conditions, returns first match

## navigate

- [all logical functions](https://deepcalc.com/docs/functions/logical-functions.md)
- [function index](https://deepcalc.com/docs/functions.md): all 602 functions
- [error values](https://deepcalc.com/docs/errors.md) · [concepts](https://deepcalc.com/docs/concepts.md) · [limits](https://deepcalc.com/docs/limits.md)
- [everything in one file](https://deepcalc.com/llms-full.txt)

source: https://deepcalc.com/docs/functions/if