I want Different time to calculate

Grafana 8.2.5
Database InfluxDB

I want different time, A max, A min, B max, B min to calculate by the equation in this picture.

At least, I want to know how to get different time on time series graph.

Thank you

Are you using Flux or InfluxQL?