Documentation

InfluxQL miscellaneous functions

Use InfluxQL miscellaneous functions to perform different operations in InfluxQL queries.

fill()

Fills null field values returned from empty time windows in GROUP BY time() queries with a specified fill value.

Supported only in the GROUP BY clause.

fill(behavior)
  • Copy
  • Fill window

Arguments

  • behavior: Defines the behavior of the fill operation. If no FILL clause is included, the default behavior is fill(null).

    The following options are available:

    • numeric literal: Replaces null values with the specified numeric literal.
    • linear: Uses linear interpolation between existing values to replace null values.
    • none: Removes rows with null field values.
    • null: Keeps null values and associated timestamps.
    • previous: Replaces null values with the most recent non-null value.

Examples

The following example uses the Bitcoin price sample dataset.

SELECT
  MEAN(price)
FROM bitcoin
WHERE
  code = 'USD'
  AND time >= '2023-05-01T00:00:00Z'
  AND time < '2023-05-01T02:00:00Z'
GROUP BY
  time(30m)
  fill(0)
  • Copy
  • Fill window

name: bitcoin

timemean
2023-05-01T00:00:00Z29319.9092
2023-05-01T00:30:00Z29307.4416
2023-05-01T01:00:00Z0
2023-05-01T01:30:00Z29263.2886
SELECT
  MEAN(price)
FROM bitcoin
WHERE
  code = 'USD'
  AND time >= '2023-05-01T00:00:00Z'
  AND time < '2023-05-01T02:00:00Z'
GROUP BY
  time(30m)
  fill(linear)
  • Copy
  • Fill window

name: bitcoin

timemean
2023-05-01T00:00:00Z29319.9092
2023-05-01T00:30:00Z29307.4416
2023-05-01T01:00:00Z29285.3651
2023-05-01T01:30:00Z29263.2886
SELECT
  MEAN(price)
FROM bitcoin
WHERE
  code = 'USD'
  AND time >= '2023-05-01T00:00:00Z'
  AND time < '2023-05-01T02:00:00Z'
GROUP BY
  time(30m)
  fill(none)
  • Copy
  • Fill window

name: bitcoin

timemean
2023-05-01T00:00:00Z29319.9092
2023-05-01T00:30:00Z29307.4416
2023-05-01T01:30:00Z29263.2886
SELECT
  MEAN(price)
FROM bitcoin
WHERE
  code = 'USD'
  AND time >= '2023-05-01T00:00:00Z'
  AND time < '2023-05-01T02:00:00Z'
GROUP BY
  time(30m)
  fill(null)
  • Copy
  • Fill window

name: bitcoin

timemean
2023-05-01T00:00:00Z29319.9092
2023-05-01T00:30:00Z29307.4416
2023-05-01T01:00:00Z
2023-05-01T01:30:00Z29263.2886
SELECT
  MEAN(price)
FROM bitcoin
WHERE
  code = 'USD'
  AND time >= '2023-05-01T00:00:00Z'
  AND time < '2023-05-01T02:00:00Z'
GROUP BY
  time(30m)
  fill(previous)
  • Copy
  • Fill window

name: bitcoin

timemean
2023-05-01T00:00:00Z29319.9092
2023-05-01T00:30:00Z29307.4416
2023-05-01T01:00:00Z29307.4416
2023-05-01T01:30:00Z29263.2886

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.

Read more

InfluxDB 3 Core and Enterprise are now in Beta

InfluxDB 3 Core and Enterprise are now available for beta testing, available under MIT or Apache 2 license.

InfluxDB 3 Core is a high-speed, recent-data engine that collects and processes data in real-time, while persisting it to local disk or object storage. InfluxDB 3 Enterprise is a commercial product that builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries. A free tier of InfluxDB 3 Enterprise will also be available for at-home, non-commercial use for hobbyists to get the full historical time series database set of capabilities.

For more information, check out: