docs-v2/content/flux/v0.x/stdlib/universe/mode.md

1.9 KiB
Raw Permalink Blame History

title description aliases menu weight flux/v0.x/tags related introduced
mode() function The `mode()` function computes the mode or value that occurs most often in a specified column in the input table.
/influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/mode/
/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/mode/
/influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/mode/
flux_0_x_ref
name parent
mode universe
102
aggregates
transformations
/{{< latest "influxdb" "v1" >}}/query_language/functions/#mode, InfluxQL MODE()
/flux/v0.x/stdlib/experimental/mode/
0.36.0

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

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.

{{% warn %}}

Empty tables

mode() drops empty tables. {{% /warn %}}

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

Parameters

column

The column to use to compute the mode. Default is "_value".

tables

Input data. Default is piped-forward data (<-).

Examples

{{% flux/sample-example-intro %}}

import "sampledata"

sampledata.int()
    |> mode()

{{% expand "View input and output" %}} {{< flex >}} {{% flex-content %}}

Input data

{{% flux/sample "int" %}}

{{% /flex-content %}} {{% flex-content %}}

Output data
tag _value
t1
tag _value
t2 19

{{% /flex-content %}} {{< /flex >}} {{% /expand %}}