Follow

# Aggregation Methods

When retrieving detailed data from tag based time series data sources (i.e. Historians), Flow makes use of a number of aggregation methods to standardize how this data is summarized and stored in the Flow System. In a previous lab, you created a measure that calculated the average value of the Boiler Temperature for each hour. The aggregation method you used was “Average”, but there are a few others you should know about. Let’s discuss each of these aggregation methods in detail.

Let’s use a standard set of detailed data, and then apply each of the aggregation methods to the same data set. Here is our data set …

 Point Timestamp Raw Value 1 05:55:03 1.6 2 06:03:23 2.3 3 06:07:30 2.5 4 06:10:22 3 5 06:15:52 2.1 6 06:20:40 1.9 7 06:25:13 2.5 8 06:29:44 2.3 9 06:35:14 1.6 10 06:41:14 1.8 11 06:46:03 2.3 12 06:52:35 2.9 13 06:55:26 2.2 14 07:05:40 1.4

Which, graphically, looks like this if we plot the points. The shaded area is the time period we are interested in for our summary information. Flow uses a “Stair Step” interpolation between each point, like this … Because the first point in our data set is outside of our summary time period, Flow uses it as a “boundary” value with a timestamp of exactly 06:00:00.

 The Wonderware Historian Data Source type does allow the option to use a different Interpolation between points, however, Flow will default to using “Stair Step”.

Sum

When using the “Sum” aggregation method, Flow will calculate the sum of points 2 to 13. It will exclude the “boundary” value, since point 1 before the “boundary”, would have been used in the previous time period’s calculation.

Average

When using the “Average” aggregation method, Flow calculates a time weighted average. The “boundary” value is included in the calculation.

Minimum

When using the “Minimum” aggregation method, Flow determines the minimum value of all the points within the time period, including the “boundary” value.

Maximum

When using the “Maximum” aggregation method, Flow determines the maximum value of all the points within the time period, including the “boundary” value.

Range

When using the “Range” aggregation method, Flow determines the maximum and the minimum values of all the points within the time period, including the “boundary” value, and then returns the difference between the maximum and the minimum.

First

When using the “First” aggregation method, Flow will return the “boundary” value.

Last

When using the “Last” aggregation method, Flow will return the value of the last point before the end of the time period. If a point falls exactly on the end of the time period (i.e. 07:00:00), it will be excluded from the evaluation.

Delta

When using the “Delta” aggregation method, Flow will sum the difference between each consecutive point, including the “boundary” point.

Count

When using the “Count” aggregation method, Flow will return the number of points within the time period, excluding the “boundary” point.

Time in State

When configuring Flow to return a “Time in State” summary, you will need to specify the “State” setting and condition. Flow will return the total duration (in milliseconds) that the “Stair Step” interpolation evaluates to the specified “State” setting and condition. For example, in the above scenario, if the “State” setting is specified as “=” 1.6, Flow will sum the duration between the “boundary” point and point 2, and the duration between point 9 and point 10.

Variance

When using the “Variance” aggregation method, Flow will calculate the statistical population variance for all the data points within the time period, including the “boundary” point.

Standard Deviation

When using the “Standard Deviation” aggregation method, Flow will calculate the statistical population standard deviation for all the data points within the time period, including the “boundary” point.

Counter (Totalizers)

The “Counter” aggregation method is applicable to totalizers only. For this aggregation type, let’s look at a different set of data:

 Point Timestamp Raw Value 1 05:55:03 1 2 06:03:23 1.7 3 06:07:30 1.9 4 06:10:22 2 5 06:15:52 2.3 6 06:20:40 2.5 7 06:25:13 2.8 8 06:29:44 3.2 9 06:35:14 0 10 06:41:14 0.2 11 06:46:03 0.4 12 06:52:35 1 13 06:55:26 1.4 14 07:05:40 2.3

When we plot this “totalizer’s” points, and then apply the “Stair Step” interpolation, we get the following result. Notice the totalizer’s reset point. Flow will sum the difference between each consecutive point, including the “boundary” value, until it detects a negative change. If the negative change is greater than the “Deadband” setting, Flow interprets this as a totalizer reset, and then continues summing the difference between following consecutive points.

 The Flow “Counter” aggregation method will handle multiple totalizer resets in any single time period.

Counter Rollover

A totalizer is often configured in the instrument or in its controller to always reset at a specific value. This specific value is known as the “Rollover” value.

Due to the nature of slight delays in data historization, it is possible that the raw data will not include a point at exactly the rollover value, but rather a value slightly before, and slightly lower than the rollover value.

For example, if this totalizer reset at exactly 3.5, Flow would “miss” 0.3 counts (3.5 rollover – 3.2 point 8). Fortunately, Flow allows the configuration of a “Rollover” setting. When calculating the “Counter” aggregation for a time period, Flow will use this “Rollover” setting to include the “missed” counts. Custom Expression

Some Data Source types provide the ability to configure a “Custom Expression”, rather than using one of the standard aggregation methods.  Custom expressions allow for the querying of more than one tag from the data source.

The results of the query are transposed into a “data” object that returns a set of columns containing the tag values and qualities.  The custom expression uses Microsoft.NET’s C# syntax.  A single “Result” object must be returned by the custom expression. The custom expression must be validated before being saved.

Custom expressions can be used for custom calculations (e.g. integrated one tag by another), lookups (e.g. convert the returned values based on a lookup table), etc.