Documentation

Find and count unique values

These examples use NOAA water sample data.

The following examples identify and count unique locations that data was collected from.

Find unique values

This query:

  • Uses group() to ungroup data and return results in a single table.
  • Uses keep() and unique() to return unique values in the specified column.
from(bucket: "noaa")
  |> range(start: -30d)
  |> group()
  |> keep(columns: ["location"])
  |> unique(column: "location")

Example results

location
coyote_creek
santa_monica

Count unique values

This query:

  • Uses group() to ungroup data and return results in a single table.
  • Uses keep(), unique(), and then count() to count the number of unique values.
from(bucket: "noaa")
  |> group()
  |> unique(column: "location")
  |> count(column: "location")

Example results

location
2

Set your InfluxDB URL

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.