experimental.mode() function

The experimental.mode() function is subject to change at any time. By using this function, you accept the risks of experimental functions.

The experimental.mode() function computes the mode or value that occurs most often in the _value column in each input table.

Function type: Aggregate

import "experimental"


If there are multiple modes, it returns all of them in a sorted table. Mode only considers non-null values. If there is no mode, experimental.mode() returns null.

Empty tables

experimental.mode() drops empty tables.

Supported data types
  • String
  • Float
  • Integer
  • UInteger
  • Boolean
  • Time


Return the mode of windowed data
import "experimental"

from(bucket: "example-bucket")
  |> filter(fn: (r) =>
    r._measurement == "example-measurement" and
    r._field == "example-field"
  |> range(start:-12h)
  |> window(every:10m)
  |> experimental.mode()

Set your InfluxDB URL

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.