Group by every hour of the day

Hi,

Can you try using date.hour() to add another column to every row of your dataset and then group by that column to get mean() for every hour?

Example:

import "date"
from(bucket: "mybucket")
	|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "measurement")
  |> filter(fn: (r) => r["_field"] == "field")
  |> map(fn: (r) => ({ r with hour: date.hour(t: r._time) }))  
  |> group(columns: ["hour"], mode:"by")
  |> mean(column: "_value")  

Hopefully this is what you are looking for. Let us know if this does not work.

Regards
Balaji

1 Like