Get all first occurrence of the condition from a continous series

Hi,

I have a simple series of power output, my query is very simple:

select power from head_unit

My requirement is to get all the first point’s where power > 4. Below graph will explain the issue:

I need all the points where there is a red cross.
I cannot check power = 4 as it will give me points on the opposite side of the curve as well.

Is it possible to get this value using query/subquery/flux?

Best,
Bhoomi

Hello @Bhoomi_Desai,
Sorry for missing this. Just doing some work answering unanswered questions in this topic. This answer might be too late for you, but I’m hoping the answer can help someone else. I apologize for missing your question.
You can shift the values forward with timeShift, perform a join and filter for the instances where the next value is increasing like so:

data = from(bucket: "noaa")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "average_temperature")
  |> filter(fn: (r) => r["_field"] == "degrees")
  |> filter(fn: (r) => r["location"] == "coyote_creek")
  |> aggregateWindow(every: 6h, fn: mean, createEmpty: false)
//   |> yield(name: "original")

dataShift = data
  |> timeShift(duration: 6h, columns: ["_time"])
//    |> yield(name: "timeshift")


joined = join(tables: {data:data, dataShift: dataShift}, on: ["_time", "_field", "_start", "_stop", "_measurement", "location"], method: "inner")
  |> filter(fn: (r) => r._value_data == 80.0 and r._value_dataShift > r._value_data)
  |> yield(name: "joined and first instances of data")