

# Use formula expressions
<a name="formula-expressions"></a>

With formula expressions, you can define the mathematical functions to transform and aggregate your raw industrial data to gain insights about your operation. Formula expressions combine literals, operators, functions, and variables to process data. For more information about how to define asset properties that use formula expressions, see [Transform data (transforms)](transforms.md) and [Aggregate data from properties and other assets (metrics)](metrics.md). Transforms and metrics are formula properties.

**Topics**
+ [Use variables in formula expressions](expression-variables.md)
+ [Use literals in formula expressions](expression-literals.md)
+ [Use operators in formula expressions](expression-operators.md)
+ [Use constants in formula expressions](expression-constants.md)
+ [Use functions in formula expressions](expression-functions.md)
+ [Formula expression tutorials](expression-tutorials.md)

# Use variables in formula expressions
<a name="expression-variables"></a>

Variables represent AWS IoT SiteWise asset properties in formula expressions. Use variables to input values from other asset properties in your expressions, so that you can process data from constant properties ([attributes](attributes.md)), raw data streams ([measurements](measurements.md)), and other formula properties.

Variables can represent asset properties from the same asset model or from associated child asset models. Only metric formulas can input variables from child asset models.

You identify variables by different names in the console and the API.
+ **AWS IoT SiteWise console** – Use asset property names as variables in your expressions.
+ **AWS IoT SiteWise API (AWS CLI, AWS SDKs)** – Define variables with the [ExpressionVariable](https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_ExpressionVariable.html) structure, which requires a variable name and a reference to an asset property. The variable name can contain lowercase letters, numbers, and underscores. Then, use variable names to reference asset properties in your expressions.

Variable names are case sensitive.

For more information, see [Defining transforms](transforms.md) and [Defining metrics](metrics.md).

## Use variables to reference properties
<a name="variable-values"></a>

A variable's *value* defines the property that it references. AWS IoT SiteWise provides different ways to do this.
+ **By property ID:** You can specify the property's unique ID (UUID) to identify it.
+ **By name:** If the property is on the same asset model, you can specify its name in the property ID field.
+ **By path:** A variable value can refer to a property by its *path.* For more information, see [Use paths to reference custom composite model properties](custom-composite-models.md#property-paths).

**Note**  
 Variables are not supported by AWS IoT SiteWise console. They are used by AWS IoT SiteWise API, including the AWS Command Line Interface AWS CLI) and AWS SDKs. 

 A variable that you receive in a response from AWS IoT SiteWise includes full information about the value, including both the ID and the path.

 However, when you pass a variable into AWS IoT SiteWise (for example, in a "create" or "update" call), you only need to specify one of these. For example, if you specify the path, you don't need to provide the ID. 

# Use literals in formula expressions
<a name="expression-literals"></a>

AWS IoT SiteWise supports the use of literals in expressions and formulas. Literals are fixed values that represent a specific data type. In AWS IoT SiteWise, you can define number and string literals in formula expressions. Literals can be used in various contexts, including data transformations, alarm conditions, and visualization calculations.


+ <a name="number-literal-definition"></a>**Numbers**

  Use numbers and scientific notation to define integers and doubles. You can use [E notation](https://en.wikipedia.org/wiki/Scientific_notation#E_notation) to express numbers with scientific notation.

  Examples: `1`, `2.0`, `.9`, `-23.1`, `7.89e3`, `3.4E-5`
+ <a name="string-literal-definition"></a>**Strings**

  Use the `'` (quote) and `"` (double quote) characters to define strings. The quote type for the start and end must match. To escape a quote that matches the one that you use to declare a string, include that quote character twice. This is the only escape character in AWS IoT SiteWise strings.

  Examples: `'active'`, `"inactive"`, `'{"temp": 52}'`, `"{""temp"": ""high""}"`

# Use operators in formula expressions
<a name="expression-operators"></a>

You can use the following common operators in formula expressions.


| Operator | Description | 
| --- | --- | 
|  `+`  |  If both operands are numbers, this operator adds the left and right operands. If either operand is a string, this operator concatenates the left and right operands as strings. For example, the expression `1 + 2 + " is three"` evaluates to `"3 is three"`. The concatenated string can have up to 1024 characters. If the string exceeds 1024 characters, then AWS IoT SiteWise doesn't output a data point for that computation.  | 
|  `-`  |  Subtracts the right operand from the left operand. <a name="operator-numbers-only"></a>You can only use this operator with numeric operands.  | 
|  `/`  |  Divides the left operand by the right operand. <a name="operator-numbers-only"></a>You can only use this operator with numeric operands.  | 
|  `*`  |  Multiplies the left and right operands. <a name="operator-numbers-only"></a>You can only use this operator with numeric operands.  | 
|  `^`  |  Raises the left operand to the power of the right operand (exponentiation). <a name="operator-numbers-only"></a>You can only use this operator with numeric operands.  | 
|  `%`  |  Returns the remainder from dividing the left operand by the right operand. The result has the same sign as the left operand. This behavior differs from the modulo operation. <a name="operator-numbers-only"></a>You can only use this operator with numeric operands.  | 
|  `x < y`  |  Returns `1` if `x` is less than `y`, otherwise `0`.  | 
|  `x > y`  |  Returns `1` if `x` is greater than `y`, otherwise `0`.  | 
|  `x <= y`  |  Returns `1` if `x` is less than or equal to `y`, otherwise `0`.  | 
|  `x >= y`  |  Returns `1` if `x` is greater than or equal to `y`, otherwise `0`.  | 
|  `x == y`  |  Returns `1` if `x` is equal to `y`, otherwise `0`.  | 
|  `x != y`  |  Returns `1` if `x` is not equal to `y`, otherwise `0`.  | 
|  `!x`  |  Returns `1` if `x` is evaluated to `0` (false), otherwise `0`. `x` is evaluated to false if:  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-operators.html)  | 
|  `x and y`  |  Returns `0` if `x` is evaluated to `0` (false). Otherwise, returns the evaluated result of `y`. `x` or `y` is evaluated to false if:  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-operators.html)  | 
|  `x or y`  |  Returns `1` if `x` is evaluated to `1` (true). Otherwise, returns the evaluated result of `y`. `x` or `y` is evaluated to false if:  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-operators.html)  | 
|  `not x`  |  Returns `1` if `x` is evaluated to `0` (false), otherwise `0`. `x` is evaluated to false if:  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-operators.html)  | 
|   `[]` `s[index]`  |  Returns the character at an index `index` of the string `s`. This is equivalent to the index syntax in Python. 

**Examples**  
+ `"Hello!"[1]` returns `e`.
+ `"Hello!"[-2]` returns `o`.  | 
|   `[]` `s[start:end:step]`  |  Returns a slice of the string `s`. This is equivalent to the slice syntax in Python. This operator has the following arguments: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-operators.html) You can omit the `step` argument to use its default value. For example, `s[1:4:1]` is equivalent to `s[1:4]`. The arguments must be integers or the [none](expression-constants.md#none-definition) constant. If you specify `none`, AWS IoT SiteWise uses the default value for that argument. 

**Examples**  
+ `"Hello!"[1:4]` returns `"ell"`.
+ `"Hello!"[:2]` returns `"He"`.
+ `"Hello!"[3:]` returns `"lo!"`.
+ `"Hello!"[:-4]` returns `"He"`.
+ `"Hello!"[::2]` returns `"Hlo"`.
+ `"Hello!"[::-1]` returns `"!olleH"`.  | 

# Use constants in formula expressions
<a name="expression-constants"></a>

In AWS IoT SiteWise, you can use constants in your expressions and formulas to represent fixed values or predefined parameters. Constants can be used in various contexts, such as data transformations, alarm conditions, or visualization calculations. By using constants, you can simplify your expressions and make them more readable and maintainable.

You can use the following common mathematical constants in your expressions. All constants are case insensitive.

**Note**  
If you define a variable with the same name as a constant, the variable overrides the constant.


| Constant | Description | 
| --- | --- | 
|  `pi`  |  The number pi (`π`): `3.141592653589793`  | 
|  `e`  |  The number e: `2.718281828459045`  | 
|  `true`  |  Equivalent to the number 1. In AWS IoT SiteWise, Booleans convert to their number equivalents.  | 
|  `false`  |  Equivalent to the number 0. In AWS IoT SiteWise, Booleans convert to their number equivalents.  | 
|   `none`  |  Equivalent to no value. You can use this constant to output nothing as the result of a [conditional expression](expression-conditional-functions.md).  | 

# Use functions in formula expressions
<a name="expression-functions"></a>

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 | 
| --- | --- | --- | 
|  [Use common functions in formula expressions](expression-common-functions.md)  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  | 
|  [Use comparison functions in formula expressions](expression-comparison-functions.md)  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  | 
|  [Use conditional functions in formula expressions](expression-conditional-functions.md)  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  | 
|  [Use string functions in formula expressions](expression-string-functions.md)  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  | 
|  [Use aggregation functions in formula expressions](expression-aggregation-functions.md)  |  <a name="polaris-no-para"></a>![\[A red circle with the letter x for no.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-no.png) No  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  | 
|  [Use temporal functions in formula expressions](expression-temporal-functions.md)  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  | 
|  [Use date and time functions in formula expressions](expression-date-and-time-functions.md)  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  |  <a name="polaris-yes-para"></a>![\[A green circle with a checkmark for yes.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/icon-yes.png) Yes  | 

## Function syntax
<a name="expression-function-syntax"></a>

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](https://tour.dlang.org/tour/en/gems/uniform-function-call-syntax-ufcs) 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.

# Use common functions in formula expressions
<a name="expression-common-functions"></a>

In [transforms](transforms.md) and [metrics](metrics.md), you can use the following functions to calculate common mathematical functions in transforms and metrics.


| Function | Description | 
| --- | --- | 
|  `abs(x)`  |  Returns the absolute value of `x`.  | 
|  `acos(x)`  |  Returns the arccosine of `x`.  | 
|  `asin(x)`  |  Returns the arcsine of `x`.  | 
|  `atan(x)`  |  Returns the arctangent of `x`.  | 
|  `cbrt(x)`  |  Returns the cubic root of `x`.  | 
|  `ceil(x)`  |  Returns the nearest integer greater than `x`.  | 
|  `cos(x)`  |  Returns the cosine of `x`.  | 
|  `cosh(x)`  |  Returns the hyperbolic cosine of `x`.  | 
|  `cot(x)`  |  Returns the cotangent of `x`.  | 
|  `exp(x)`  |  Returns `e` to the power of `x`.  | 
|  `expm1(x)`  |  Returns `exp(x) - 1`. Use this function to more accurately calculate `exp(x) - 1` for small values of `x`.  | 
|  `floor(x)`  |  Returns the nearest integer less than `x`.  | 
|  `log(x)`  |  Returns the `loge` (base `e`) of `x`.  | 
|  `log10(x)`  |  Returns the `log10` (base `10`) of `x`.  | 
|  `log1p(x)`  |  Returns `log(1 + x)`. Use this function to more accurately calculate `log(1 + x)` for small values of `x`.  | 
|  `log2(x)`  |  Returns the `log2` (base `2`) of `x`.  | 
|  `pow(x, y)`  |  Returns `x` to the power of `y`. This is equivalent to `x ^ y`.  | 
|  `signum(x)`  |  Returns the sign of `x` (`-1` for negative inputs, `0` for zero inputs, `+1` for positive inputs).  | 
|  `sin(x)`  |  Returns the sine of `x`.  | 
|  `sinh(x)`  |  Returns the hyperbolic sine of `x`.  | 
|  `sqrt(x)`  |  Returns the square root of `x`.  | 
|  `tan(x)`  |  Returns the tangent of `x`.  | 
|  `tanh(x)`  |  Returns the hyperbolic tangent of `x`.  | 

# Use comparison functions in formula expressions
<a name="expression-comparison-functions"></a>

In [transforms](transforms.md) and [metrics](metrics.md), you can use the following comparison functions to compare two values and output `1` (true) or `0` (false). AWS IoT SiteWise compares strings by [lexicographic order](https://en.wikipedia.org/wiki/Lexicographic_order).


| Function | Description | 
| --- | --- | 
|  `gt(x, y)`  |  Returns `1` if `x` is greater than `y`, otherwise `0` (`x > y`). <a name="comparison-function-incompatible-types"></a>This function doesn't return a value if `x` and `y` are incompatible types, such as a number and a string.  | 
|  `gte(x, y)`  |  Returns `1` if `x` is greater than or equal to `y`, otherwise `0` (`x ≥ y`). <a name="comparison-function-relative-tolerance"></a>AWS IoT SiteWise considers the arguments equal if they are within a relative tolerance of `1E-9`. This behaves similar to the [isclose](https://docs.python.org/3/library/math.html#math.isclose) function in Python. <a name="comparison-function-incompatible-types"></a>This function doesn't return a value if `x` and `y` are incompatible types, such as a number and a string.  | 
|  `eq(x, y)`  |  Returns `1` if `x` is equal to `y`, otherwise `0` (`x == y`). <a name="comparison-function-relative-tolerance"></a>AWS IoT SiteWise considers the arguments equal if they are within a relative tolerance of `1E-9`. This behaves similar to the [isclose](https://docs.python.org/3/library/math.html#math.isclose) function in Python. <a name="comparison-function-incompatible-types"></a>This function doesn't return a value if `x` and `y` are incompatible types, such as a number and a string.  | 
|  `lt(x, y)`  |  Returns `1` if `x` is less than `y`, otherwise `0` (`x < y`). <a name="comparison-function-incompatible-types"></a>This function doesn't return a value if `x` and `y` are incompatible types, such as a number and a string.  | 
|  `lte(x, y)`  |  Returns `1` if `x` is less than or equal to `y`, otherwise `0` (`x ≤ y`). <a name="comparison-function-relative-tolerance"></a>AWS IoT SiteWise considers the arguments equal if they are within a relative tolerance of `1E-9`. This behaves similar to the [isclose](https://docs.python.org/3/library/math.html#math.isclose) function in Python. <a name="comparison-function-incompatible-types"></a>This function doesn't return a value if `x` and `y` are incompatible types, such as a number and a string.  | 
|  `isnan(x)`  |  Returns `1` if `x` is equal to `NaN`, otherwise `0`. This function doesn't return a value if `x` is a string.  | 

# Use conditional functions in formula expressions
<a name="expression-conditional-functions"></a>

In [transforms](transforms.md) and [metrics](metrics.md), you can use the following function to check a condition and return different results, whether the condition evaluates to true or false.


| Function | Description | 
| --- | --- | 
|   `if(condition, result_if_true, result_if_false)`  |  Evaluates the `condition` and returns `result_if_true` if the condition evaluates to true or `result_if_false` if the condition evaluates to `false`. `condition` must be a number. This function considers `0` and an empty string as `false` and everything else (including `NaN`) as `true`. Booleans convert to `0` (false) and `1` (true). You can return the [none constant](expression-constants.md#none-definition) from this function to discard the output for a particular condition. This means you can filter out data points that don't meet a condition. For more information, see [Filter data points](expression-tutorials.md#filter-data). 

**Examples**  
+ `if(0, x, y)` returns the variable `y`.
+ `if(5, x, y)` returns the variable `x`.
+ `if(gt(temp, 300), x, y)` returns the variable `x` if the variable `temp` is greater than `300`.
+ `if(gt(temp, 300), temp, none)` returns the variable `temp` if it's greater than or equal to `300`, or `none` (no value) if `temp` is less than `300`. We recommend that you use UFCS for nested conditional functions where one or more arguments are conditional functions. You can use `if(condition, result_if_true)` to evaluate a condition and `elif(condition, result_if_true, result_if_false)` to evaluate additional conditions. For example, you can use `if(condition1, result1_if_true).elif(condition2, result2_if_true, result2_if_false)` instead of `if(condition1, result1_if_true, if(condition2, result2_if_true, result2_if_false))`. You can also chain additional intermediate conditional functions. For example, you can use `if(condition1, result1_if_true).elif(condition2, result2_if_true).elif(condition3, result3_if_true, result3_if_false)` instead of nesting multiple `if` statements, such as `if(condition1, result1_if_true, if(condition2, result2_if_true, if(condition3, result3_if_true result3_if_false)))`.  You must use `elif(condition, result_if_true, result_if_false)` with UFCS.   | 

# Use string functions in formula expressions
<a name="expression-string-functions"></a>

In [transforms](transforms.md) and [metrics](metrics.md), you can use the following functions to operate on strings. For more information, see [Use strings in formulas](expression-tutorials.md#use-strings-in-formulas).

**Important**  
<a name="formula-output-rules"></a>Formula expressions can only output double or string values. Nested expressions can output other data types, such as strings, but the formula as a whole must evaluate to a number or string. You can use the [jp function](#jp-definition) to convert a string to a number. The Boolean value must be 1 (true) or 0 (false). For more information, see [Undefined, infinite, and overflow values](expression-tutorials.md#undefined-values).


| Function | Description | 
| --- | --- | 
|  `len(s)`  |  Returns the length of the string `s`.  | 
|  `find(s, substring)`  |  Returns the index of the string `substring` in the string `s`.  | 
|  `contains(s, substring)`  |  Returns `1` if the string `s` contains the string `substring`, otherwise `0`.  | 
|  `upper(s)`  |  Returns the string `s` in uppercase form.  | 
|  `lower(s)`  |  Returns the string `s` in lowercase form.  | 
|   `jp(s, json_path)`  |  Evaluates the string `s` with the [JsonPath](https://github.com/json-path/JsonPath) expression `json_path` and returns the result. Use this function to do the following: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-string-functions.html) To extract a string value from a JSON structure and return it as a number, you must use multiple nested `jp` functions. The outer `jp` function extracts the string from the JSON structure, and the inner `jp` function converts the string to a number. The string `json_path` must contain a string literal. This means that `json_path` can't be an expression that evaluates to a string. 

**Examples**  
+ `jp('{"status":"active","value":15}', '$.value')` returns `15`.
+ `jp('{"measurement":{"reading":25,"confidence":0.95}}', '$.measurement.reading')` returns `25`.
+ `jp('[2,8,23]', '$[2]')` returns `23`.
+ `jp('{"values":[3,6,7]}', '$.values[1]')` returns `6`.
+ `jp('111', '$')` returns `111`.
+ `jp(jp('{"measurement":{"reading":25,"confidence":"0.95"}}', '$.measurement.confidence'), '$')` returns `0.95`.  | 
|  `join(s0, s1, s2, s3, ...)`  |  Returns a concatenated string with a delimiter. This function uses the first input string as a delimiter and joins the remaining input strings together. This behaves similar to the [join(CharSequence delimiter, CharSequence... elements)](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#join-java.lang.CharSequence-java.lang.CharSequence...-) function in Java. 

**Examples**  
+ `join("-", "aa", "bb", "cc")` returns `aa-bb-cc`  | 
|  `format(expression: "format")` or `format("format", expression)`  |  Returns a string in the specified format. This function evaluates `expression` to a value, and then returns the value in the specified format. This behaves similar to the [format(String format, Object... args)](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#format-java.lang.String-java.lang.Object...-) function in Java. For more information about supported formats, see Conversions under [Class Formatter](https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html) in the *Java Platform, Standard Edition 7 API Specification*. 

**Examples**  
+ `format(100+1: "d")` returns a string, `101`.
+ `format("The result is %d", 100+1)` returns a string, `The result is 101`.  | 
|  `f'expression'`  |  Returns a concatenated string. With this formatted function, you can use a simple expression to concatenate and format strings. These functions may contain nested expressions. You can use `{}` (curly braces) to interpolate expressions. This behaves similar to the [formatted string literals](https://docs.python.org/3/reference/lexical_analysis.html#f-strings) in Python. 

**Examples**  
+ `f'abc{1+2: "f"}d'` returns `abc3.000000d`. To evaluate this example expression, do the following:

  1. `format(1+2: "f")` returns a floating point number, `3.000000`.

  1. `join('', "abc", 1+2, 'd')` returns a string, `abc3.000000d`.

  You can also write the expression in the following way: `join('', "abc", format(1+2: "f"), 'd')`.  | 

# Use aggregation functions in formula expressions
<a name="expression-aggregation-functions"></a>

In [metrics](metrics.md) only, you can use the following functions that aggregate input values over each time interval and calculate a single output value. Aggregation functions can aggregate data from associated assets.

Aggregation function arguments can be [variables](expression-variables.md), [number literals](expression-literals.md#number-literal-definition), [temporal functions](expression-temporal-functions.md), nested expressions, or aggregation functions. The formula `max(latest(x), latest(y), latest(z))` uses an aggregation function as an argument and returns the largest current value of the `x`, `y`, and `z` properties.

You can use nested expressions in aggregation functions. When you use nested expressions, the following rules apply: 
+ Each argument can have only one variable.  
**Example**  

  For example, `avg(x*(x-1))` and `sum(x/2 )/avg(y^2 )` are supported.

  For example, `min(x/y)` isn't supported.
+ Each argument can have multilevel nested expressions.  
**Example**  

  For example, `sum(avg(x^2 )/2)` is supported.
+ Different arguments can have different variables.  
**Example**  

  For example, `sum(x/2, y*2)` is supported.

**Note**  
If your expressions contain measurements, AWS IoT SiteWise uses the last values over the current time interval for the measurements to compute aggregates.
If your expressions contain attributes, AWS IoT SiteWise uses the latest values for the attributes to compute aggregates.


| Function | Description | 
| --- | --- | 
|  `avg(x0, ..., xn)`  |  Returns the mean of the given variables' values over the current time interval. <a name="aggregation-function-no-output"></a>This function outputs a data point only if the given variables have at least one data point over the current time interval.  | 
|   `sum(x0, ..., xn)`  |  Returns the sum of the given variables' values over the current time interval. <a name="aggregation-function-no-output"></a>This function outputs a data point only if the given variables have at least one data point over the current time interval.  | 
|  `min(x0, ..., xn)`  |  Returns the minimum of the given variables' values over the current time interval. <a name="aggregation-function-no-output"></a>This function outputs a data point only if the given variables have at least one data point over the current time interval.  | 
|  `max(x0, ..., xn)`  |  Returns the maximum of the given variables' values over the current time interval. <a name="aggregation-function-no-output"></a>This function outputs a data point only if the given variables have at least one data point over the current time interval.  | 
|  `count(x0, ..., xn)`  |  Returns the total number of data points for the given variables over the current time interval. For more information about how to count the number of data points that meet a condition, see [Count data points that match a condition](expression-tutorials.md#count-filtered-data). <a name="aggregation-function-always-output"></a>This function computes a data point for every time interval.  | 
| `stdev(x0, ..., xn)` | Returns the standard deviation of the given variables' values over the current time interval. This function outputs a data point only if the given variables have at least one data point over the current time interval.  | 

# Use temporal functions in formula expressions
<a name="expression-temporal-functions"></a>

Use temporal functions to return values based on timestamps of data points.

## Use temporal functions in metrics
<a name="temporal-functions-in-metrics"></a>

In [metrics](metrics.md) only, you can use the following functions that return values based on timestamps of data points.

Temporal function arguments must be properties from the local asset model or nested expressions. This means that you can't use properties from child asset models in temporal functions.

You can use nested expressions in temporal functions. When you use nested expressions, the following rules apply: 
+ Each argument can have only one variable.

  For example, `latest( t*9/5 + 32 )` is supported.
+ Arguments can't be aggregation functions.

  For example, `first( sum(x) )` isn't supported.


| Function | Description | 
| --- | --- | 
|  `first(x)`  |  Returns the given variable's value with the earliest timestamp over the current time interval.  | 
|   `last(x)` |  Returns the given variable's value with the latest timestamp over the current time interval.  | 
|  `earliest(x)`  |  Returns the given variable's last value before the start of the current time interval. This function computes a data point for every time interval, if the input property has at least one data point in its history. See [time-range-defintion](#time-range-def) for details.   | 
|   `latest(x)` |  Returns the given variable's last value with the latest timestamp before the end of the current time interval. This function computes a data point for every time interval, if the input property has at least one data point in its history. See [time-range-defintion](#time-range-def) for details.  | 
|   `statetime(x)`  |  Returns the amount of time in seconds that the given variables are positive over the current time interval. You can use the [comparison functions](expression-comparison-functions.md) to create a transform property for the `statetime` function to consume.  For example, if you have an `Idle` property that is `0` or `1`, you can calculate idle time per time interval with this expression: `IdleTime = statetime(Idle)`. For more information, see the [example statetime scenario](#statetime-example). This function doesn't support metric properties as input variables. This function computes a data point for every time interval, if the input property has at least one data point in its history.  | 
|   `TimeWeightedAvg(x, [interpolation])`  | Returns the average of input data weighted with time intervals between points.See [Time weighted functions parameters](#timeweighted-parameter) for computation and intervals details.The optional argument `interpolaton` must be a string constant:[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-temporal-functions.html) | 
|   `TimeWeightedStDev(x, [algo])`  |  Returns the standard deviation of input data weighted with time intervals between points.  See [Time weighted functions parameters](#timeweighted-parameter) for computation and intervals details.  The calculation uses the Last Observed Carry Forward computation algorithm for intervals between data points. In this approach, the data point is computed as the last observed value until the next input data point time stamp. Weight is computed as time interval in seconds between data points or window boundaries.  The optional argument `algo` must be a string constant: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-temporal-functions.html) The following formulas are used for computation where: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-temporal-functions.html) Equation for population standard deviation: ![\[Equation for population standard deviation.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/timeweightedstdev1.png) Equation for frequency standard deviation: ![\[Equation for frequency standard deviation.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/timeweighted-frequency-stdev.png)  | 

The following diagram shows how AWS IoT SiteWise computes the temporal functions `first`, `last`, `earliest`, and `latest`, relative to the current time interval.

![\[AWS IoT SiteWise temporal functions return data points based on their timestamp.\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/images/sitewise-temporal-functions.png)
<a name="time-range-def"></a>

**Note**  
The time range for `first(x)`, `last(x)` is (current window start, current window end].
The time range for `latest(x)` is (beginning of time, current window end].
The time range for `earliest(x)` is (beginning of time, previous window end].

**Time-weighted functions parameters**

Time-weighted functions computed for the aggregate window take into account the following:
+ Data points inside the window
+ Time intervals between data points
+ Last data point before the window
+ First data point after the window (for some algorithms)

**Terms:**
+ **Bad data point** – Any data point with non-good quality or non-number value. This is not considered in a window result computation.
+ **Bad interval** – The interval after a bad data point. The interval before the first known data point is also considered a bad interval.
+ **Good data point** – Any data point with good quality and numeric value.

**Note**  
AWS IoT SiteWise only consumes `GOOD` quality data when it computes transforms and metrics. It ignores `UNCERTAIN` and `BAD` data points.
The interval before the first known data point is considered a **bad interval**. See [Formula expression tutorials](expression-tutorials.md) for more information.

The interval after the last known data point continues indefinitely, affecting all following windows. When a new data point arrives, the function recomputes the interval.

Following the rules above, the aggregate window result is computed and limited to window boundaries. By default, the function only sends the window result if the whole window is a **good interval**.

If the window **good interval** is smaller than the window length, the function does not send the window. 

When the data points affecting the window result change, the function recalculates the window, even if the data points are outside of the window. 

If the input property has at least one data point in its history and a computation has been initiated, the function calculates the time-weighted aggregate functions for every time interval.

**Example statetime scenario**  
Consider an example where you have an asset with the following properties:  
+ `Idle` – A measurement that is `0` or `1`. When the value is `1`, the machine is idle.
+ `Idle Time` – A metric that uses the formula `statetime(Idle)` to calculate the amount of time in seconds where the machine is idle, per 1 minute interval.
The `Idle` property has the following data points.  


|  |  |  |  |  |  | 
| --- |--- |--- |--- |--- |--- |
| Timestamp | 2:00:00 PM | 2:00:30 PM | 2:01:15 PM | 2:02:45 PM | 2:04:00 PM | 
| Idle | 0 | 1 | 1 | 0 | 0 | 
AWS IoT SiteWise calculates the `Idle Time` property every minute from the values of `Idle`. After this calculation completes, the `Idle Time` property has the following data points.  


|  |  |  |  |  |  | 
| --- |--- |--- |--- |--- |--- |
| Timestamp | 2:00:00 PM | 2:01:00 PM | 2:02:00 PM | 2:03:00 PM | 2:04:00 PM | 
| Idle Time | N/A | 30 | 60 | 45 | 0 | 
AWS IoT SiteWise performs the following calculations for `Idle Time` at the end of each minute.  
+ At 2:00 PM (for 1:59 PM to 2:00 PM)
  + There is no data for `Idle` before 2:00 PM, so no data point is calculated.
+ At 2:01 PM (for 2:00 PM to 2:01 PM)
  + At 2:00:00 PM, the machine is active (`Idle` is `0`).
  + At 2:00:30 PM, the machine is idle (`Idle` is `1`).
  + `Idle` doesn't change again before the end of the interval at 2:01:00 PM, so `Idle Time` is 30 seconds.
+ At 2:02 PM (for 2:01 PM to 2:02 PM)
  + At 2:01:00 PM, the machine is idle (per the last data point at 2:00:30 PM).
  + At 2:01:15 PM, the machine is still idle.
  + `Idle` doesn't change again before the end of the interval at 2:02:00 PM, so `Idle Time` is 60 seconds.
+ At 2:03 PM (for 2:02 PM to 2:03 PM)
  + At 2:02:00 PM, the machine is idle (per the last data point at 2:01:15 PM).
  + At 2:02:45 PM, the machine is active.
  + `Idle` doesn't change again before the end of the interval at 2:03:00 PM, so `Idle Time` is 45 seconds.
+ At 2:04 PM (for 2:03 PM to 2:04 PM)
  + At 2:03:00 PM, the machine is active (per the last data point at 2:02:45 PM).
  + `Idle` doesn't change again before the end of the interval at 2:04:00 PM, so `Idle Time` is 0 seconds.

**Example TimeWeightedAvg and TimeWeightedStDev scenario**  
The following tables provide sample inputs and outputs for these one-minute window metrics: `Avg(x), TimeWeightedAvg(x), TimeWeightedAvg(x, "linear"), stDev(x), timeWeightedStDev(x), timeWeightedStDev(x, 'p')`.  
Sample input for one-minute aggregate window:  
These data points all have `GOOD` quality.


|  |  | 
| --- |--- |
| 03:00:00 | 4.0 | 
| 03:01:00 | 2.0 | 
| 03:01:10 | 8.0 | 
| 03:01:50 | 20.0 | 
| 03:02:00 | 14.0 | 
| 03:02:05 | 10.0 | 
| 03:02:10 | 3.0 | 
| 03:02:30 | 20.0 | 
| 03:03:30 | 0.0 | 
Aggregate results output:  
None – Result not produced for this window.


| Time | `Avg(x)` | `TimeWeightedAvg(x)` | `TimeWeightedAvg(X, "linear")` | `stDev(X)` | `timeWeightedStDev(x)` | `timeWeightedStDev(x, 'p')` | 
| --- | --- | --- | --- | --- | --- | --- | 
| 3:00:00 | 4 | None | None | 0 | None | None | 
| 3:01:00 | 2 | 4 | 3 | 0 | 0 | 0 | 
| 3:02:00 | 14 | 9 | 13 | 6 | 5.430610041581775 | 5.385164807134504 | 
| 3:03:00 | 11 | 13 | 12.875 | 8.54400374531753 | 7.724054437220943 | 7.659416862050705 | 
| 3:04:00 | 0 | 10 | 2.5 | 0 | 10.084389681792215 | 10 | 
| 3:05:00 | None | 0 | 0 | None | 0 | 0 | 

## Use temporal functions in transforms
<a name="temporal-functions-in-transforms"></a>

In [transforms](transforms.md) only, you can use the `pretrigger()` function to retrieve the `GOOD` quality value for a variable prior to the property update that initiated the current transform calculation.

Consider an example where a manufacturer uses AWS IoT SiteWise to monitor the status of a machine. The manufacturer uses the following measurements and transforms to represent the process:
+ A measurement, `current_state`, that can be 0 or 1.
  + If the machine is in the cleaning state, `current_state` equals 1.
  + If the machine is in the manufacturing state, `current_state` equals 0.
+ A transform, `cleaning_state_duration`, that equals `if(pretrigger(current_state) == 1, timestamp(current_state) - timestamp(pretrigger(current_state)), none)`. This transform returns how long the machine has been in the cleaning state in seconds, in the Unix epoch format. For more information, see [Use conditional functions in formula expressions](expression-conditional-functions.md) and the [timestamp()](expression-date-and-time-functions.md) function.

If the machine stays in the cleaning state longer than expected, the manufacturer might investigate the machine.

You can also use the `pretrigger()` function in multivariate transforms. For example, you have two measurements named `x` and `y`, and a transform, `z`, that equals `x + y + pretrigger(y)`. The following table shows the values for `x`, `y`, and `z` from 9:00 AM to 9:15 AM.

**Note**  
This example assumes that the values for the measurements arrive chronologically. For example, the value of `x` for 09:00 AM arrives before the value of `x` for 09:05 AM.
If the data points for 9:05 AM arrive before the data points for 9:00 AM, `z` isn't calculated at 9:05 AM.
If the value of `x` for 9:05 AM arrives before the value of `x` for 09:00 AM and the values of `y` arrive chronologically, `z` equals `22 = 20 + 1 + 1` at 9:05 AM.


|  | 09:00 AM | 09:05 AM | 09:10 AM | 09:15 AM | 
| --- | --- | --- | --- | --- | 
|  `x`  |  10  |  20  |    |  30  | 
|  `y`  |  1  |  2  |  3  |    | 
|  `z = x + y + pretrigger(y)`  |  `y` doesn't receive any data point before 09:00 AM. Therefore, `z` isn't calculated at 09:00 AM.  |  23 = 20 \$1 2 \$1 1 `pretrigger(y)` equals 1.  |  25 = 20 \$1 3 \$1 2 `x` doesn't receive a new data point. `pretrigger(y)` equals 2.  |  36 = 30 \$1 3 \$1 3 `y` doesn't receive a new data point. Therefore, `pretrigger(y)` equals 3 at 09:15 AM.  | 

# Use date and time functions in formula expressions
<a name="expression-date-and-time-functions"></a>

In [transforms](transforms.md) and [metrics](metrics.md), you can use the date and time functions in the following ways:
+ Retrieve the current timestamp of a data point in UTC or in the local time zone.
+ Construct timestamps with arguments, such as `year`, `month`, and `day_of_month`.
+ Extract a time period such as a year or month with the `unix_time` argument.


| Function | Description | 
| --- | --- | 
|  `now()`  |  Returns the current date and time, in seconds, in the Unix epoch format.  | 
|  `timestamp()`  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-date-and-time-functions.html)  | 
|  `mktime(time_zone, year, month, day_of_month, hour, minute, second)`  |  Returns the input time in seconds, in the Unix epoch format. The following requirements apply for using this function: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-date-and-time-functions.html) The following limits apply for using this function: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-date-and-time-functions.html) Examples: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-date-and-time-functions.html)  | 
|  `localtime(unix_time, time_zone)`  |  Returns the year, the day of the month, the day of the week, the day of the year, the hour, the minute, or the second in the specified time zone from the Unix time. The following requirements apply for using this function: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-date-and-time-functions.html) Example response: `2007-12-03T10:15:30+01:00[Europe/Paris]` `localtime(unix_time, time_zone)` isn't a standalone function. The `year()`, `mon()`, `mday`, `wday()`, `yday()`, `hour()`, `minute()`, and `sec()` functions take `localtime(unix_time, time_zone)` as an argument. Examples: [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/iot-sitewise/latest/userguide/expression-date-and-time-functions.html)  | 
|  `year(localtime(unix_time, time_zone)`  |  Returns the year from `localtime(unix_time, time_zone)`.  | 
|  `mon(localtime(unix_time, time_zone))`  |  Returns the month from `localtime(unix_time, time_zone)`.  | 
|  `mday(localtime(unix_time, time_zone))`  |  Returns the day of the month from `localtime(unix_time, time_zone)`.  | 
|  `wday(localtime(unix_time, time_zone))`  |  Returns the day of the week from `localtime(unix_time, time_zone)`.  | 
|  `yday(localtime(unix_time, time_zone))`  |  Returns the day of the year from `localtime(unix_time, time_zone)`.  | 
|  `hour(localtime(unix_time, time_zone))`  |  Returns the hour from `localtime(unix_time, time_zone)`.  | 
|  `minute(localtime(unix_time, time_zone))`  |  Returns the minute from `localtime(unix_time, time_zone)`.  | 
|  `sec(localtime(unix_time, time_zone))`  |  Returns the second from `localtime(unix_time, time_zone)`.  | 

## Supported time zone formats
<a name="time-zone-expressions"></a>

You can specify the time zone argument in the following ways:
+ Time zone offset - Specify `'Z'` for UTC or an offset (`'+2'` or `'-5'`).
+ Offset IDs - Combine a time zone abbreviation and an offset. For example, `'GMT+2'` and `'UTC-01:00'`. The time zone abbreviation must contain only three letters.
+ Region based IDs - For example, `'Etc/GMT+12'` and `'Pacific/Pago_Pago'`.

### Supported time zone abbreviations
<a name="spported-time-zones"></a>

The date and time functions support the following three-letter time zone abbreviations: 
+ EST - -05:00
+ HST - -10:00
+ MST - -07:00
+ ACT - Australia/Darwin
+ AET - Australia/Sydney
+ AGT - America/Argentina/Buenos\$1Aires
+ ART - Africa/Cairo
+ AST - America/Anchorage
+ BET - America/Sao\$1Paulo
+ BST - Asia/Dhaka
+ CAT - Africa/Harare
+ CET - Europe/Paris
+ CNT - America/St\$1Johns
+ CST - America/Chicago
+ CTT - Asia/Shanghai 
+ EAT - Africa/Addis\$1Ababa
+ IET - America/Indiana/Indianapolis
+ IST - Asia/Kolkata
+ JST - Asia/Tokyo
+ MIT - Pacific/Apia
+ NET - Asia/Yerevan
+ NST - Pacific/Auckland
+ PLT - Asia/Karachi
+ PRT - America/Puerto\$1Rico
+ PST - America/Los\$1Angeles
+ SST - Pacific/Guadalcanal
+ VST - Asia/Ho\$1Chi\$1Minh

### Supported Region-based IDs
<a name="supported-region-based-ids"></a>

The date and time functions support the following Region-based IDs, organized by their relation to UTC\$100:00:
+ Etc/GMT\$112 (UTC-12:00)
+ Pacific/Pago\$1Pago (UTC-11:00)
+ Pacific/Samoa (UTC-11:00)
+ Pacific/Niue (UTC-11:00)
+ US/Samoa (UTC-11:00)
+ Etc/GMT\$111 (UTC-11:00)
+ Pacific/Midway (UTC-11:00)
+ Pacific/Honolulu (UTC-10:00)
+ Pacific/Rarotonga (UTC-10:00)
+ Pacific/Tahiti (UTC-10:00)
+ Pacific/Johnston (UTC-10:00)
+ US/Hawaii (UTC-10:00)
+ SystemV/HST10 (UTC-10:00)
+ Etc/GMT\$110 (UTC-10:00)
+ Pacific/Marquesas (UTC-09:30)
+ Etc/GMT\$19 (UTC-09:00)
+ Pacific/Gambier (UTC-09:00)
+ America/Atka (UTC-09:00)
+ SystemV/YST9 (UTC-09:00)
+ America/Adak (UTC-09:00)
+ US/Aleutian (UTC-09:00)
+ Etc/GMT\$18 (UTC-08:00)
+ US/Alaska (UTC-08:00)
+ America/Juneau (UTC-08:00)
+ America/Metlakatla (UTC-08:00)
+ America/Yakutat (UTC-08:00)
+ Pacific/Pitcairn (UTC-08:00)
+ America/Sitka (UTC-08:00)
+ America/Anchorage (UTC-08:00)
+ SystemV/PST8 (UTC-08:00)
+ America/Nome (UTC-08:00)
+ SystemV/YST9YDT (UTC-08:00)
+ Canada/Yukon (UTC-07:00)
+ US/Pacific-New (UTC-07:00)
+ Etc/GMT\$17 (UTC-07:00)
+ US/Arizona (UTC-07:00)
+ America/Dawson\$1Creek (UTC-07:00)
+ Canada/Pacific (UTC-07:00)
+ PST8PDT (UTC-07:00)
+ SystemV/MST7 (UTC-07:00)
+ America/Dawson (UTC-07:00)
+ Mexico/BajaNorte (UTC-07:00)
+ America/Tijuana (UTC-07:00)
+ America/Creston (UTC-07:00)
+ America/Hermosillo (UTC-07:00)
+ America/Santa\$1Isabel (UTC-07:00)
+ America/Vancouver (UTC-07:00)
+ America/Ensenada (UTC-07:00)
+ America/Phoenix (UTC-07:00)
+ America/Whitehorse (UTC-07:00)
+ America/Fort\$1Nelson (UTC-07:00)
+ SystemV/PST8PDT (UTC-07:00)
+ America/Los\$1Angeles (UTC-07:00)
+ US/Pacific (UTC-07:00)
+ America/El\$1Salvador (UTC-06:00)
+ America/Guatemala (UTC-06:00)
+ America/Belize (UTC-06:00)
+ America/Managua (UTC-06:00)
+ America/Tegucigalpa (UTC-06:00)
+ Etc/GMT\$16 (UTC-06:00)
+ Pacific/Easter (UTC-06:00)
+ Mexico/BajaSur (UTC-06:00)
+ America/Regina (UTC-06:00)
+ America/Denver (UTC-06:00)
+ Pacific/Galapagos (UTC-06:00)
+ America/Yellowknife (UTC-06:00)
+ America/Swift\$1Current (UTC-06:00)
+ America/Inuvik (UTC-06:00)
+ America/Mazatlan (UTC-06:00)
+ America/Boise (UTC-06:00)
+ America/Costa\$1Rica (UTC-06:00)
+ MST7MDT (UTC-06:00)
+ SystemV/CST6 (UTC-06:00)
+ America/Chihuahua (UTC-06:00)
+ America/Ojinaga (UTC-06:00)
+ Chile/EasterIsland (UTC-06:00)
+ US/Mountain (UTC-06:00)
+ America/Edmonton (UTC-06:00)
+ Canada/Mountain (UTC-06:00)
+ America/Cambridge\$1Bay (UTC-06:00)
+ Navajo (UTC-06:00)
+ SystemV/MST7MDT (UTC-06:00)
+ Canada/Saskatchewan (UTC-06:00)
+ America/Shiprock (UTC-06:00)
+ America/Panama (UTC-05:00)
+ America/Chicago (UTC-05:00)
+ America/Eirunepe (UTC-05:00)
+ Etc/GMT\$15 (UTC-05:00)
+ Mexico/General (UTC-05:00)
+ America/Porto\$1Acre (UTC-05:00)
+ America/Guayaquil (UTC-05:00)
+ America/Rankin\$1Inlet (UTC-05:00)
+ US/Central (UTC-05:00)
+ America/Rainy\$1River (UTC-05:00)
+ America/Indiana/Knox (UTC-05:00)
+ America/North\$1Dakota/Beulah (UTC-05:00)
+ America/Monterrey (UTC-05:00)
+ America/Jamaica (UTC-05:00)
+ America/Atikokan (UTC-05:00)
+ America/Coral\$1Harbour (UTC-05:00)
+ America/North\$1Dakota/Center (UTC-05:00)
+ America/Cayman (UTC-05:00)
+ America/Indiana/Tell\$1City (UTC-05:00)
+ America/Mexico\$1City (UTC-05:00)
+ America/Matamoros (UTC-05:00)
+ CST6CDT (UTC-05:00)
+ America/Knox\$1IN (UTC-05:00)
+ America/Bogota (UTC-05:00)
+ America/Menominee (UTC-05:00)
+ America/Resolute (UTC-05:00)
+ SystemV/EST5 (UTC-05:00)
+ Canada/Central (UTC-05:00)
+ Brazil/Acre (UTC-05:00)
+ America/Cancun (UTC-05:00)
+ America/Lima (UTC-05:00)
+ America/Bahia\$1Banderas (UTC-05:00)
+ US/Indiana-Starke (UTC-05:00)
+ America/Rio\$1Branco (UTC-05:00)
+ SystemV/CST6CDT (UTC-05:00)
+ Jamaica (UTC-05:00)
+ America/Merida (UTC-05:00)
+ America/North\$1Dakota/New\$1Salem (UTC-05:00)
+ America/Winnipeg (UTC-05:00)
+ America/Cuiaba (UTC-04:00)
+ America/Marigot (UTC-04:00)
+ America/Indiana/Petersburg (UTC-04:00)
+ Chile/Continental (UTC-04:00)
+ America/Grand\$1Turk (UTC-04:00)
+ Cuba (UTC-04:00)
+ Etc/GMT\$14 (UTC-04:00)
+ America/Manaus (UTC-04:00)
+ America/Fort\$1Wayne (UTC-04:00)
+ America/St\$1Thomas (UTC-04:00)
+ America/Anguilla (UTC-04:00)
+ America/Havana (UTC-04:00)
+ US/Michigan (UTC-04:00)
+ America/Barbados (UTC-04:00)
+ America/Louisville (UTC-04:00)
+ America/Curacao (UTC-04:00)
+ America/Guyana (UTC-04:00)
+ America/Martinique (UTC-04:00)
+ America/Puerto\$1Rico (UTC-04:00)
+ America/Port\$1of\$1Spain (UTC-04:00)
+ SystemV/AST4 (UTC-04:00)
+ America/Indiana/Vevay (UTC-04:00)
+ America/Indiana/Vincennes (UTC-04:00)
+ America/Kralendijk (UTC-04:00)
+ America/Antigua (UTC-04:00)
+ America/Indianapolis (UTC-04:00)
+ America/Iqaluit (UTC-04:00)
+ America/St\$1Vincent (UTC-04:00)
+ America/Kentucky/Louisville (UTC-04:00)
+ America/Dominica (UTC-04:00)
+ America/Asuncion (UTC-04:00)
+ EST5EDT (UTC-04:00)
+ America/Nassau (UTC-04:00)
+ America/Kentucky/Monticello (UTC-04:00)
+ Brazil/West (UTC-04:00)
+ America/Aruba (UTC-04:00)
+ America/Indiana/Indianapolis (UTC-04:00)
+ America/Santiago (UTC-04:00)
+ America/La\$1Paz (UTC-04:00)
+ America/Thunder\$1Bay (UTC-04:00)
+ America/Indiana/Marengo (UTC-04:00)
+ America/Blanc-Sablon (UTC-04:00)
+ America/Santo\$1Domingo (UTC-04:00)
+ US/Eastern (UTC-04:00)
+ Canada/Eastern (UTC-04:00)
+ America/Port-au-Prince (UTC-04:00)
+ America/St\$1Barthelemy (UTC-04:00)
+ America/Nipigon (UTC-04:00)
+ US/East-Indiana (UTC-04:00)
+ America/St\$1Lucia (UTC-04:00)
+ America/Montserrat (UTC-04:00)
+ America/Lower\$1Princes (UTC-04:00)
+ America/Detroit (UTC-04:00)
+ America/Tortola (UTC-04:00)
+ America/Porto\$1Velho (UTC-04:00)
+ America/Campo\$1Grande (UTC-04:00)
+ America/Virgin (UTC-04:00)
+ America/Pangnirtung (UTC-04:00)
+ America/Montreal (UTC-04:00)
+ America/Indiana/Winamac (UTC-04:00)
+ America/Boa\$1Vista (UTC-04:00)
+ America/Grenada (UTC-04:00)
+ America/New\$1York (UTC-04:00)
+ America/St\$1Kitts (UTC-04:00)
+ America/Caracas (UTC-04:00)
+ America/Guadeloupe (UTC-04:00)
+ America/Toronto (UTC-04:00)
+ SystemV/EST5EDT (UTC-04:00)
+ America/Argentina/Catamarca (UTC-03:00)
+ Canada/Atlantic (UTC-03:00)
+ America/Argentina/Cordoba (UTC-03:00)
+ America/Araguaina (UTC-03:00)
+ America/Argentina/Salta (UTC-03:00)
+ Etc/GMT\$13 (UTC-03:00)
+ America/Montevideo (UTC-03:00)
+ Brazil/East (UTC-03:00)
+ America/Argentina/Mendoza (UTC-03:00)
+ America/Argentina/Rio\$1Gallegos (UTC-03:00)
+ America/Catamarca (UTC-03:00)
+ America/Cordoba (UTC-03:00)
+ America/Sao\$1Paulo (UTC-03:00)
+ America/Argentina/Jujuy (UTC-03:00)
+ America/Cayenne (UTC-03:00)
+ America/Recife (UTC-03:00)
+ America/Buenos\$1Aires (UTC-03:00)
+ America/Paramaribo (UTC-03:00)
+ America/Moncton (UTC-03:00)
+ America/Mendoza (UTC-03:00)
+ America/Santarem (UTC-03:00)
+ Atlantic/Bermuda (UTC-03:00)
+ America/Maceio (UTC-03:00)
+ Atlantic/Stanley (UTC-03:00)
+ America/Halifax (UTC-03:00)
+ Antarctica/Rothera (UTC-03:00)
+ America/Argentina/San\$1Luis (UTC-03:00)
+ America/Argentina/Ushuaia (UTC-03:00)
+ Antarctica/Palmer (UTC-03:00)
+ America/Punta\$1Arenas (UTC-03:00)
+ America/Glace\$1Bay (UTC-03:00)
+ America/Fortaleza (UTC-03:00)
+ America/Thule (UTC-03:00)
+ America/Argentina/La\$1Rioja (UTC-03:00)
+ America/Belem (UTC-03:00)
+ America/Jujuy (UTC-03:00)
+ America/Bahia (UTC-03:00)
+ America/Goose\$1Bay (UTC-03:00)
+ America/Argentina/San\$1Juan (UTC-03:00)
+ America/Argentina/ComodRivadavia (UTC-03:00)
+ America/Argentina/Tucuman (UTC-03:00)
+ America/Rosario (UTC-03:00)
+ SystemV/AST4ADT (UTC-03:00)
+ America/Argentina/Buenos\$1Aires (UTC-03:00)
+ America/St\$1Johns (UTC-02:30)
+ Canada/Newfoundland (UTC-02:30)
+ America/Miquelon (UTC-02:00)
+ Etc/GMT\$12 (UTC-02:00)
+ America/Godthab (UTC-02:00)
+ America/Noronha (UTC-02:00)
+ Brazil/DeNoronha (UTC-02:00)
+ Atlantic/South\$1Georgia (UTC-02:00)
+ Etc/GMT\$11 (UTC-01:00)
+ Atlantic/Cape\$1Verde (UTC-01:00)
+ Pacific/Kiritimati (UTC\$114:00)
+ Etc/GMT-14 (UTC\$114:00)
+ Pacific/Fakaofo (UTC\$113:00)
+ Pacific/Enderbury (UTC\$113:00)
+ Pacific/Apia (UTC\$113:00)
+ Pacific/Tongatapu (UTC\$113:00)
+ Etc/GMT-13 (UTC\$113:00)
+ NZ-CHAT (UTC\$112:45)
+ Pacific/Chatham (UTC\$112:45)
+ Pacific/Kwajalein (UTC\$112:00)
+ Antarctica/McMurdo (UTC\$112:00)
+ Pacific/Wallis (UTC\$112:00)
+ Pacific/Fiji (UTC\$112:00)
+ Pacific/Funafuti (UTC\$112:00)
+ Pacific/Nauru (UTC\$112:00)
+ Kwajalein (UTC\$112:00)
+ NZ (UTC\$112:00)
+ Pacific/Wake (UTC\$112:00)
+ Antarctica/South\$1Pole (UTC\$112:00)
+ Pacific/Tarawa (UTC\$112:00)
+ Pacific/Auckland (UTC\$112:00)
+ Asia/Kamchatka (UTC\$112:00)
+ Etc/GMT-12 (UTC\$112:00)
+ Asia/Anadyr (UTC\$112:00)
+ Pacific/Majuro (UTC\$112:00)
+ Pacific/Ponape (UTC\$111:00)
+ Pacific/Bougainville (UTC\$111:00)
+ Antarctica/Macquarie (UTC\$111:00)
+ Pacific/Pohnpei (UTC\$111:00)
+ Pacific/Efate (UTC\$111:00)
+ Pacific/Norfolk (UTC\$111:00)
+ Asia/Magadan (UTC\$111:00)
+ Pacific/Kosrae (UTC\$111:00)
+ Asia/Sakhalin (UTC\$111:00)
+ Pacific/Noumea (UTC\$111:00)
+ Etc/GMT-11 (UTC\$111:00)
+ Asia/Srednekolymsk (UTC\$111:00)
+ Pacific/Guadalcanal (UTC\$111:00)
+ Australia/Lord\$1Howe (UTC\$110:30)
+ Australia/LHI (UTC\$110:30)
+ Australia/Hobart (UTC\$110:00)
+ Pacific/Yap (UTC\$110:00)
+ Australia/Tasmania (UTC\$110:00)
+ Pacific/Port\$1Moresby (UTC\$110:00)
+ Australia/ACT (UTC\$110:00)
+ Australia/Victoria (UTC\$110:00)
+ Pacific/Chuuk (UTC\$110:00)
+ Australia/Queensland (UTC\$110:00)
+ Australia/Canberra (UTC\$110:00)
+ Australia/Currie (UTC\$110:00)
+ Pacific/Guam (UTC\$110:00)
+ Pacific/Truk (UTC\$110:00)
+ Australia/NSW (UTC\$110:00)
+ Asia/Vladivostok (UTC\$110:00)
+ Pacific/Saipan (UTC\$110:00)
+ Antarctica/DumontDUrville (UTC\$110:00)
+ Australia/Sydney (UTC\$110:00)
+ Australia/Brisbane (UTC\$110:00)
+ Etc/GMT-10 (UTC\$110:00)
+ Asia/Ust-Nera (UTC\$110:00)
+ Australia/Melbourne (UTC\$110:00)
+ Australia/Lindeman (UTC\$110:00)
+ Australia/North (UTC\$109:30)
+ Australia/Yancowinna (UTC\$109:30)
+ Australia/Adelaide (UTC\$109:30)
+ Australia/Broken\$1Hill (UTC\$109:30)
+ Australia/South (UTC\$109:30)
+ Australia/Darwin (UTC\$109:30)
+ Etc/GMT-9 (UTC\$109:00)
+ Pacific/Palau (UTC\$109:00)
+ Asia/Chita (UTC\$109:00)
+ Asia/Dili (UTC\$109:00)
+ Asia/Jayapura (UTC\$109:00)
+ Asia/Yakutsk (UTC\$109:00)
+ Asia/Pyongyang (UTC\$109:00)
+ ROK (UTC\$109:00)
+ Asia/Seoul (UTC\$109:00)
+ Asia/Khandyga (UTC\$109:00)
+ Japan (UTC\$109:00)
+ Asia/Tokyo (UTC\$109:00)
+ Australia/Eucla (UTC\$108:45)
+ Asia/Kuching (UTC\$108:00)
+ Asia/Chungking (UTC\$108:00)
+ Etc/GMT-8 (UTC\$108:00)
+ Australia/Perth (UTC\$108:00)
+ Asia/Macao (UTC\$108:00)
+ Asia/Macau (UTC\$108:00)
+ Asia/Choibalsan (UTC\$108:00)
+ Asia/Shanghai (UTC\$108:00)
+ Antarctica/Casey (UTC\$108:00)
+ Asia/Ulan\$1Bator (UTC\$108:00)
+ Asia/Chongqing (UTC\$108:00)
+ Asia/Ulaanbaatar (UTC\$108:00)
+ Asia/Taipei (UTC\$108:00)
+ Asia/Manila (UTC\$108:00)
+ PRC (UTC\$108:00)
+ Asia/Ujung\$1Pandang (UTC\$108:00)
+ Asia/Harbin (UTC\$108:00)
+ Singapore (UTC\$108:00)
+ Asia/Brunei (UTC\$108:00)
+ Australia/West (UTC\$108:00)
+ Asia/Hong\$1Kong (UTC\$108:00)
+ Asia/Makassar (UTC\$108:00)
+ Hongkong (UTC\$108:00)
+ Asia/Kuala\$1Lumpur (UTC\$108:00)
+ Asia/Irkutsk (UTC\$108:00)
+ Asia/Singapore (UTC\$108:00)
+ Asia/Pontianak (UTC\$107:00)
+ Etc/GMT-7 (UTC\$107:00)
+ Asia/Phnom\$1Penh (UTC\$107:00)
+ Asia/Novosibirsk (UTC\$107:00)
+ Antarctica/Davis (UTC\$107:00)
+ Asia/Tomsk (UTC\$107:00)
+ Asia/Jakarta (UTC\$107:00)
+ Asia/Barnaul (UTC\$107:00)
+ Indian/Christmas (UTC\$107:00)
+ Asia/Ho\$1Chi\$1Minh (UTC\$107:00)
+ Asia/Hovd (UTC\$107:00)
+ Asia/Bangkok (UTC\$107:00)
+ Asia/Vientiane (UTC\$107:00)
+ Asia/Novokuznetsk (UTC\$107:00)
+ Asia/Krasnoyarsk (UTC\$107:00)
+ Asia/Saigon (UTC\$107:00)
+ Asia/Yangon (UTC\$106:30)
+ Asia/Rangoon (UTC\$106:30)
+ Indian/Cocos (UTC\$106:30)
+ Asia/Kashgar (UTC\$106:00)
+ Etc/GMT-6 (UTC\$106:00)
+ Asia/Almaty (UTC\$106:00)
+ Asia/Dacca (UTC\$106:00)
+ Asia/Omsk (UTC\$106:00)
+ Asia/Dhaka (UTC\$106:00)
+ Indian/Chagos (UTC\$106:00)
+ Asia/Qyzylorda (UTC\$106:00)
+ Asia/Bishkek (UTC\$106:00)
+ Antarctica/Vostok (UTC\$106:00)
+ Asia/Urumqi (UTC\$106:00)
+ Asia/Thimbu (UTC\$106:00)
+ Asia/Thimphu (UTC\$106:00)
+ Asia/Kathmandu (UTC\$105:45)
+ Asia/Katmandu (UTC\$105:45)
+ Asia/Kolkata (UTC\$105:30)
+ Asia/Colombo (UTC\$105:30)
+ Asia/Calcutta (UTC\$105:30)
+ Asia/Aqtau (UTC\$105:00)
+ Etc/GMT-5 (UTC\$105:00)
+ Asia/Samarkand (UTC\$105:00)
+ Asia/Karachi (UTC\$105:00)
+ Asia/Yekaterinburg (UTC\$105:00)
+ Asia/Dushanbe (UTC\$105:00)
+ Indian/Maldives (UTC\$105:00)
+ Asia/Oral (UTC\$105:00)
+ Asia/Tashkent (UTC\$105:00)
+ Antarctica/Mawson (UTC\$105:00)
+ Asia/Aqtobe (UTC\$105:00)
+ Asia/Ashkhabad (UTC\$105:00)
+ Asia/Ashgabat (UTC\$105:00)
+ Asia/Atyrau (UTC\$105:00)
+ Indian/Kerguelen (UTC\$105:00)
+ Iran (UTC\$104:30)
+ Asia/Tehran (UTC\$104:30)
+ Asia/Kabul (UTC\$104:30)
+ Asia/Yerevan (UTC\$104:00)
+ Etc/GMT-4 (UTC\$104:00)
+ Etc/GMT-4 (UTC\$104:00)
+ Asia/Dubai (UTC\$104:00)
+ Indian/Reunion (UTC\$104:00)
+ Europe/Saratov (UTC\$104:00)
+ Europe/Samara (UTC\$104:00)
+ Indian/Mahe (UTC\$104:00)
+ Asia/Baku (UTC\$104:00)
+ Asia/Muscat (UTC\$104:00)
+ Europe/Volgograd (UTC\$104:00)
+ Europe/Astrakhan (UTC\$104:00)
+ Asia/Tbilisi (UTC\$104:00)
+ Europe/Ulyanovsk (UTC\$104:00)
+ Asia/Aden (UTC\$103:00)
+ Africa/Nairobi (UTC\$103:00)
+ Europe/Istanbul (UTC\$103:00)
+ Etc/GMT-3 (UTC\$103:00)
+ Europe/Zaporozhye (UTC\$103:00)
+ Israel (UTC\$103:00)
+ Indian/Comoro (UTC\$103:00)
+ Antarctica/Syowa (UTC\$103:00)
+ Africa/Mogadishu (UTC\$103:00)
+ Europe/Bucharest (UTC\$103:00)
+ Africa/Asmera (UTC\$103:00)
+ Europe/Mariehamn (UTC\$103:00)
+ Asia/Istanbul (UTC\$103:00)
+ Europe/Tiraspol (UTC\$103:00)
+ Europe/Moscow (UTC\$103:00)
+ Europe/Chisinau (UTC\$103:00)
+ Europe/Helsinki (UTC\$103:00)
+ Asia/Beirut (UTC\$103:00)
+ Asia/Tel\$1Aviv (UTC\$103:00)
+ Africa/Djibouti (UTC\$103:00)
+ Europe/Simferopol (UTC\$103:00)
+ Europe/Sofia (UTC\$103:00)
+ Asia/Gaza (UTC\$103:00)
+ Africa/Asmara (UTC\$103:00)
+ Europe/Riga (UTC\$103:00)
+ Asia/Baghdad (UTC\$103:00)
+ Asia/Damascus (UTC\$103:00)
+ Africa/Dar\$1es\$1Salaam (UTC\$103:00)
+ Africa/Addis\$1Ababa (UTC\$103:00)
+ Europe/Uzhgorod (UTC\$103:00)
+ Asia/Jerusalem (UTC\$103:00)
+ Asia/Riyadh (UTC\$103:00)
+ Asia/Kuwait (UTC\$103:00)
+ Europe/Kirov (UTC\$103:00)
+ Africa/Kampala (UTC\$103:00)
+ Europe/Minsk (UTC\$103:00)
+ Asia/Qatar (UTC\$103:00)
+ Europe/Kiev (UTC\$103:00)
+ Asia/Bahrain (UTC\$103:00)
+ Europe/Vilnius (UTC\$103:00)
+ Indian/Antananarivo (UTC\$103:00)
+ Indian/Mayotte (UTC\$103:00)
+ Europe/Tallinn (UTC\$103:00)
+ Turkey (UTC\$103:00)
+ Africa/Juba (UTC\$103:00)
+ Asia/Nicosia (UTC\$103:00)
+ Asia/Famagusta (UTC\$103:00)
+ W-SU (UTC\$103:00)
+ EET (UTC\$103:00)
+ Asia/Hebron (UTC\$103:00)
+ Asia/Amman (UTC\$103:00)
+ Europe/Nicosia (UTC\$103:00)
+ Europe/Athens (UTC\$103:00)
+ Africa/Cairo (UTC\$102:00)
+ Africa/Mbabane (UTC\$102:00)
+ Europe/Brussels (UTC\$102:00)
+ Europe/Warsaw (UTC\$102:00)
+ CET (UTC\$102:00)
+ Europe/Luxembourg (UTC\$102:00)
+ Etc/GMT-2 (UTC\$102:00)
+ Libya (UTC\$102:00)
+ Africa/Kigali (UTC\$102:00)
+ Africa/Tripoli (UTC\$102:00)
+ Europe/Kaliningrad (UTC\$102:00)
+ Africa/Windhoek (UTC\$102:00)
+ Europe/Malta (UTC\$102:00)
+ Europe/Busingen (UTC\$102:00)
+ 
+ Europe/Skopje (UTC\$102:00)
+ Europe/Sarajevo (UTC\$102:00)
+ Europe/Rome (UTC\$102:00)
+ Europe/Zurich (UTC\$102:00)
+ Europe/Gibraltar (UTC\$102:00)
+ Africa/Lubumbashi (UTC\$102:00)
+ Europe/Vaduz (UTC\$102:00)
+ Europe/Ljubljana (UTC\$102:00)
+ Europe/Berlin (UTC\$102:00)
+ Europe/Stockholm (UTC\$102:00)
+ Europe/Budapest (UTC\$102:00)
+ Europe/Zagreb (UTC\$102:00)
+ Europe/Paris (UTC\$102:00)
+ Africa/Ceuta (UTC\$102:00)
+ Europe/Prague (UTC\$102:00)
+ Antarctica/Troll (UTC\$102:00)
+ Africa/Gaborone (UTC\$102:00)
+ Europe/Copenhagen (UTC\$102:00)
+ Europe/Vienna (UTC\$102:00)
+ Europe/Tirane (UTC\$102:00)
+ MET (UTC\$102:00)
+ Europe/Amsterdam (UTC\$102:00)
+ Africa/Maputo (UTC\$102:00)
+ Europe/San\$1Marino (UTC\$102:00)
+ Poland (UTC\$102:00)
+ Europe/Andorra (UTC\$102:00)
+ Europe/Oslo (UTC\$102:00)
+ Europe/Podgorica (UTC\$102:00)
+ Africa/Bujumbura (UTC\$102:00)
+ Atlantic/Jan\$1Mayen (UTC\$102:00)
+ Africa/Maseru (UTC\$102:00)
+ Europe/Madrid (UTC\$102:00)
+ Africa/Blantyre (UTC\$102:00)
+ Africa/Lusaka (UTC\$102:00)
+ Africa/Harare (UTC\$102:00)
+ Africa/Khartoum (UTC\$102:00)
+ Africa/Johannesburg (UTC\$102:00)
+ Europe/Belgrade (UTC\$102:00)
+ Europe/Bratislava (UTC\$102:00)
+ Arctic/Longyearbyen (UTC\$102:00)
+ Egypt (UTC\$102:00)
+ Europe/Vatican (UTC\$102:00)
+ Europe/Monaco (UTC\$102:00)
+ Europe/London (UTC\$101:00)
+ Etc/GMT-1 (UTC\$101:00)
+ Europe/Jersey (UTC\$101:00)
+ Europe/Guernsey (UTC\$101:00)
+ Europe/Isle\$1of\$1Man (UTC\$101:00)
+ Africa/Tunis (UTC\$101:00)
+ Africa/Malabo (UTC\$101:00)
+ GB-Eire (UTC\$101:00)
+ Africa/Lagos (UTC\$101:00)
+ Africa/Algiers (UTC\$101:00)
+ GB (UTC\$101:00)
+ Portugal (UTC\$101:00)
+ Africa/Sao\$1Tome (UTC\$101:00)
+ Africa/Ndjamena (UTC\$101:00)
+ Atlantic/Faeroe (UTC\$101:00)
+ Eire (UTC\$101:00)
+ Atlantic/Faroe (UTC\$101:00)
+ Europe/Dublin (UTC\$101:00)
+ Africa/Libreville (UTC\$101:00)
+ Africa/El\$1Aaiun (UTC\$101:00)
+ Africa/El\$1Aaiun (UTC\$101:00)
+ Africa/Douala (UTC\$101:00)
+ Africa/Brazzaville (UTC\$101:00)
+ Africa/Porto-Novo (UTC\$101:00)
+ Atlantic/Madeira (UTC\$101:00)
+ Europe/Lisbon (UTC\$101:00)
+ Atlantic/Canary (UTC\$101:00)
+ Africa/Casablanca (UTC\$101:00)
+ Europe/Belfast (UTC\$101:00)
+ Africa/Luanda (UTC\$101:00)
+ Africa/Kinshasa (UTC\$101:00)
+ Africa/Bangui (UTC\$101:00)
+ WET (UTC\$101:00)
+ Africa/Niamey (UTC\$101:00)
+ GMT (UTC\$100:00)
+ Etc/GMT-0 (UTC\$100:00)
+ Atlantic/St\$1Helena (UTC\$100:00)
+ Etc/GMT\$10 (UTC\$100:00)
+ Africa/Banjul (UTC\$100:00)
+ Etc/GMT (UTC\$100:00)
+ Africa/Freetown (UTC\$100:00)
+ Africa/Bamako (UTC\$100:00)
+ Africa/Conakry (UTC\$100:00)
+ Universal (UTC\$100:00)
+ Africa/Nouakchott (UTC\$100:00)
+ UTC (UTC\$100:00)
+ Etc/Universal (UTC\$100:00)
+ Atlantic/Azores (UTC\$100:00)
+ Africa/Abidjan (UTC\$100:00)
+ Africa/Accra (UTC\$100:00)
+ Etc/UCT (UTC\$100:00)
+ GMT0 (UTC\$100:00)
+ Zulu (UTC\$100:00)Zulu (UTC\$100:00)
+ Africa/Ouagadougou (UTC\$100:00)
+ Atlantic/Reykjavik (UTC\$100:00)
+ Etc/Zulu (UTC\$100:00)
+ Iceland (UTC\$100:00)
+ Africa/Lome (UTC\$100:00)
+ Greenwich (UTC\$100:00)
+ Etc/GMT0 (UTC\$100:00)
+ America/Danmarkshavn (UTC\$100:00)
+ Africa/Dakar (UTC\$100:00)
+ Africa/Bissau (UTC\$100:00)
+ Etc/Greenwich (UTC\$100:00)
+ Africa/Timbuktu (UTC\$100:00)
+ UCT (UTC\$100:00)
+ Africa/Monrovia (UTC\$100:00)
+ Etc/UTC (UTC\$100:00)

# Formula expression tutorials
<a name="expression-tutorials"></a>

You can follow these tutorials to use formula expressions in AWS IoT SiteWise.

**Topics**
+ [Use strings in formulas](#use-strings-in-formulas)
+ [Filter data points](#filter-data)
+ [Count data points that match a condition](#count-filtered-data)
+ [Late data in formulas](#late-data)
+ [Data quality in formulas](#data-quality)
+ [Undefined, infinite, and overflow values](#undefined-values)

## Use strings in formulas
<a name="use-strings-in-formulas"></a>

You can operate on strings in your formula expressions. You also can input strings from variables that reference attribute and measurement properties.

**Important**  
<a name="formula-output-rules"></a>Formula expressions can only output double or string values. Nested expressions can output other data types, such as strings, but the formula as a whole must evaluate to a number or string. You can use the [jp function](expression-string-functions.md#jp-definition) to convert a string to a number. The Boolean value must be 1 (true) or 0 (false). For more information, see [Undefined, infinite, and overflow values](#undefined-values).

AWS IoT SiteWise provides the following formula expression features that you can use to operate on strings:
+ [String literals](expression-literals.md#string-literal-definition)
+ The [index operator](expression-operators.md#index-operator-definition) (`s[index]`)
+ The [slice operator](expression-operators.md#slice-operator-definition) (`s[start:end:step]`)
+ [Comparison functions](expression-comparison-functions.md), which you can use compare strings by [lexicographic order](https://en.wikipedia.org/wiki/Lexicographic_order)
+ [String functions](expression-string-functions.md), which include the `jp` function that can parse serialized JSON objects and convert strings to numbers

## Filter data points
<a name="filter-data"></a>

You can use the [if function](expression-conditional-functions.md#if-definition) to filter out data points that don't meet a condition. The `if` function evaluates a condition and returns different values for `true` and `false` results. You can use the [none constant](expression-constants.md#none-definition) as an output for one case of an `if` function to discard the data point for that case.

**To filter out data points that match a condition**
+ Create a transform that uses the `if` function to define a condition that checks if a condition is met, and returns `none` as either the `result_if_true` or `result_if_false` value.

**Example: Filter out data points where water isn't boiling**  
Consider a scenario where you have a measurement, `temp_c`, that provides the temperature (in Celsius) of water in a machine. You can define the following transform to filter out data points where the water isn't boiling:  
+ Transform: `boiling_temps = if(gte(temp_c, 100), temp_c, none)` – Returns the temperature if it's greater than or equal to 100 degrees Celsius, otherwise returns no data point.

## Count data points that match a condition
<a name="count-filtered-data"></a>

You can use [comparison functions](expression-comparison-functions.md) and [sum()](expression-aggregation-functions.md#sum-definition) to count the number of data points for which a condition is true.

**To count data points that match a condition**

1. Create a transform that uses a comparison function to define a filter condition on another property.

1. Create a metric that sums the data points where that condition is met.

**Example: Count the number of data points where water is boiling**  
Consider a scenario where you have a measurement, `temp_c`, that provides the temperature (in Celsius) of water in a machine. You can define the following transform and metric properties to count the number of data points where the water is boiling:  
+ Transform: `is_boiling = gte(temp_c, 100)` – Returns `1` if the temperature is greater than or equal to 100 degrees Celsius, otherwise returns `0`.
+ Metric: `boiling_count = sum(is_boiling)` – Returns the number of data points where water is boiling.

## Late data in formulas
<a name="late-data"></a>

AWS IoT SiteWise supports late data ingestion of data that is up to 7 days old. When AWS IoT SiteWise receives late data, it recalculates existing values for any metric that inputs the late data in a past window. These recalculations result in data processing charges.

**Note**  
When AWS IoT SiteWise computes properties that input late data, it uses each property's current formula expression.

After AWS IoT SiteWise recalculates a past window for a metric, it replaces the previous value for that window. If you enabled notifications for that metric, AWS IoT SiteWise also emits a property value notification. This means that you can receive a new property value update notification for the same property and timestamp for which you previously received a notification. If your applications or data lakes consume property value notifications, you must update the previous value with the new value so that their data is accurate.

## Data quality in formulas
<a name="data-quality"></a>

In AWS IoT SiteWise, each data point has a quality code, which can be one of the following:
+ `GOOD` – The data isn't affected by any issues.
+ `BAD` – The data is affected by an issue such as sensor failure.
+ `UNCERTAIN` – The data is affected by an issue such as sensor inaccuracy.

AWS IoT SiteWise consumes only `GOOD` quality data when it computes transforms and metrics. AWS IoT SiteWise outputs only `GOOD` quality data for successful computations. If a computation is unsuccessful, then AWS IoT SiteWise doesn't output a data point for that computation. This can occur if a computation results in an undefined, infinite, or overflow value.

For more information about how to query data and filter by data quality, see [Query data from AWS IoT SiteWise](query-industrial-data.md).

## Undefined, infinite, and overflow values
<a name="undefined-values"></a>

Some formula expressions (such as `x / 0`, `sqrt(-1)`, or `log(0)`) calculate values that are undefined in a real number system, infinite, or outside the range supported by AWS IoT SiteWise. When an asset property's expression computes an undefined, infinite, or overflow value, AWS IoT SiteWise doesn't output a data point for that computation.

AWS IoT SiteWise also doesn't output a data point if it computes a non-numeric value as the result of a formula expression. This means that if you define a formula that computes a string, array, or the [none constant](expression-constants.md#none-definition), then AWS IoT SiteWise doesn't output a data point for that computation.

**Examples**  
Each of the following formula expressions result in a value that AWS IoT SiteWise can't represent as a number. AWS IoT SiteWise doesn't output a data point when it computes these formula expressions.  
+ `x / 0` is undefined.
+ `log(0)` is undefined.
+ `sqrt(-1)` is undefined in a real number system.
+ `"hello" + " world"` is a string.
+ `jp('{"values":[3,6,7]}', '$.values')` is an array.
+ `if(gte(temp, 300), temp, none)` is `none` when `temp` is less than `300`.