SIZE

SIZE(array)[source]

Returns the number of elements in an array or table.

The SIZE function calculates the size of an array-like model component and returns it as a Formula object of type INTEGER. It is useful for determining the number of elements in an array or the size of a table. If the input is a primitive array (e.g. BOOLEAN_ARRAY, INTEGER_ARRAY), this formula has the same behaviour as the formula ROWS. However, if the input is a table or OBJECT_ARRAY, then the formula will evaluate to the number of rows multiplied by the number of columns. A ValueError is raised if the input is not an array type.

Parameters:

array (Operand) –

The arra or table whose size will be evaluated. Must be a valid array type. If the input is not an array, a ValueError is raised.

Supported types:

  • BOOLEAN_ARRAY

  • INTEGER_ARRAY

  • DECIMAL_ARRAY

  • STRING_ARRAY

  • DATE_ARRAY

  • DATETIME_ARRAY

  • TIME_ARRAY

  • OBJECT_ARRAY

Return type:

Formula

Returns:

The total number of elements in the input array, returned as an INTEGER Formula.

Supported types:

  • INTEGER

Raises:

ValueError – If array is not a valid array type.

Examples

Getting the size of a primitive array:

SIZE([10, 20, 30])
# Returns 3

Getting the size of a table:

SIZE(my_table)
# Returns the size (rows * columns) of the table