docs-v2/content/v2.0/reference/flux/functions/built-in/transformations/fill.md

1.7 KiB

title description aliases menu weight
fill() function The `fill()` function replaces all null values in an input stream and replace them with a non-null value.
/v2.0/reference/flux/functions/transformations/fill
v2_0_ref
name parent
fill built-in-transformations
401

The fill() function replaces all null values in an input stream with a non-null value. The output stream is the same as the input stream with all null values replaced in the specified column.

Function type: Transformation

fill(column: "_value", value: 0.0)

// OR

fill(column: "_value", usePrevious: true)

Parameters

column

The column in which to replace null values. Defaults to "_value".

Data type: String

value

The constant value to use in place of nulls. The value type must match the value type of the column.

Data type: Boolean | Integer | UInteger | Float | String | Time | Duration

usePrevious

When true, assigns the value set in the previous non-null row.

{{% note %}} Cannot be used with value. {{% /note %}}

Data type: Boolean

Examples

Fill null values with a specified non-null value
from(bucket: "example-bucket")
  |> range(start: -1h)
  |> filter(fn: (r) =>
    r._measurement == "cpu" and
    r.cpu == "cpu-total"
  )
  |> fill(value: 0.0)
Fill null values with the previous non-null value
from(bucket: "example-bucket")
  |> range(start: -1h)
  |> filter(fn: (r) =>
    r._measurement == "cpu" and
    r.cpu == "cpu-total"
  )
  |> fill(usePrevious: true)

FILL