# Special functions

We developed functions to facilitate working with time series, fill in gaps or missing data points, allow conditional statements, cumulative sums and, shift the position of the elements inside.

Many Synthetic Expressions require two or more variables, in those cases, each of the values to be computed must have the same timestamp, else the engine will not compute or return unexpected results due to the way it was designed.

**is a function that basically fills in the gaps where there is a missing value in any of the variables used within the expression. The syntax for this function is as follows:***Fill missing()*** fill_missing (expression, <first_fill>, <last_fill>, <fill_value>)**

Parameters | Description | Value | Mandatory |
---|---|---|---|

Expression | Is the syntactic entity that will be evaluated to determine its output value. | N/A | YES |

`first_fill` | Indicates how the gap is going to be filled, there are to options, back and forward. By the fault the function is set to $ffill$ . | $ffill$ : Fills in the gaps forward, starting in a most recent point where there's enough data to fill the gaps for all the involved series. $bfill$ : Fills in the gaps backward, starting in a oldest point where there's enough data to fill the gaps for all the involved series."None": No fill will be done. | NO |

`last_fill` | Indicates how the gap is going to be filled at the end of the time series. Comes in handy when you have to fill all gaps in the variables. By the fault the function is set to $none$ . | $ffill$ : Fills in the gaps forward, starting in a most recent point where there's enough data to fill the gap for all the involved series. $bfill$ : Fills in the gaps backward, starting in a oldest point where there's enough data to fill the gap for all the involved series. $none$ : No fill will be done. | NO |

`fill_value` | This is the value that will be used to fill in the blanks in the variables. | any integer or float | NO |

A conditional expression is required in some cases to generate an outcome. The

*function is an if-else statement that executes one of two actions depending on whether the input condition is True or False. The syntax for this function is as follows:***where()**** where(condition, operation if true, operation if false)**

Computes the operation

*operation_if_true*, if the condition is true otherwise it will execute the*operation_if_false.*This function calculates the difference staring at the last element in a time series and the next separated by a specified number of steps. The syntax of this function is as follows.

**diff(<variable>,<steps>)**

Parameter | Description | Value | Mandatory |
---|---|---|---|

variable | It shows the measurements of a sensor as a time series of data points that vary over time, also known as "dots", and is identified by a variable label. | variable label | YES |

steps | Number of places separating two components in a time series, starting with the most recent element. | any positive integer no bigger than the total of elements in the time series | YES |

The function returns the variable's values in the time series shifted by the given number of steps. The syntax of this function is as follows.

**shift(<variable>,<step> )**Parameter | Description | Value | Mandatory |
---|---|---|---|

variable | It shows the measurements of a sensor as a time series of data points that vary over time, also known as "dots", and is identified by a variable label. | Variable label | YES |

step | Number of places (+/-) the time series will be shifted to. | Positive or negative integer | YES |

This function returns the cumulative sum of a time series. The syntax of this function is

$cumsum(x)$

where $x$

, is the variable to calculate.

Last modified 11mo ago