Use functions in formula expressions - AWS IoT SiteWise

Use functions in formula expressions

You can use the following functions to operate on data in your formula expressions.

Transforms and metrics support different functions. The following table indicates which types of functions are compatible with each type of formula property.

Note

You can include a maximum of 10 functions in a formula expression.

Function syntax

You can use the following syntax to create functions:

Regular syntax

With the regular syntax, the function name is followed by parentheses with zero or more arguments.

function_name(argument1, argument2, argument3, ...). For example, functions with the regular syntax might look like log(x) and contains(s, substring).

Uniform function call syntax (UFCS)

UFCS enables you to call functions using the syntax for method calls in object-oriented programming. With UFCS, the first argument is followed by dot (.), then the function name and the remaining arguments (if any) inside parentheses.

argument1.function_name(argument2, argument3, ...). For example, functions with UFCS might look like x.log() and s.contains(substring).

You can also use UFCS to chain subsequent functions. AWS IoT SiteWise uses the evaluation result of the current function as the first argument for the next function.

For example, you can use message.jp('$.status').lower().contains('fail') instead of contains(lower(jp(message, '$.status')),'fail').

For more information, visit the D Programming Language website.

Note

You can use UFCS for all AWS IoT SiteWise functions.

AWS IoT SiteWise functions are not case sensitive. For example, you can use lower(s) and Lower(s) interchangeably.