LAMBDA

Creates a custom, reusable function.

Syntax 

LAMBDA([parameter1, parameter2, …,] calculation)

Examples 

Example 1

Select all the elements in an array that regex match the string "r"​

Input

{
  "my_array": [
    "red",
    "blue",
    "green"
  ]
}

Formula

FILTER(input.my_array, LAMBDA(element, MATCH(element, "r")))

Output

[
  "red",
  "green"
]
Example 2

Get the difference between 2 arrays, i.e. get elements from array_two that are not present in array_one​

Input

{
  "array_one": [
    "dog",
    "cat",
    "turtle",
    "dinosaur",
    "lizard",
    "chicken",
    "koala"
  ],
  "array_two": [
    "cat",
    "elephant",
    "giraffe",
    "penguin",
    "tiger",
    "koala"
  ]
}

Formula

FILTER(input.array_two, LAMBDA(array_two_elem, NOT(INCLUDES(input.array_one, array_two_elem))))

Output

[
  "elephant",
  "giraffe",
  "penguin",
  "tiger"
]
Was this helpful?