FILTER

FILTER(array, filter_condition)[source]

Returns a filtered subset of an array based on a specified condition.

This function evaluates array and applies filter_condition to determine which elements or rows should be included in the result. The filter_condition must be an array of booleans, integers, or decimals representing the inclusion criteria. Both singular arrays and table objects are supported. If the condition or array is blank or in an error state, or if array and filter_condition are not arrays of the same size, the formula evaluates to an error.

Parameters:
  • array (Table | Operand) –

    The array or table to filter. The return will be a filtered array of the same type.

    Supported types:

    • INTEGER_ARRAY

    • DECIMAL_ARRAY

    • STRING_ARRAY

    • BOOLEAN_ARRAY

    • DATE_ARRAY

    • DATETIME_ARRAY

    • TIME_ARRAY

    • OBJECT_ARRAY

  • filter_condition (Operand) –

    An array representing which elements or rows to include. Must be of type BOOLEAN_ARRAY, INTEGER_ARRAY, or DECIMAL_ARRAY. If a non-boolean type is used, the value is treated as True if non-zero, False if zero.

    Supported types:

    • BOOLEAN_ARRAY

    • INTEGER_ARRAY

    • DECIMAL_ARRAY

Return type:

Formula

Returns:

A filtered array containing only elements or rows that meet the filter_condition. Returns an array of the same type as array or an object array for tables.

Supported types:

  • INTEGER_ARRAY

  • DECIMAL_ARRAY

  • STRING_ARRAY

  • BOOLEAN_ARRAY

  • DATE_ARRAY

  • DATETIME_ARRAY

  • TIME_ARRAY

  • OBJECT_ARRAY

Raises:
  • ValueError – If filter_condition is not BOOLEAN_ARRAY, INTEGER_ARRAY, or DECIMAL_ARRAY.

  • ValueError – If array is not an array or table type.

Examples

Filtering an array of numbers:

FILTER([1, 2, 3, 4, 5], [True, False, True, False, True])
# Returns [1, 3, 5]

Filtering a table:

FILTER(customers_table, customers_table["active"])
# Returns all rows where 'active' is True