If-Then-Else Function

An 'If' statement which asks a yes or no question and then gives a true or false output.

Syntax

if(ConditionExpression, ThenExpression, ElseExpression)

Parameter Description
ConditionExpression

A logical expression that gives a true or false output at each time step. This should be written in the form of a comparison using >, <, >=, <= and == operators.

You can also use && (And) and || (Or) operators within the ConditionExpression.

For example: @sensor>500 || @sensor<300

ThenExpression

The output of the If statement when the expression is true. This can be a constant value, another function, or another If statement.

ElseExpression

The output of the If statement when the expression is false. This can be a constant value, another function, or another If statement.

Example expression

if(@sensor>75, 1, 0): Gives a time series with an output of 1 when the sensor values are greater than 75 and an output of 0 when not.

if(@sensor>500 || @sensor<300, 1, 0): Gives a time series with an output of 1 when the sensor values are either greater than 500 or lower than 300 and an output of 0 when sensor values are in the range of 300 to 500.

Example chart

This chart uses the If-Then-Else function to track when the temperature sensor is over 75 (true output of 1) or not (false output of 0).