COUNTA function
First
The first parameter.
Other
Additional parameters.
Returns
The number of parameters which are not blank.
Returns the number of values which are not blank. COUNTA(1, 2, BLANK(), "test", FALSE, TRUE)COUNTA(1; 2; BLANK(); "test"; FALSE; TRUE) returns 5, because five of the six values are not blank.
To count the number of values which are numbers, use COUNT. To count the number of elements in an array, use SIZE.
Count anything
Using a combination of FILTER and SIZE, you can use any criteria you like. Consider this formula:
The formula above returns a version of the Field1:Field100Field1:Field100 range where only fields whose values are greater than 4 are included. Use the SIZE function to count the number of elements in the returned array:
The formula above returns the number of fields of the Field1:Field100Field1:Field100 range whose values are greater than 4.
It's easy to replicate what COUNTA does armed with this knowledge, and the fact that ISDEFINED can be used to determine if an array element is not blank:
The formula above returns the number of array elements which are not blank, which is exactly what COUNTA does.
Counting can also be done with REDUCE. Here's the equivalent REDUCE formula:
Refer to the REDUCE documentation to learn more about how this example works (specifically, this example is similar to the XOR example in that documentation).
Examples
Returns 5, because five of the six values are not blank.
Returns the number of fields of the Field1:Field100Field1:Field100 range whose values are not blank.
Returns the number of fields of the Field1:Field100Field1:Field100 range whose values
are not blank. The Field1:Field100Field1:Field100 range is filtered
using FILTER
and ISDEFINED, leaving only non-blank
values. FILTER accepts an array as its first parameter and a condition as
its second parameter, and returns an array consisting only of those
elements which satisfy the condition. The condition parameter (where
Element
is set to the array element to be inspected) returns
TRUE only if ISDEFINED returns TRUE when applied to the array element,
which it only does if the array element is not blank.
Returns 5, because five of the six values are not blank. Arrays are supported.