covariance() function

The covariance() function computes the covariance between two columns.

Function type: Transformation
Output data type: Float

covariance(columns: ["column_x", "column_y"], pearsonr: false, valueDst: "_value")



(Required) A list of two columns on which to operate.

Data type: Array of strings


Indicates whether the result should be normalized to be the Pearson R coefficient.

Data type: Boolean


The column into which the result will be placed. Defaults to "_value".

Data type: String


from(bucket: "example-bucket")
  |> range(start:-5m)  
  |> map(fn: (r) => ({r with x: r._value, y: r._value * r._value / 2}))
  |> covariance(columns: ["x", "y"])

Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: