Fill gaps in data
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:
date_bin_gapfillfunction 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_gapfillinserts a new row with the starting timestamp of the window, all columns in the
GROUP BYclause populated, and null values for the queried fields.
locfto 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
locfmust use an aggregate function.
WHEREclause 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
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.