percentile()

percentile(n, col) returns the n-th percentile value of the provided column in the input datastream. A value at the n-th percentile means that n% of the values in the input datastream are below that value.

n must be a numeric value between 0 and 100. Floating point numbers are accepted.

If the provided column does not have numeric values or does not exist, percentile will return null; otherwise, percentile will always return a value that was part of the input datastream.

Technical Notes

  • If there are at most 1000 values in the input stream, percentile uses the nearest rank algorithm to return the exact value.

  • If there are more than 1000 values in the input stream, percentile uses the Karnin, Lang, and Liberty (KLL) algorithm to return an approximation. The approximation is generally within 1% rank error, e.g. the value returned for the 90th percentile will usually be between the 89th and 91st percentile.

Returns

A table with one row and one column, called @q.value.

Examples

# Return the median (value at the 50th percentile) of `elapsed_ms` column
* | percentile(50, elapsed_ms)

# Return the value at the 99.9th percentile of `elapsed_ms` column.
* | percentile(99.9, elapsed_ms)

Last updated