group() function

The group() function groups records based on their values for specific columns. It produces tables with new group keys based on provided properties. Specify an empty array of columns to ungroup data or merge all input tables into a single output table.

Function type: Transformation

group(columns: ["host", "_measurement"], mode:"by")

// OR

group(columns: ["_time"], mode:"except")

// OR


Group does not guarantee sort order

group() does not guarantee the sort order of output records. To ensure data is sorted correctly, use sort() after group().

  |> group()
  |> sort(columns: ["_time"])



List of columns to use in the grouping operation. Defaults to [].

Data type: Array of strings


The mode used to group columns.

Data type: String

The following options are available:

  • by
  • except

Defaults to "by".


Groups records by columns defined in the columns parameter.


Groups records by all columns except those defined in the columns parameter.


Group by host and measurement
from(bucket: "example-bucket")
  |> range(start: -30m)
  |> group(columns: ["host", "_measurement"])
Group by everything except time
from(bucket: "example-bucket")
  |> range(start: -30m)
  |> group(columns: ["_time"], mode: "except")
Ungroup data
// Merge all tables into a single table
from(bucket: "example-bucket")
  |> range(start: -30m)
  |> group()

Set your InfluxDB URL

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.