Non-interpolated integral

From brief experimentation, it appears that integral() uses a linear interpolation between points. Is there a method for disabling this? Essentially what I’m after is a zero-order hold so that the previous value remains constant until changed. This enables integration to be used for calculating time-weighted means for a set of irregular events.

I currently have the following workaround:

events = from(bucket: ...

shifted = events
  |> timeShift(duration: -1ns)
  |> drop(columns: ["val"])

union(tables: [events, shifted])
  |> sort(columns: ["_time"])
  |> fill(column: "val", usePrevious: true) 
  |> integral(unit: 1m, column: "val")

This works, but introduces a small amount of error due to the 1ns impulse response. It feels like there should be a builtin approach for this, but am very new to working with InfluxDB / flux and would love any advice. Thanks in advance.

@kim There currently isn’t a way to do this with integral(), but extending the integral() function with a new interpolation parameters sounds like it would be a good addition. I’d suggest creating an issue on the Flux repo.