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

2.3 KiB
Raw Permalink Blame History

title description aliases menu weight flux/v0.x/tags related introduced
count() function The `count()` function outputs the number of non-null records in a column.
/influxdb/v2.0/reference/flux/functions/transformations/aggregates/count
/influxdb/v2.0/reference/flux/functions/built-in/transformations/aggregates/count/
/influxdb/v2.0/reference/flux/stdlib/built-in/transformations/aggregates/count/
/influxdb/cloud/reference/flux/stdlib/built-in/transformations/aggregates/count/
flux_0_x_ref
name parent
count universe
102
aggregates
transformations
/{{< latest "influxdb" "v1" >}}/query_language/functions/#count, InfluxQL COUNT()
/flux/v0.x/stdlib/experimental/count/
0.7.0

The count() function outputs the number of records in a column. It counts both null and non-null records. count() is an aggregate function.

Output data type: Integer

count(column: "_value")

{{% note %}}

Empty tables

count() returns 0 for empty tables. To keep empty tables in your data, set the following parameters for the following functions:

Function Parameter
filter() onEmpty: "keep"
window() createEmpty: true
aggregateWindow() createEmpty: true
{{% /note %}}

Parameters

column

The column on which to operate. Defaults to "_value".

tables

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

Examples

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

Count the number of rows in each input table

import "sampledata"

sampledata.string()
    |> count()

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

Input data

{{% flux/sample "string" %}}

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

Output data
tag _value
t1 6
tag _value
t2 6

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