# percentile() function

Warning! This page documents an earlier version of Flux, which is no longer actively developed. Flux v0.65 is the most recent stable version of Flux.

The `percentile()` function returns records from an input table with `_value`s that fall within a specified percentile or it returns the record with the `_value` that represents the specified percentile. Which it returns depends on the method used.

Function type: Aggregate or Selector
Output data type: Float or Object

``````percentile(columns: ["_value"], percentile: 0.99, method: "estimate_tdigest", compression: 1000)
``````

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

When using the `exact_selector` method, it outputs the non-null record with the value that represents the specified percentile.

## Parameters

### columns

A list of columns on which to compute the percentile. Defaults to `["_value"]`.

Data type: Array of strings

### percentile

A value between 0 and 1 indicating the desired percentile.

Data type: Float

### method

Defines the method of computation.

Data type: String

The available options are:

##### estimate_tdigest

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

##### exact_mean

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

##### exact_selector

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

### compression

Indicates how many centroids to use when compressing the dataset. A larger number produces a more accurate result at the cost of increased memory requirements. Defaults to 1000.

Data type: Float

## Examples

###### Percentile as an aggregate
``````from(bucket: "telegraf/autogen")
|> range(start: -5m)
|> filter(fn: (r) =>
r._measurement == "cpu" AND
r._field == "usage_system")
|> percentile(
percentile: 0.99,
method: "estimate_tdigest",
compression: 1000
)
``````
###### Percentile as a selector
``````from(bucket: "telegraf/autogen")
|> range(start: -5m)
|> filter(fn: (r) =>
r._measurement == "cpu" AND
r._field == "usage_system")
|> percentile(
percentile: 0.99,
method: "exact_selector"
)
``````

PERCENTILE()
{"ft_lang_label":"__label__en","ft_lang_prob":0.6078892,"math_prob":0.70426464,"size":2003,"snap":"2020-24-2020-29","text_gpt3_token_len":468,"char_repetition_ratio":0.14907454,"word_repetition_ratio":0.13427562,"special_character_ratio":0.23065402,"punctuation_ratio":0.1491228,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97441626,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-05-27T13:29:08Z\",\"WARC-Record-ID\":\"<urn:uuid:1bfe193c-e3d2-4094-befe-35ba400b4624>\",\"Content-Length\":\"42543\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:777ab483-af0f-489e-9f36-45412f821e65>\",\"WARC-Concurrent-To\":\"<urn:uuid:eb46b0e7-706a-43c0-8efb-2b8d7d9a9088>\",\"WARC-IP-Address\":\"54.192.30.74\",\"WARC-Target-URI\":\"https://docs.influxdata.com/flux/v0.7/functions/transformations/aggregates/percentile/\",\"WARC-Payload-Digest\":\"sha1:MF4ZD7MEQBNW65BDP2E5QTV67G5NZ3YR\",\"WARC-Block-Digest\":\"sha1:GS5OV4OZ3AJJIU6QGCWCGDUTMTYF7TDN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-24/CC-MAIN-2020-24_segments_1590347394074.44_warc_CC-MAIN-20200527110649-20200527140649-00535.warc.gz\"}"}