2.3 KiB
2.3 KiB
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. |
|
|
102 |
|
|
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 %}}