Aggregate functions explained

Prev Next

Introduction

An aggregate function is a calculation that is performed on multiple values in a given time interval, and returns a single value. You can determine the interval by setting a time range for the dashboard.

This is important because the values are compressed when they are displayed in a widget. Presenting each individual value would give an unclear and complex picture, from which it is difficult to draw conclusions. There is usually more interest in knowing whole figures than in details. When you zoom in on the widget timeline, you'll see more individual data points.


Example

Let's say a sensor counts water consumption in liters. Within a time interval, it emits the following values:

1 1 2 0 1 0 2 3

Depending on the aggregation set, your widget will display the following value:

Aggregation

Displayed value

Statement

COUNT

8

The number of values sent in the time interval. It works on numeric values as well as on strings (text).

AVG

1.25

The average value in the time interval. It is usually used to get an overview of a situation, or when it is important to know averages.

MAX

3

The largest value it has received in the time interval. Useful if you check an upper limit, for example.

MIN

0

The smallest value in the time interval. Useful if you check a lower limit, for example.

FIRST

1

The first value received in the time interval.

LAST

3

The last value received in the time interval.

DIFF

2

The difference between the first and the last value in the time interval. This feature is useful when you are counting totals, and you want to know the increase or decrease in your values.

SUM

10

The sum of all values received in the time interval. This feature is useful when your sensor is a counter, for example, and you want to know totals.

Attention!

To know when to use SUM or DIFF, it's important to understand the way your sensor measures the value.
If you get the following values: 1 1 0 2 you can use SUM to get the total of the measured values.
If you get the following values: 1 3 6 5 the sensor will add up the measured values. You can also use DIFF to know by how much the values have changed. The calculation looks like this: 5 - 1 = 4

Charts

This is a graph with data from a single sensor, so exactly the same measurement path, but with three different aggregations.

  • The red line shows the maximum (#MAX) value.

  • The green line shows the average (#AVG) value.

  • The blue line shows the minimum (#MIN) value.

How to use aggregation in widgets

When setting up a widget, you can choose a maximum for the data points that are displayed.

Data points are the values that the sensor sends to the portal. Over time, these values are compressed for clarity. The compression of the data points is controlled by the Max Data Points setting. The higher the maximum you set, the more points will be displayed on your widget, and the less they will be compressed.

Examples

A column chart with Max Data Points set to 100:

Same graph with Max Data Points set to 20:

When compressing multiple sensor values, the value shown in the widget is determined by the aggregate function.

If you do not select aggregatie, it will default to LAST.