Fill gaps in data
Use date_bin_gapfill
with interpolate
or locf
to
fill gaps of time where no data is returned.
Gap-filling SQL queries handle missing data in time series data by filling in
gaps with interpolated values or by carrying forward the last available observation.
To fill gaps in data:
Use the
date_bin_gapfill
function to window your data into time-based groups and apply an aggregate function to each window. If no data exists in a window,date_bin_gapfill
inserts a new row with the starting timestamp of the window, all columns in theGROUP BY
clause populated, and null values for the queried fields.Use either
interpolate
orlocf
to fill the inserted null values in the specified column.- interpolate: fills null values by interpolating values between non-null values.
- locf: fills null values by carrying the last observed value forward.
The expression passed to
interpolate
orlocf
must use an aggregate function.Include a
WHERE
clause that sets upper and lower time bounds. For example:
Example of filling gaps in data
The following examples use the sample data set provided in
Get started with InfluxDB tutorial
to show how to use date_bin_gapfill
and the different results of interplate
and locf
.
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.