Group by using flux

Greetings

Given the following sample influx data

how can I get data back with count grouped by _value
so that is returns

K,3
A,22

I want to chart this in a bar chart

This is rather easy:

data
  |>group(columns: ["_value"])
  |>count(column: "_field")
  |>map(fn: (r) => ({r with _field: r._value, _value: r._field}))
1 Like