SIZE function

SIZE(Array) SIZE(Array)

Array

{ ? }

The array

Returns

Number

The size of the given array, also known as its length.

Returns the size of the given array, that is, the number of elements that are contained in the array. SIZE({ 1, 2, 3 })SIZE({ 1; 2; 3 }) returns 3.

SIZE may be used together with FILTER to determine the number of elements matching the filter. This formula returns 2, because only the 20 and 59 elements are greater than 1:

SIZE(FILTER({ 1, 20, 59 }, Element > 1))SIZE(FILTER({ 1; 20; 59 }; Element > 1))

SIZE is different from the COUNT and COUNTA functions. COUNT counts the number of parameters or array elements which can be interpreted as numbers, while COUNTA counts the number of parameters which are not blank.

By contrast, SIZE counts all elements of an array, regardless of whether they are numbers, logical values, text strings or blank. It runs faster than COUNT and COUNTA, because while these two functions need to inspect each and every array element to see if they meet their criteria, SIZE has no need to look at the array elements individually.

Examples

SIZE({ 1, 2, 3 })SIZE({ 1; 2; 3 })

Returns 3.

SIZE(FILTER({ 1, 20, 59 }, Element > 1))SIZE(FILTER({ 1; 20; 59 }; Element > 1))

Returns the number of elements of the { 1, 20, 59 }{ 1; 20; 59 } array which are greater than 1. As only the 20 and 59 elements are greater than 1, 2 is returned.

SIZE({ 1, 2, "3", TRUE, "a", BLANK() })SIZE({ 1; 2; "3"; TRUE; "a"; BLANK() })

Returns 6.

COUNT({ 1, 2, "3", TRUE, "a", BLANK() })COUNT({ 1; 2; "3"; TRUE; "a"; BLANK() })

Returns 4, because COUNT is only concerned with numbers. "3" is a text string, but can be interpreted as a number. Logical values — TRUE and FALSE — also count as numbers.

COUNTA({ 1, 2, "3", TRUE, "a", BLANK() })COUNTA({ 1; 2; "3"; TRUE; "a"; BLANK() })

Returns 5, because COUNTA disregards blank values.