Ah, ok. I understand the use case now. The challenge is conditionally applying an aggregate operation. My initial thought is to just filter out all the rows where status
is 1
and then use difference()
to show the difference between subsequent rows. The problem with this approach is that you’d end up getting the difference between the last row of a status 0
“cycle” and the first row of the next status 0
cycle.
With the current functionality available in Flux, I can’t really think of a way to this. There is a proposed feature called scan()
that would make this type of operation trivial. Here’s a link to the GitHub issue: EPIC: scan function · Issue #4671 · influxdata/flux · GitHub