COUNTBY
Counts the number of values within a column, partitioned by the unique values of a separate column
Last updated
Counts the number of values within a column, partitioned by the unique values of a separate column
Last updated
COUNTBY( column
, partition column
)
Counts the number of values within a column
when grouped by unique values within a partition column
.
COUNTBY() is a window function, which performs COUNT() except partitioned by the unique values of a separate column.
Input
Description
column
Column to count
partition column
Column containing unique values.
Outputs a count of values when grouped by partition column
.
In this example, we want to count the number of non-null cells in {Adult Population}
, partitioned by {Region}
.