top() function
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)
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, use the following resources:
InfluxDB Cloud customers can contact InfluxData Support.