Syntax
=IF(logical_test, value_if_true, [value_if_false])Arguments
| Argument | Required | Description |
|---|---|---|
logical_test | Required | The condition to check |
value_if_true | Required | The result when the condition is TRUE |
value_if_false | Optional | The result when it is FALSE (FALSE when left out) |
How to use IF
IF takes 2 required arguments and 1 optional argument. Type =IF( in a cell and SheetsBat shows the arguments as you go. Optional arguments are shown in square brackets; leave them out to use their default.
Examples
Each result below was calculated by the SheetsBat formula engine.
=IF(5>3, "Yes", "No")Result =IF(1>3, "Yes")Result Related logical functions
- ANDTRUE when every argument is TRUE.
- FALSEThe logical value FALSE.
- IFERRORReturns a value of your choice when a formula gives an error, otherwise the formula result.
- IFNAReturns a value of your choice when a formula gives #N/A, otherwise the formula result.
- IFSChecks conditions in order and returns the value of the first one that is TRUE.
- LAMBDACreates a reusable function with parameters. Call it right away, store it in a name or pass it to MAP, REDUCE and friends.
- LETNames the results of calculations so a formula can reuse them.
- NOTReverses a logical value.
- ORTRUE when any argument is TRUE.