Filter out rows based on the row directly before and after that

Hi,

let’s say I have the following values stored:

0
120.50
124.90
124.40
0         <-- Should be removed
119.0
187.99
-1.54     <-- Should be removed
122.54
0

I want to filter out all rows with a value that is <= 0 that are also between rows with a value > 0. So in this case I would want the following result:

0
120.50
124.90
124.40
119.0
187.99
122.54
0

So if there is a row with a value of <=0 and the rows that comes directly before AND after that row are > 0, the row that is 0 should be removed.

I would appreciate any help.

Thanks in advance

I don’t think it is possible, especially due to the check for the next element.

Thanks for the reply, but I would be very surprised if this is actually impossible, given how powerful flux is.

Sorry for pinging you @Anaisdg , but could you please take a look at this? I would highly appreciate it.

Thanks and best regards

I’m curious as well. But in the documentation I cannot see any instruction/keyword that “navigates” or “extracts” values from a sequence; difference is the only one, but it is of course applicable only to read the previous element, not the next.

EDIT: There’s an (unanswered) exception here, but it seems to apply to time series, which your example is not (or you didn’t mention the _time column at least).

Yeah, I looked through the docs too and could not find something specifically for this. But I thought that there might be a way to do this via joining or something like this, even though I am not sure how good this would be performance wise (if possible at all)

// Edit: Sorry, I did not mention this because I assumed that this is always the case, because InfluxDB is a time series database. So yes, there is indeed a timestamp available.

Thanks for the link, I will try if I get something to work with the pivot example