COUNT

COUNT returns the number of elements in an array or a series of elements. It can take an arbitrary number of optional arguments.

Function group: Statistical

Syntax

COUNT(arg1, [arg2...])

Arguments

Description

arg1

A number, string or an array of numbers or strings (or any value that can be parsed into a number).

arg2

Optional. Same as arg1.

Examples

Let's say we're given a response with the following lists of driver IDs:

{
"data": {
"driver_performance_ratings": {
"highest": 98,
"lowest": 20,
"fleet": [
30,
60,
55,
99
]
}
}
}

Example 1: Find amount of drivers (highest and lowest)

If we want to find the amount of highest rated drivers and the lowest rated drivers, use the following function.

# Find the number of highest and lowest rated drivers.
COUNT(data.driver_performance_ratings.highest,
data.driver_performance_ratings.lowest)
# Returns 2

Example 2: Find amount of drivers (highest and lowest) using an array

If we wanted to find the number of highest and lowest rated drivers using the fleet array, use the following function.

COUNT(data.driver_performance_ratings.highest,
data.driver_performance_ratings.lowest,
data.driver_performance_ratings.fleet)
# Returns 6