Behavior of taking averages with irregular data

Hi,

Brand new user here and I’m trying to understand the behavior with irregularly spaced data. I tried searching but didn’t get any hits.

Let’s say I have irregularly spaced data. I may have a burst of 1s data, but then may not get data for an hour. All data is properly timestamped from the source.

I would like to query for 15 minutes averages, for example: 12:00, 12:15, 12:30, 12:45, etc. If my query start/end time fall in a period where there is no data, what’s would the query return?

My desired behavior is to assume the last value prior to the start time is valid and this value is used for the averaging (thus returned as this last value would be the average). Is this possible?

The createEmpty parameter of aggregateWindow() can be used to control this behavior. The default is true so if there is no data in a window, a row is still created (with _value being null).
You can combine this with fill(column: "_value", usePrevious: true) to replace the empty row values with the corresponding previous value.

Note that this works for individual windows, but not for the whole query. So if you only query for 1 hour, and no data is available for the full hour, it will not fill-in data from the previous hour.

Reference: