Rollup and aggregation

Rollup and aggregation are features the framework uses to combine data for meaningful analysis. A rollup combines multiple adjacent rows of historical data into a single row. Aggregation applies to any request for individual data by tag, such as hs:power or an algorithm where multiple data sources are found and processed. Trend requests may find multiple data sources, each with histories and the aggregation function combines those historical values as well. Rollups and aggregation control how an algorithm queries the database for input data.

A rollup uses a function (sum, average, etc.) to combine historical data. It allows you to view dissimilar histories at common intervals. For example, if one point samples data at five-minute intervals, and another samples at 10-minute intervals, you can use rollup to calculate and compare their values at, 10-minute intervals.

An aggregation uses a function (sum, average, etc.) to combine multiple data source values into a single value. If not explicitly configured, the framework uses the first function for both rollup and aggregation.

Both features share the same set of functions

The framework tends to convert primitive data types in the background if necessary. For example, using an And function for aggregation of numeric points returns a false (0) if any numeric value is <=0. The And, Or functions work on numeric and enum (ordinal) values. The Math functions also work on Boolean values using 0 for false and 1 for true.

Function Description
And Logical and.
Avg Calculates the sum divided by the count.
Count Returns the number of values.
First Returns the initial value in the set.
Last Returns the final value in the set.
Load Factor Returns the average value divided by peak (Max) value.
Max For numerics, this is the greatest value. For Booleans, false = 0 and true = 1. For enums, this returns the greatest ordinal.
Median Returns the value in the middle of a sorted combination—the number that separates the higher half from the lower half.
Mean Returns the arithmetic mean (average) of the values in the data source(s).
Min For numerics, this is the smallest value. For Booleans, false = 0 and true = 1. For enums, this returns the smallest ordinal.
Mode Returns the statistically most frequently occurring number in the combination.
Or Logical or.
Std Dev Returns the standard deviation of the values in the combination.
Sum Adds all values together.

When the difference between two values matters

Some of the functions used by aggregation and rollup may not make sense for certain values. For example, the sum of KWh for a group of points yields the total energy consumed; however, the average of those same points yields a meaningless number. In another example, summing air temperature readings may not yield a useful number. You may be more interested in the delta (change) that occurs between the historical values. To have the system calculate this value, make sure data source is tagged with the hs:hisTotalized marker tag and the request totalize property is false.

Best practice

As you configure the visualization of values and trends, experiment with the rollup and aggregation properties on the binding. If you get a result you do not expect, consider the settings for these properties.