Documentation

Find median values

This page documents an earlier version of InfluxDB OSS. InfluxDB 3 Core is the latest stable version.

Use the median() function to return a value representing the 0.5 quantile (50th percentile) or median of input data.

Select a method for calculating the median

Select one of the following methods to calculate the median:

estimate_tdigest

(Default) An aggregate method that uses a t-digest data structure to compute an accurate 0.5 quantile estimate on large data sources. Output tables consist of a single row containing the calculated median.

Given the following input table:

_time_value
2020-01-01T00:01:00Z1.0
2020-01-01T00:02:00Z1.0
2020-01-01T00:03:00Z2.0
2020-01-01T00:04:00Z3.0

estimate_tdigest returns:

_value
1.5

exact_mean

An aggregate method that takes the average of the two points closest to the 0.5 quantile value. Output tables consist of a single row containing the calculated median.

Given the following input table:

_time_value
2020-01-01T00:01:00Z1.0
2020-01-01T00:02:00Z1.0
2020-01-01T00:03:00Z2.0
2020-01-01T00:04:00Z3.0

exact_mean returns:

_value
1.5

exact_selector

A selector method that returns the data point for which at least 50% of points are less than. Output tables consist of a single row containing the calculated median.

Given the following input table:

_time_value
2020-01-01T00:01:00Z1.0
2020-01-01T00:02:00Z1.0
2020-01-01T00:03:00Z2.0
2020-01-01T00:04:00Z3.0

exact_selector returns:

_time_value
2020-01-01T00:02:00Z1.0

The examples below use the example data variable.

Find the value that represents the median

Use the default method, "estimate_tdigest", to return all rows in a table that contain values in the 50th percentile of data in the table.

data
    |> median()

Find the average of values closest to the median

Use the exact_mean method to return a single row per input table containing the average of the two values closest to the mathematical median of data in the table.

data
    |> median(method: "exact_mean")

Find the point with the median value

Use the exact_selector method to return a single row per input table containing the value that 50% of values in the table are less than.

data
    |> median(method: "exact_selector")

Use median() with aggregateWindow()

aggregateWindow() segments data into windows of time, aggregates data in each window into a single point, and then removes the time-based segmentation. It is primarily used to downsample data.

To specify the median calculation method in aggregateWindow(), use the full function syntax:

data
  |> aggregateWindow(
    every: 5m,
    fn: (tables=<-, column) => tables |> median(method: "exact_selector"),
  )

Was this page helpful?

Thank you for your feedback!


New in InfluxDB 3.5

Key enhancements in InfluxDB 3.5 and the InfluxDB 3 Explorer 1.3.

See the Blog Post

InfluxDB 3.5 is now available for both Core and Enterprise, introducing custom plugin repository support, enhanced operational visibility with queryable CLI parameters and manual node management, stronger security controls, and general performance improvements.

InfluxDB 3 Explorer 1.3 brings powerful new capabilities including Dashboards (beta) for saving and organizing your favorite queries, and cache querying for instant access to Last Value and Distinct Value caches—making Explorer a more comprehensive workspace for time series monitoring and analysis.

For more information, check out:

InfluxDB Docker latest tag changing to InfluxDB 3 Core

On November 3, 2025, the latest tag for InfluxDB Docker images will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments.

If using Docker to install and run InfluxDB, the latest tag will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments. For example, if using Docker to run InfluxDB v2, replace the latest version tag with a specific version tag in your Docker pull command–for example:

docker pull influxdb:2