Documentation

integral() function

The integral() function computes the area under the curve per unit of time of subsequent non-null records. integral() requires _start and _stop columns that are part of the group key. The curve is defined using _time as the domain and record values as the range. integral() is an aggregate function.

Output data type: Float

integral(
    unit: 10s,
    column: "_value",
    timeColumn: "_time",
    interpolate: "",
)

Parameters

unit

(Required) Time duration used when computing the integral.

column

Column on which to operate. Defaults to "_value".

timeColumn

Column that contains time values to use in the operation. Defaults to "_time".

interpolate

Type of interpolation to use. Defaults to "".

Use one of the following interpolation options:

  • empty string for no interpolation
  • linear

tables

Input data. Default is piped-forward data (<-).

Examples

The following examples use data provided by the sampledata package to show how integral() transforms data.

Calculate the integral

import "sampledata"

sampledata.int()
    |> range(start: sampledata.start, stop: sampledata.stop)
    |> integral(unit:10s)

View input and output

Calculate the integral with linear interpolation

import "sampledata"

sampledata.int(includeNull: true)
    |> range(start: sampledata.start, stop: sampledata.stop)
    |> integral(unit:10s, interpolate: "linear")

View input and output


Was this page helpful?

Thank you for your feedback!


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.