2.1 KiB
2.1 KiB
title | description | aliases | menu | weight | flux/v0.x/tags | related | introduced | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
bottom() function | The `bottom()` function sorts a table by columns and keeps only the bottom n records. |
|
|
102 |
|
|
0.7.0 |
The bottom()
function sorts a table by columns and keeps only the bottom n
records.
bottom()
is a selector function.
bottom(n:10, columns: ["_value"])
{{% warn %}}
Empty tables
bottom()
drops empty tables.
{{% /warn %}}
Parameters
n
Number of records to return.
columns
List of columns by which to sort.
Sort precedence is determined by list order (left to right).
Default is ["_value"]
.
tables
Input data.
Default is piped-forward data (<-
).
Examples
{{% flux/sample-example-intro %}}
Return rows with the two lowest values
import "sampledata"
sampledata.int()
|> bottom(n:2)
{{< expand-wrapper >}} {{% expand "View input and output" %}} {{< flex >}} {{% flex-content %}}
Input data
{{% flux/sample set="int" %}}
{{% /flex-content %}} {{% flex-content %}}
Output data
_time | tag | _value |
---|---|---|
2021-01-01T00:00:00Z | t1 | -2 |
2021-01-01T00:00:50Z | t1 | 4 |
_time | tag | _value |
---|---|---|
2021-01-01T00:00:20Z | t2 | -3 |
2021-01-01T00:00:50Z | t2 | 1 |
{{% /flex-content %}} {{< /flex >}} {{% /expand %}} {{< /expand-wrapper >}}