Skip to content

2.9 Sliding Aggregates

The SlidingAggregate functions perform an aggregate operation on a single input, over a window. The general construct for SLIDINGAGG functions is:

SLIDINGAGG(input, operation, window)

input — an integer or any valid timeseries source

operation — the short name for one of the operators listed below (AVG, COUNT, NUMGOOD, NUMBAD, STDDEV, VAR, MIN, MAX, SUM, DIFF)

window — any valid time input — see section 2.2

The function returns the result of the operation over the period of the window immediately preceding the current time. When trending a SLIDINGAGG function, the window is always anchored to beginning of the trend time range.

SLIDINGAGG(input, AVG, window)

Will return a timeseries of the average of the preceding hour at every point in time

The difference between the Sliding Aggregates and the Statistics functions is that the Statistics functions operate across the inputs at each point in time, whereas the Sliding Aggregates operate on a single tag over a window.

Returns an averaged value of the input over the window. This is an extremely useful function for smoothing out noisy signals. The syntax for a sliding aggregate AVG function is:

SLIDINGAGG(input, AVG, window)

Returns the count of the number of points in the window. The syntax for a sliding aggregate COUNT function is:

SLIDINGAGG(input, COUNT, window)

Returns the count of the number of points with a “bad” status in the window. The syntax for a sliding aggregate NUMBAD function is:

SLIDINGAGG(input, NUMBAD, window)

Returns the count of the number of points with a “bad” status in the window. The syntax for a sliding aggregate NUMGOOD function is:

SLIDINGAGG(input, NUMGOOD, window)

Returns the standard deviation of the data in the window. The syntax for a sliding aggregate STDDEV function is:

SLIDINGAGG(input, STDDEV, window)

Returns the variance of the data in the window. The syntax for a sliding aggregate VAR function is:

SLIDINGAGG(input, VAR, window)

Returns the minimum value of the data in the window. The syntax for a sliding aggregate MIN function is:

SLIDINGAGG(input, MIN, window)

Returns the maximum value of the data in the window. The syntax for a sliding aggregate MAX function is:

SLIDINGAGG(input, MAX, window)

Returns the sum of all the values of the data in the window. The syntax for a sliding aggregate SUM function is:

SLIDINGAGG(input, SUM, window)

Returns the difference between the last and the first values of the data in the window. The syntax for a sliding aggregate DIFF function is:

SLIDINGAGG(input, DIFF, window)

If the last value is lower than the first value, then the result is negative. This is very useful for calculating gradients.