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.

    1. from(bucket: "noaa")
    2. |> group()
    3. |> keep(columns: ["location"])
    4. |> 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.

    1. from(bucket: "noaa")
    2. |> group()
    3. |> unique(column: "location")
    4. |> count(column: "location")

Example results

location
2

queries