Documentation

top() function

Flux 0.7.0+

The top() function sorts each input table by columns and keeps only the top n records. top() is a selector function.

top(n:10, columns: ["_value"])

Empty tables

top() drops empty tables.

Parameters

n

(Required) Number of records to return.

columns

List of columns to sort by. Sort precedence is determined by list order (left to right). Default is ["_value"].

tables

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

Examples

The following example uses data provided by the sampledata package to show how top() transforms data.

Return rows with the top three values in each input table
import "sampledata"

sampledata.int()
  |> top(n: 3)

View input and output


Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.