mode() function

The mode() function computes the mode or value that occurs most often in a specified column in the input table.

*Function type: Aggregate*

  1. mode(column: "_value")

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, mode() returns null.

Empty tables

mode() drops empty tables.

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

Parameters

column

The column to use to compute the mode. Defaults to "_value".

*Data type: String*

Examples

Return the mode of windowed data
  1. from(bucket: "example-bucket")
  2. |> filter(fn: (r) =>
  3. r._measurement == "errors" and
  4. r._field == "count_per_minute"
  5. )
  6. |> range(start:-12h)
  7. |> window(every:10m)
  8. |> mode()

Related articles