Get timestamp info of max daily aggregate value

Hello,

I’m using solar panel, I will need to identify for each day, when max production value is.

→ I would like to get the timestamp and max value of daily aggregate

Basic query well provides the max value but I do not know when this max value was produced

For exemple : Today exemple 356 at 1:21pm

from(bucket: “Solar”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “Total Power”)
|> aggregateWindow(every: 1d, fn: max, createEmpty: false)

the result of course provides the daily max value but not the timestamp when max value occured

@Franck_Bellot For your use case, you’ll want to use window() instead of aggregateWindow(). aggregateWindow() applies a new timestamp to the aggregate value using one of the window boundaries. Try this:

from(bucket: "Solar")
    |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
    |> filter(fn: (r) => r["_measurement"] == "Total Power")
    |> window(every: 1d)
    |> max()
    |> window(every: inf)

window(every: 1d) applies the daily windows. window(every: inf) removes the time-based grouping.

2 Likes

Very nice @scott

I was going to suggest this slightly different approach that I created in Grafana for a similar need (i.e. daily max table showing Date & Time and Peak Value).