Search the array for matches to the specified criteria.
The function takes an array as the first argument and compares its elements to the value provided as the third argument, using the comparison operator specified in the second argument. It then retrieves the index values from the fourth argument, which is also an array that matches the specified criteria.
Possible comparison operators are =,!=, <>, <, <=,>, and>=.
The third argument can be a single value, an array, or both. In the case of an array, it is compared between the same index as the first array.
If the arrays being compared have a different number of elements, they are aligned with the array containing fewer elements.
It does not change the original array.
In the example notation below, ‘(result) ⇒ XXX’ represents the result of executing that expression. Do not enter ‘(result) ⇒ XXX’ in the expression.
= findif(
[1, 2, 3, 4, 5], ">=", 3,
["A", "B", "C", "D", "E"]
)
(Result) ⇒ ["C", "D", "E"]
= findif(
[1, 2, 3, 4, 5],
"=",
[1, 0, 3, 0, 5],
["A", "B", "C", "D", "E"]
)
(Result) ⇒ ["A", "C", "E"]
As a more specific example, suppose the following Source Record is included as the result value of action #1.
Budget | Payment |
---|---|
100 | 120 |
110 | 90 |
120 | 100 |
130 | 200 |
You can use findif to extract source records where payments fall within the budget.
= findif($1.budget, ">=", $1.pay, $1)
(Result) ⇒
Budget | Payment
-----|------
110 | 90
120 | 100
Additionally, aggregation functions like sum can create calculations similar to sumif. The following example illustrates how to calculate the total payments that remain within budget.
SUM
findif($1.budget, ">=", $1.payment, $1).payment
)
(Result) ⇒ 190