syntax:functions:when

### Table of Contents

# When(condition, expression)

Category: Logical function

## Description

This function returns the result of *expression* if *condition* is TRUE. Otherwise, it returns empty value.

This function is effectively a shorthand version of ` if(condition, expression, empty()) `

## Arguments

Argument | Type | Description |
---|---|---|

condition | Expression | This is an expression or "test" that evaluates to either TRUE or FALSE. |

expression | Expression | Any expression. |

**Return value type:** Text, Number, Boolean (the value type of the returned value from *expression*), or, empty value.

## Examples

when(2 + 2 = 4, 'Makes sense') //Returns 'Makes sense'

when(1 + 1 = 4, 'Makes sense') //Returns empty

when([FieldA] = 10, 'FieldA is 10') //Returns 'FieldA is 10' (where [FieldA] is 10)

when([FieldA] = 10, 'FieldA is 10') //Returns empty (where [FieldA] is 20)

## See also

syntax/functions/when.txt · Last modified: 2021/08/28 21:17 by craigt