median() function

The median() function is a special application of the quantile() function that returns the median _value of an input table or all non-null records in the input table with values that fall within the 0.5 quantile (50th percentile) depending on the method used.

median() behaves like an aggregate function or a selector function depending on the method used.

    column: "_value",
    method: "estimate_tdigest",
    compression: 0.0,

When using the estimate_tdigest or exact_mean methods, it outputs non-null records with values that fall within the 0.5 quantile.

When using the exact_selector method, it outputs the non-null record with the value that represents the 0.5 quantile.

The median() function can only be used with float value types. It is a special application of the quantile() function which uses an approximation implementation that requires floats. You can convert your value column to a float column using the toFloat() function.



Column to use to compute the median. Default is "_value".


Computation method. Default is "estimate_tdigest".

The available options are:


An aggregate method that uses a t-digest data structure to compute an accurate quantile estimate on large data sources.


An aggregate method that takes the average of the two points closest to the quantile value.


A selector method that returns the data point for which at least q points are less than.


Number of centroids to use when compressing the dataset. A larger number produces a more accurate result at the cost of increased memory requirements. Default is 1000.0.


Input data. Default is piped-forward data (<-).


The following examples use data provided by the sampledata package to show how median() transforms data.

Median as an aggregate

import "sampledata"

    |> median()

View input and output

Median as a selector

import "sampledata"

    |> median(method: "exact_selector")

View input and output

Was this page helpful?

Thank you for your feedback!

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.