How to get maxValue and it`s time

how to get maxValue and it`s time in influxdb:2.4

Hi @huanhuangongzi

How about something like this?

from(bucket: "your-bucket")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "your-measurement")
  |> filter(fn: (r) => r["your Fields or tags"] == "tag1") 
...
  |> aggregateWindow(every: v.windowPeriod, fn: max, createEmpty: false)
  |> max()
  |> keep(columns: ["_time", "tag1", "_value"])  
  |> group()
  |> yield(name: "max")

thanks for your reply,but if I want to get mean,max,maxTime,min,minTime,what can i do