derivative() function

The derivative() function computes the rate of change per unit of time between subsequent non-null records. It assumes rows are ordered by the _time column. The output table schema is the same as the input table.

*Function type: Transformation
**
Output data type:* Float

  1. derivative(
  2. unit: 1s,
  3. nonNegative: true,
  4. columns: ["_value"],
  5. timeSrc: "_time"
  6. )

Parameters

unit

The time duration used when creating the derivative. Defaults to 1s.

*Data type: Duration*

nonNegative

Indicates if the derivative is allowed to be negative. Default is true. When true, if a value is less than the previous value, it is assumed the previous value should have been a zero.

*Data type: Boolean*

columns

The columns to use to compute the derivative. Defaults to ["_value"].

*Data type: String*

timeSrc

The column containing time values. Defaults to "_time".

*Data type: String*

Output tables

For each input table with n rows, derivative() outputs a table with n - 1 rows.

Examples

  1. from(bucket: "example-bucket")
  2. |> range(start: -5m)
  3. |> derivative(unit: 1s, nonNegative: true)

Related articles