docs-v2/content/flux/v0.x/stdlib/universe/last.md

1.9 KiB
Raw Permalink Blame History

title description aliases menu weight flux/v0.x/tags related introduced
last() function The `last()` function selects the last non-null record from an input table.
/influxdb/v2.0/reference/flux/functions/transformations/selectors/last
/influxdb/v2.0/reference/flux/functions/built-in/transformations/selectors/last/
/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/selectors/last/
/influxdb/cloud/reference/flux/stdlib/built-in/transformations/selectors/last/
flux_0_x_ref
name parent
last universe
102
selectors
transformations
/{{< latest "influxdb" >}}/query-data/flux/first-last/
/{{< latest "influxdb" "v1" >}}/query_language/functions/#last, InfluxQL LAST()
0.7.0

The last() function selects the last non-null record from an input table. last() is a selector function.

last(column: "_value")

{{% warn %}}

Empty tables

last() drops empty tables. {{% /warn %}}

Parameters

column

Column used to verify the existence of a value. If this column is null in the last record, last() returns the previous record with a non-null value. Default is "_value".

tables

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

Examples

{{% flux/sample-example-intro %}}

import "sampledata"

sampledata.int()
    |> last()

{{% expand "View input and output" %}} {{< flex >}} {{% flex-content %}}

Input data

{{% flux/sample "int" %}}

{{% /flex-content %}} {{% flex-content %}}

Output data
tag _time _value
t1 2021-01-01T00:00:50Z 4
tag _time _value
t2 2021-01-01T00:00:50Z 1

{{% /flex-content %}} {{< /flex >}} {{% /expand %}}