Filter
This formula allows you to filter values from an array (list) based on a condition.
JSON Format
{
"type": "filter",
"components": ...,
"filter": ...,
"filter_value_key": ...
}
Fields
| Field | Type | Required | Description |
|---|---|---|---|
components | StatFormulaComponent | ✓ | The formula for the array (list) whose values you want to filter. |
filter | StatFormulaComponent | ✓ | The formula for the condition that should be satisfied for a value to be present in the array resulting from this Filter formula. Anything inside this formula can make use of the $filterValue stat, which will contain the current value for the iteration (e.g: if iterating the array ['a', 'b', 'c'], $filterValue will first be equal to 'a', then 'b' and then 'c'), thus allowing the formula specified here to access the value of each element in the array one at a time as part of the condition. If you were to specify the optional filter_value_key parameter, you should use the key given there instead of $filterValue to access these values. |
filter_value_key | String | Optional parameter that lets you provide a key to use in the filter formula to access the array's current value in the iteration. e.g: if you are iterating classes, you might want to assign "$class" to the filter_value_key, to make your system easier to read. This is also helpful when dealing with nested filter formulas, as it will allow inner filter formulas to access the values of outer filter formulas. |