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 type | Transforms | Metrics |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
. For example, functions with the regular syntax might look likefunction_name
(argument1, argument2, argument3, ...
)log(x)
andcontains(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.
. For example, functions with UFCS might look likeargument1
.function_name
(argument2
,argument3
, ...)x.log()
ands.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 ofcontains(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.