difference() function

The difference() function computes the difference between subsequent non-null records.

Function type: Aggregate
Output data type: Float

difference(nonNegative: false, columns: ["_value"])



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

Data type: Boolean


A list of columns on which to compute the difference. Defaults to ["_value"].

Data type: Array of strings


from(bucket: "telegraf/autogen")
  |> range(start: -5m)
  |> difference()
from(bucket: "telegraf/autogen")
  |> range(start: -5m)
  |> difference(nonNegative: true)


This documentation is open source. See a typo? Please, open an issue.

Need help getting up and running? Get Support