--- title: "if (if, then, else)" slug: "calc-function-if" updated: 2026-05-12T12:13:53Z published: 2026-05-12T12:13:53Z canonical: "docs.lobstersoftware.com/calc-function-if" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.lobstersoftware.com/llms.txt > Use this file to discover all available pages before exploring further. # if (if, then, else) *See also*: [ifEmpty](/v1/docs/en/calc-function-if-empty), [ifNotEmpty](/v1/docs/en/calc-function-if-not-empty), [cmp (Compare)](/v1/docs/en/calc-function-cmp), [and (Logical And)](/v1/docs/en/calc-function-and), [or (Logical Or)](/v1/docs/en/calc-function-or), [not (Logical negation)](/v1/docs/en/calc-function-not) > [!NOTE] > Evaluates a truth value (*condition*) and executes the then-expression (*thenValue*) if *true* and the else-expression (*elseValue*) if *false*. > > The function returns the value of the executed expression. > > > [!TIP] > > Tooltip > > > > Syntax: *$if(condition,thenValue[,elseValue])* > > > > | Parameter | Description | > > | --- | --- | > > | `condition` | An expression that is executed to determine a truth value (Boolean value). *If the evaluated expression returns true, the expression thenValue is evaluated, otherwise the optional expression elseValue.* | > > | `thenValue` | A static value or expression that is evaluated and returned if the condition returns *true.* | > > | `elseValue` | An optional value or expression that is evaluated and returned if the condition returns *false*. | > > > > Example: $if($true, condition is true, condition is false) ## Syntax *$if(condition,thenValue[,elseValue])* ## Parameter | Name | Description | | --- | --- | | condition | An expression that is executed to determine a truth value (Boolean value). If the evaluated expression returns true, the expression *thenValue* is evaluated, otherwise the optional expression *elseValue*. | | thenValue | A static value or expression that is evaluated and returned if the condition returns *true.* | | elseValue | An optional value or expression that is evaluated and returned if the condition returns *false*. | ## Return value Returns the evaluated fixed value or the return of the evaluated expression. If the condition is false and no *elseValu*e is specified, the function returns *null/empty*. ## Example | Syntax | Ergebnis | | --- | --- | | $if(true,condition is true, condition is false) | condition is true | | $if(false,condition is true, condition is false) | condition is false | | $if(false,condition is true) | null/empty | | $if($get($input,DANGEROUS_GOODS), true, false) | true or false, depending on the content of the DANGEROUS_GOODS field of $input |