A sampled calculation uses aggregated values of one or more data references as input and runs the calculation script to output a single value for each time interval processed.

Sampled calculation settings

Time interval

  • The time interval at which the calculation script runs and thus outputs a value.
  • For a seconds level time interval, the seconds fraction of the timestamp of a result will be a multiple of the time interval.
    For example, a time interval of 5 seconds will result in a timestamp with a seconds fraction being a multiple of 5 seconds starting from 0 seconds (0, 5, 10, .. seconds).
  • The time interval is the same for all given input data references.
  • Subsequent time intervals do not overlap. The start time is always inclusive to the interval, and the end time is always exclusive of the interval.
    For example, subsequent calculations use the intervals [t1, t2[, [t2,t3[, [t3,t4[, ...
  • The result of the calculation is written at the timestamp of the beginning of the interval.
    For example, the result of a calculation running in the interval [t1, t2[ will write its result at timestamp t1.

Interval offset

  • A seconds level offset is added to each minute before multiples of the time interval are taken into account.
    For example, a time offset of 2 seconds with an interval of 5s, will result in a timestamp with a seconds fraction starting 2 seconds after the minute (2, 7, 12, .. seconds) instead of on the minute (0, 5, 10, .. seconds).

Evaluate Insufficient Data

  • If enabled the script will run regardless of the availability of data for the input data references.
  • If disabled the script will not be run on points where there are one or more values missing for the input data references. The calculation will write an error point with status `BadInsufficientData'

Input data reference(s)

The selection of data references is similar to the Raw calculation input data reference, with an additional settings for aggregation type and default value.

  • Alias: An alias for the input data reference which must be used in the script to address the input data references. Aliases are automatically generated by the system in alphabetical order and must be preceded by an underscore (_). The preceding underscore is automatically provided and thus fixed, yet the name of the alias can be changed as desired.

  • Data reference type: The type of the input data reference. The type can be either Measurement or Asset property.

  • Data reference: The name of the data reference. The reference is selected by searching in all existing references of the chosen type over all databases. Note that there is no check on the health or configuration of the reference during selection.

  • Aggregation type: at each time interval, the aggregation function is applied to the input data reference. The aggregation type may differ between multiple input data references. The available aggregation types depend on the datatype of the data reference. More info on the aggregation types can be found below .

  • Default value: only available if Evaluate Insufficient Data is enabled. The default value will be used if there is no data for the input data reference.

Script

  • The script outputs a new value starting from the aggregated values of the input data reference(s).
  • Read further about setting up a calculation script .

Aggregation types

An overview of the possible aggregation types is listed below. Note that, depending on the datatype of the according input data reference, the aggregated value will be retrieved from a different field of the data reference. For more information about the time series data fields, checkout the influx storage model .

  • a number input data reference -> uses the value field
  • a string input data reference -> uses the value_str field
  • a boolean input data reference -> uses the value_bool field
  • an array input data reference -> uses the value field (which records the length of the array)
An input data reference having an array datatype returns an aggregated value of the array length.

More info for influx v1.x

More info for influx v2.x

count

Returns the number of non-null fields values.

integral

Returns the area under the curve for subsequent field values.

mean

Returns the arithmetic mean (average) of field values.

median

Returns the middle value from a sorted list of field values.

mode

Returns the most frequent value in a list of field values.

spread

Returns the difference between the minimum and maximum field values.

stddev

Returns the standard deviation of field values.

sum

Returns the sum of field values.

first

Returns the field value with the oldest timestamp.

last

Returns the field value with the most recent timestamp.

max

Returns the greatest field value.

min

Returns the lowest field value.

Performance

Picking a shorter time interval for a sampled calculation will cause a calculation to be triggered more frequently and thus increase the load on the active machine.

A script execution times out, if it does not complete in 10 seconds.