Flux query to find max-min for past 45min data

I have data each having a 15 min interval. That is:

13:00:00 - 12
13:15:00 - 14
13:30:00 - 16
13:45:00 - 18
14:00:00 - 20

I wanted to calculate max - min for past 45 min. That is value should be 20 - 14 = 6 for timestamp 14:00:00. Can anybody suggest me how should i work this out. I wanted to this operation for every hour. I am using window(every:1h,period:45m) but its not showing me the values i want. I tried other combinations as well with offset, but not able to achieve the result.

Hi, take a look at the spread() function: spread() function | InfluxDB Cloud Documentation

1 Like