ConvertCalculator Icon

FILTER function

The FILTER function allows you the perform an action (function) over each element of an array deciding whether it should stay in the array or not resulting in a new filtered array.

Syntax

The syntax for FILTER is as follows

FS
FILTER(array, f)
  • array an array (collection/list) of values
  • f the function you want to apply on each value (can be built-in or a custom function)

The result is another array

Examples

FS
// only keep values that are numbers FILTER(ARRAY(1, 2, -5, 'string', ARRAY(), true), ISNUMBER) // -> [1, 2, -5] // only keep value that are positive (greater or equal to 0) FILTER(ARRAY(-5, -3, 3, 5, 100, -100, 0), function(x: x >= 0)) // -> [3, 5, 100, 0]