---
title: experimental.integral() function
description: experimental.integral() computes the area under the curve per unit of time of subsequent non-null records.
url: https://docs.influxdata.com/flux/v0/stdlib/experimental/integral/
estimated_tokens: 2938
product: Flux
version: v0
---

# experimental.integral() function

-   Flux 0.106.0+
-   View InfluxDB support

`experimental.integral()` is [subject to change at any time](/flux/v0/stdlib/experimental/#experimental-packages-are-subject-to-change).

`experimental.integral()` computes the area under the curve per unit of time of subsequent non-null records.

The curve is defined using `_time` as the domain and record values as the range.

Input tables must have `_start`, \_stop`,` \_time`, and` \_value`columns.`\_start`and`\_stop\` must be part of the group key.

##### Function type signature

```js
(<-tables: stream[{A with _value: B, _time: time}], ?interpolate: string, ?unit: duration) => stream[{A with _value: B}]
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### unit

Time duration used to compute the integral.

### interpolate

Type of interpolation to use. Default is `""` (no interpolation).

Use one of the following interpolation options:

-   empty string (`""`) for no interpolation
-   linear

### tables

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

## Examples

-   [Calculate the integral](#calculate-the-integral)
-   [Calculate the integral with linear interpolation](#calculate-the-integral-with-linear-interpolation)

### Calculate the integral

```js
import "experimental"
import "sampledata"

data =
    sampledata.int()
        |> range(start: sampledata.start, stop: sampledata.stop)

data
    |> experimental.integral(unit: 20s)
```

[](#view-example-input-and-output)

View example input and output

#### Input data

| *_start | *_stop | _time | _value | *tag |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 |

| *_start | *_stop | _time | _value | *tag |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 |

#### Output data

| *_start | *_stop | *tag | _value |
| --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 25 |

| *_start | *_stop | *tag | _value |
| --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 21.5 |

### Calculate the integral with linear interpolation

```js
import "experimental"
import "sampledata"

data =
    sampledata.int()
        |> range(start: sampledata.start, stop: sampledata.stop)

data
    |> experimental.integral(unit: 20s, interpolate: "linear")
```

[](#view-example-input-and-output)

View example input and output

#### Input data

| *_start | *_stop | _time | _value | *tag |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 |

| *_start | *_stop | _time | _value | *tag |
| --- | --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 |

#### Output data

| *_start | *_stop | *tag | _value |
| --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 24.25 |

| *_start | *_stop | *tag | _value |
| --- | --- | --- | --- |
| 2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 19 |

#### Related

-   [InfluxQL – INTEGRAL()](/influxdb/v1/query_language/functions/#integral)
-   [integral() function](/flux/v0/stdlib/universe/integral/)

[transformations](/flux/v0/tags/transformations/) [aggregates](/flux/v0/tags/aggregates/)
