Creating Dashboard with max Value/Time in Flux

Hello,
I’m trying to create a dashboard in Grafana that outputs the maximum value including the associated date.

Example:
Time: 2023-09-12 14:00:00
Value: 396
Time: 2023-09-12 14:15:00
Value: 463
Time: 2023-09-12 14:30:00
Value: 551
Time: 2023-09-12 14:45:00
Value: 391

Then the dashboard should say the following:
551
2023-09-12 14:30:00

My data comes from Influxdb 2. Here is my query:

from(bucket: “iobroker”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “Erzeugung”)
|> filter(fn: (r) => r[“_field”] == “value”)
|> aggregateWindow(every: v.windowPeriod, fn: max, createEmpty: false)
|> yield(name: “max”)

Can anyone help me?

Thank you
Yours Tazmanischer

Welcome @tazmanischer to the Grafana forum.

With a Table visualization, perhaps something like this?

from(bucket: "iobroker")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "Erzeugung")
|> filter(fn: (r) => r["_field"] == "value")
|> aggregateWindow(every: v.windowPeriod, fn: max, createEmpty: false)
|> max()
|> keep(columns: ["_time", "_value"])  
|> group()
|> yield(name: "max")
1 Like

Oh my god… Thank you.

I realize I still have a lot to learn in Flux.

Do you know any good documentation or tutorials?

I am told this tutorial offers a good introduction to using Flux in Grafana alerts :wink:

I learned Flux through forums like this and trying stuff out.