Date range

Ubidots lets you build new variables from time-series data over a date range. For example, you can calculate the mean, sum, or median per hour using a synthetic variable based on your sensor inputs.

Below are the most common date range functions.

Function
Description

max(x,range)max(x, range)

Returns the maximum value of the variable x in the specified date range.

min(x,range)min(x, range)

Returns the minimum value of the variable x in the specified date range.

mean(x,range)mean(x, range)

Returns the mean value of the variable x in the specified date range.

std(x,range)std(x, range)

Returns the standard deviation of the variable x in the specified date range.

count(x,range)count(x, range)

Returns the number of dots stored in the variable x for the specified date range.

last(x,range)last(x, range)

Returns the last value of the time-series variable x in the specified date range.

first(x,range)first(x, range)

Returns the first value of the time-series variable x in the specified date range.

sum(x,range)sum(x, range)

Returns the sum of the dots stored in the variable x in the specified date range.

Date range functions use the following syntax:

aggregation_method(<variable>, <range>, <position>, <offset>)

Parameters
Description
Value
Mandatory

Variable

Represents the measurements of a sensor as a time seriesarrow-up-right of data points that vary over time. Also known as "dots"arrow-up-right, it is identified by a variable label.

Variable label

YES

Range

The time window in which the function is computed.

Note: Set the selected range so it evenly divides the next range. For example, if you use minutes ("T"), the number n must evenly divide an hour ("H"). Available minute values are 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, and 30. Other values may produce unexpected results. The same applies to other ranges.

Available data ranges:

This is a positive integer that represents the number of observations used for each window, or a time range specified as follows:

"nT": Every n minutes

"nH": Every n hours

"nD": Every n days

"W": Every end of the week

"M": Every end of the month

YES

Position

Indicates whether the output value is timestamped at the start or at the end of the time series.

position = "start" or position = "end"

NO

Offset

Sets the hour at which the synthetic variable engine starts computing the variable. This value represents the number of hours after midnight. By default, it is 0.

Any integer between 1 and 23

NO

Last updated

Was this helpful?