# Windowing data and calculate intervals based on some _field value condition (value over 30)

I have pretty much a simple case, where i have one measurement (Temperature). I have a case, where i want to find out all separate intervals in which Temperature exceeded a value of 35°C. Is this possible using Flux language? I was able to write a query in which i am windows data by 15min and get the desired visual result. So in this case the result should be 5 separate intervals (windows), with different duration (based on temp value > 35°C). How to achieve this?

So i want the result of something of:
_start, _stop, _avg_value, _min_value, max_value

In the case which is displayed above, the result should consist out of 5 intervals (windows) - as there are cases when temperature is consistently above 35.

Any ideas how to solve that with Flux?

Thank you

Hello @Nace,
yes you can use the filters:

``````|> filter(fn: (r) => r_avg._value >= 35.0)
``````

Yes, we have tried out with filter, with a combination with window(), but this does not resolve the expected behaviour.

data = from(bucket: “sample-bucker”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “measurements”)
|> filter(fn: (r) => r[“deviceId”] == “0087”)
|> filter(fn: (r) => r[“_field”] == “Curr” and r[“_value”] > 35)
|> window(every: 15m)
data

We want to get all separated (“connected”) intervals where the value of the “Curr” field exceed 35. Now we have multiple windows of 15min length, but what we want to achieve is, to have - for the case on the screenshot attached only 4 windows with different time length, based on the field Curr and when the value is over 35. In the next steps, we want to calculate min() avg() and some other stuff for this 4 windows. So actually the question is, what is the way to group existing windows (length 15min) into new windows/frames based on some other field values and conditions.

Maybe now the question and the expected result is more clear.