Documentation

Fill null values in data

Use fill() to replace null values with:

data
    |> fill(usePrevious: true)

// OR

data
    |> fill(value: 0.0)

Fill empty windows of time

The fill() function does not fill empty windows of time. It only replaces null values in existing data. Filling empty windows of time requires time interpolation (see influxdata/flux#2428).

Fill with the previous value

To fill null values with the previous non-null value, set the usePrevious parameter to true.

Values remain null if there is no previous non-null value in the table.

data
    |> fill(usePrevious: true)

Given the following input:

_time _value
2020-01-01T00:01:00Z null
2020-01-01T00:02:00Z 0.8
2020-01-01T00:03:00Z null
2020-01-01T00:04:00Z null
2020-01-01T00:05:00Z 1.4

fill(usePrevious: true) returns:

_time _value
2020-01-01T00:01:00Z null
2020-01-01T00:02:00Z 0.8
2020-01-01T00:03:00Z 0.8
2020-01-01T00:04:00Z 0.8
2020-01-01T00:05:00Z 1.4

Fill with a specified value

To fill null values with a specified value, use the value parameter to specify the fill value. The fill value must match the data type of the column.

data
    |> fill(value: 0.0)

Given the following input:

_time _value
2020-01-01T00:01:00Z null
2020-01-01T00:02:00Z 0.8
2020-01-01T00:03:00Z null
2020-01-01T00:04:00Z null
2020-01-01T00:05:00Z 1.4

fill(value: 0.0) returns:

_time _value
2020-01-01T00:01:00Z 0.0
2020-01-01T00:02:00Z 0.8
2020-01-01T00:03:00Z 0.0
2020-01-01T00:04:00Z 0.0
2020-01-01T00:05:00Z 1.4

Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following: