I have a production data and I am trying to filter the data based on time because I need data for each shift. I have written my query as below:
import "experimental/date/boundaries"
thisWeek = boundaries.week(start_sunday: true,)
from(bucket: "production")
|> range(start: thisWeek.start, stop: thisWeek.stop)
|> filter(fn: (r) => r._measurement == "productioncounters" and r._field == "counter" and r.line == "2L")
|> aggregateWindow(every: 5m, fn: last, createEmpty: false)
|> max()
|> group()
|> keep(columns:["_time", "_value", "sap"])
|> sort(columns: ["_time"])
This gives me the table
When I add hour selection in the query as below
import "experimental/date/boundaries"
thisWeek = boundaries.week(start_sunday: true,)
from(bucket: "production")
|> range(start: thisWeek.start, stop: thisWeek.stop)
|> filter(fn: (r) => r._measurement == "productioncounters" and r._field == "counter" and r.line == "2L")
|> aggregateWindow(every: 5m, fn: last, createEmpty: false)
|> max()
|> group()
|> keep(columns:["_time", "_value", "sap"])
|> sort(columns: ["_time"])
|> hourSelection(start: 7, stop: 15, timeColumn: "_time")
The output is
This is not working as I expected, What I want is for each sap during that particular shift( the slected hours), I need the maximum value and add them to find the total produced units during that shift . can someone help me with this.