FunctionCopy link to clipboard
where( booleanArray, default )
Returns the indexes where the values in the input array are true.
See also:
- wherecontains(): Use this function to return indexes of an array that match a user-defined value, instead of items that evaluate to
true
. - index(): Use this function to return the values of an array at the indexes you gathered with the
where()
function.
ParametersCopy link to clipboard
Keyword | Type | Description |
---|---|---|
|
Boolean Array |
The array of Boolean values to test. |
|
Integer or Integer Array |
The integer number or array of integer numbers to return if none of the values in the array are true. |
ReturnsCopy link to clipboard
Integer Array
Usage considerationsCopy link to clipboard
When to use where()Copy link to clipboard
This function is useful for finding values in an array that meet a certain criterion. It's also useful for checking the value of a field in an array of CDT field values.
Understanding resultsCopy link to clipboard
If a default value is not specified and none of the values in the input array are true, an empty list will be returned.
A null or empty array given as the array parameter is considered false.
ExamplesCopy link to clipboard
Check which indexes are trueCopy link to clipboard
1
where({true, false, true})
Copy
Returns 1, 3
.
When all array values are false and no default is specified, an empty set is returned. For example:
1
where({false, false, false})
Copy
Returns {}
.
When all array values are false and a default is specified, the default value is returned. For example:
1
where({false, false, false}, -1)
Copy
Returns {-1}
.
Check which indexes are evenCopy link to clipboard
1
where(mod({13, 24, 35, 46, 57, 68}, 2)=0)
Copy
Returns 2, 4, 6
. mod({13, 24, 35, 46, 57, 68}, 2)=0
returns a list of true and false values based on whether a value is divisible by 2. The where()
function then returns the list of indexes for true values (in this example, the even numbers).
Use with comparison operatorsCopy link to clipboard
Check which indexes are greater than 50Copy link to clipboard
1
2
3
4
a!localVariables(
local!scores: {68, 89, 82, 90, 93, 99, 59, 49, 88, 27, 56, 49, 100},
where(local!scores < 50)
)
Copy
Returns {8, 10, 12}
.
Check which indexes are greater than the averageCopy link to clipboard
1
2
3
4
a!localVariables(
local!scores: {68, 89, 82, 90, 93, 99, 59, 49, 88, 27, 56, 49, 100},
where(local!scores > average(local!scores))
)
Copy
Returns {2, 3, 4, 5, 6, 9, 13}
.
Check which indexes are less than three standard deviations from the meanCopy link to clipboard
1
2
3
4
5
6
7
a!localVariables(
local!scores: {68, 89, 82, 90, 93, 99, 59, 49, 88, 27, 56, 49, 100},
where(
local!scores < average(local!scores) - 3 * stdevp(local!scores),
-1
)
)
Copy
Returns -1
because no scores are less than three standard deviations from the mean.
Use with the index()
functionCopy link to clipboard
Note: The rule input and CDT shown in this section are for reference only. If you copy and paste either expression, it will not evaluate.
Return first name of employees in a specified departmentCopy link to clipboard
1
2
3
4
5
6
7
8
index(
ri!employees.firstName,
where(
like(ri!employees.department, "Finance"),
-1
),
"None"
)
Copy
Returns all of the first names of employees in the Finance department, or "None" if none of the employees have their department field set to Finance.
Return customers with risk scores greater than 15Copy link to clipboard
1
2
3
4
5
6
7
8
9
10
a!localVariables(
local!customer: {
'type!Customer'(riskScore: 1),
'type!Customer'(riskScore: 25),
'type!Customer'(),
'type!Customer'(riskScore: 15),
},
local!customer[where(local!customer.riskScore > 10)]
)
Copy
Returns the customer CDTs from the original list with risk scores greater than 15 (the second and fourth customers).
Use with a null or empty arrayCopy link to clipboard
Null booleanArrayCopy link to clipboard
1
where(null)
Copy
Returns {}
.
Null booleanArray with defaultCopy link to clipboard
1
where(null, 1000)
Copy
Returns {1000}
.
Empty booleanArrayCopy link to clipboard
1
where({})
Copy
Returns {}
.
Empty booleanArray with defaultCopy link to clipboard
1
where({}, -1)
Copy
Returns {-1}
booleanArray with null itemCopy link to clipboard
1
where({true, false, null, true})
Copy
Returns {1, 4}
Feature compatibilityCopy link to clipboard
The table below lists this function's compatibility with various features in Appian.
Feature | Compatibility | Note |
---|---|---|
Portals | Compatible | |
Offline Mobile | Compatible | |
Sync-Time Custom Record Fields | Compatible | Can be used to create a custom record field that only evaluates at sync time. |
Real-Time Custom Record Fields | Incompatible | Custom record fields that evaluate in real time must be configured using one or more Custom Field functions. |
Process Reports | Compatible | |
Process Events | Compatible | |
Process Autoscaling | Compatible |