# if - script and chart function

The if function returns a value depending on whether the condition provided with the function evaluates as True or False.

Syntax:

if(condition , then [, else])

The if function has three parameters, condition, then and else, which are all expressions. The two other ones, then and else, can be of any type.

Arguments:

If arguments

| Argument | Description |
| --- | --- |
| condition | Expression that<br>is interpreted logically. |
| then | Expression that can be of any type. If the condition<br>is True, then the if function returns the value of the then expression. |
| else | Expression that can be of any type.<br>If the condition is False, then the if function<br>returns the value of the else expression.<br><br>This parameter is optional.<br>If the condition is False,<br>NULL is returned if you have not specified else. |

Examples and results:

Examples and results

| Example | Result |
| --- | --- |
| `if( Amount>=<br>0, 'OK', 'Alarm' )` | This expression will test if the amount is a positive number (0 or larger) and return 'OK' if it is. If the amount is less than 0, 'Alarm' is returned. |