Date range

Ubidots allows you to build new variables from a time series based on date range data, that is, calculate mean, sum, median per hour, etc., using a synthetic variable based on your sensor inputs.

Below you can find the commonly used 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 have the following syntax:

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

Parameters
Description
Value
Mandatory

Variable

It shows the measurements of a sensor as a time series of data points that vary over time. Also known as "dots", it's identified by a variable label.

Variable label

YES

Range

The time window in wich the function will be computed.

NOTE: The selected range should be set in a way that evenly divides the next range. For example, if using minutes ("T"), whatever the number n is, it has to evenly divide an hour ("H"). Available values for minutes are: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30. Other values may render unexpected results. Same applies to other ranges.

Available data ranges:

this is a positive integer, representing 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 week

"M" : Every end of month

YES

Position

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

position ="start" or position = "end"

NO

Offset

Sets the hour at which our synthetic variable engine will begin to compute the variable, which is the number of hours after midnight. By default, it's 0 hours.

Any integer between 1 and 23

NO

Last updated