COUNT
- COUNT(array, value)[source]
Counts the number of occurrences of a specified value in an array.
COUNT evaluates the input array and returns the total number of times value appears. The value must be compatible with the data type of the array elements.
- Parameters:
- Return type:
- Returns:
A formula object evaluating to an INTEGER representing the count of value in array.
- Raises:
ValueError – If array is not an array type
ValueError – If value does not match the array element type
Examples
Counting numeric occurrences:
COUNT([1, 2, 1, 3, 1], 1) # Returns 3 # Explanation: The value 1 occurs three times
Counting string occurrences:
COUNT(["A", "B", "A", "C"], "A") # Returns 2 # Explanation: "A" appears twice in the array
Counting boolean occurrences:
COUNT([True, False, True, True], True) # Returns 3
``array`` — accepted types
BOOLEAN_ARRAY
DATETIME_ARRAY
DATE_ARRAY
DECIMAL_ARRAY
INTEGER_ARRAY
OBJECT_ARRAY
STRING_ARRAY
TIME_ARRAY
``value`` — accepted types
BOOLEAN
DATE
DATETIME
DECIMAL
INTEGER
OBJECT
OBJECT_ARRAY
STRING
TIME
Return types
INTEGER