Aggregate

The aggregate condition exposes an input for each aggregate computed on the source. As an example, if {{Connection.opc.tag}} is an input, the aggregate condition exposes {{Condition.MyAggregate.opc_tag_<aggregate>}} as an input. The aggregate condition only stores data changes, and aggregates are computed at the time of the read.

Numerical aggregates (AVG, MIN, MAX, DELTA) are not supported on non-numeric types like strings or arrays. If the aggregate source is a complex object, the numerical aggregate is applied to each numerical value in the complex object.

Settings

Scan Interval

The rate at which the sources are scanned and stored.

Storage Interval

How long data is retained. Data older than the storage interval is discarded. It’s common to set the storage interval to longer than the window interval. This way the window interval can expand, and still be valid if the stored data is still available. As an example, you may want to store data for two days, and change the window to get the count of yesterday’s shift totals. The storage interval should never be less than the window interval. In this case the window will always be missing data.

Type

The type of windowing the aggregate supports. See window types below.

Enabled

When disabled, the aggregate no longer polls the sources for new data. Existing data remains in the aggregate storage and can be read.

Window Types

Sliding

Sliding window includes data from the time of the read, minus the interval time. As an example, a sliding window with a window interval of 10 minutes calculates an average for the last 10 minutes of data. Data older than 10 minutes is ignored. The Window Interval controls the length of the sliding window.

Fixed

Fixed window sets the explicit start and stop time of the window. Start time should always be older than the stop time, and they can be fixed times or dynamic references to other inputs. Fixed window calculates the aggregate using data between the start and stop times.

  • Start Window: The absolute time of the start of the window. Accepts a static UTC ISO8601 (ex. 2022-03-29T20:59:45Z) or epoch in milliseconds (ex. 1648587633385) format. Also accepts a reference to an input that provides the time format. The start window should be older than the stop window

  • Stop Window: The absolute time of the end of the window. Accepts the same as the Start Window, but the time should be newer. If the stop time is in the future, the stop time is set to the current time of the read until the stop time is reached.

Supported Aggregates

RAW

Returns an array of the raw data collected for the source over the window. The data includes a time and value attribute, allowing for custom expressions/calculations in instances via the expression engine. If there is no data for the window, an empty array is returned. Values can be complex or simple data types.

COUNT

Returns the number of values for the source in the time window. Only data changes are included. If there are no data changes for the window the count returns 0.

AVG

Returns the time weighted average of the value over the time window. This includes the value at the start of the window and the value at the end. The calculation is as follows. AVG = (V1 * Tv1/Ttotal) + (V2 * Tv2/Ttotal) ...

Note that V1 is the value at the start of the window. Tv1 is how long the value was V1. Ttotal is the total window length. If there is no data for the window, the read returns good quality no data.

MIN

Returns the minimum value over the time window.

Note this includes the value at the start of the window, so if the value changed but was never lower than the value at the start of the window, the value at the start is reported. |

MAX

If there is no data for the window, the read returns good quality no data. Returns the maximum value over the time window. Like MIN, this includes the value at the start of the window. If there is no data, the read returns good quality no data.

DELTA

Returns the delta of the most recent value versus the oldest value in the window. This includes the value at the start of the window. If there are no data changes for the window, DELTA returns 0.

If there is no data for the window, the read returns good quality no data.