FILTER

Takes an array or an object as well as a lambda function or an array of values to keep. If the input is an array, it returns a new array with all the values that match the lambda function or are in the array of values to keep. If the input is an object, it returns a new object with all the key-value pairs with values that match the lambda function or are in the array of values to keep.

Syntax 

FILTER(array | object, values_to_keep | LAMBDA(item, [expr]))

Usage examples 

Example 1

Input

1
{
2
"my_array": [
3
1,
4
1,
5
2,
6
2,
7
3,
8
3
9
]
10
}

Formula

FILTER(my_array, ARRAY(2, 4))

Output

1
[
2
2,
3
2
4
]

Example 2

Input

1
{
2
"my_array": [
3
1,
4
2,
5
3,
6
4,
7
5,
8
6,
9
7,
10
8,
11
9,
12
10
13
]
14
}

Formula

FILTER(my_array, LAMBDA(item, item > 5))

Output

1
[
2
6,
3
7,
4
8,
5
9,
6
10
7
]

Example 3

Input

1
{
2
"my_object": {
3
"a": 1,
4
"b": 2,
5
"c": 3,
6
"d": 4,
7
"e": 5
8
}
9
}

Formula

FILTER(my_object, ARRAY(2, 4))

Output

1
{
2
"b": 2,
3
"d": 4
4
}

Example 4

Input

1
{
2
"my_object": {
3
"a": 1,
4
"b": 2,
5
"c": 3,
6
"d": 4,
7
"e": 5
8
}
9
}

Formula

FILTER(my_object, LAMBDA(item, item > 2))

Output

1
{
2
"c": 3,
3
"d": 4,
4
"e": 5
5
}

Sample Actions 

Event transform
FILTER
Event transform
My Action

Select an action to inspect.

You can also click "Copy actions" and paste them in your Tines story to see how they work.

Was this helpful?