where( booleanArray, default )
Returns the indices where the values in the input array are true.
See also:
true
.where()
function.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. |
Integer Array
This function can be useful for finding the value of one field of a CDT in an array of CDT values where each item in the array has a given value for another field. The default
parameter can be used to return a value that is not a valid index in order to cause the index()
function to return its default value if none of the values in the input to the where()
function are true.
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.
where({true, false, true})
returns 1, 3
where(mod({13, 24, 35, 46, 57, 68}, 2)=0)
returns 2, 4, 6
where(pv!scores<50)
returns 8, 10, 12
where pv!scores = {68, 89, 82, 90, 93, 99, 59, 49, 88, 27, 56, 49, 100}
where(pv!scores>avg(pv!scores))
returns 2, 3, 4, 5, 6, 9, 13
where pv!scores = {68, 89, 82, 90, 93, 99, 59, 49, 88, 27, 56, 49, 100}
where({pv!scores}<average({pv!scores})-3*stdevp({pv!scores}),-1)
returns -1
where pv!scores = {68, 89, 82, 90, 93, 99, 59, 49, 88, 27, 56, 49, 100}
because no scores are 3 standard deviations less than the mean and -1
is given as the default value to return if none of the items in the array are true
index()
functionindex(pv!employees.firstName, where(like(pv!employees.department, "Finance"), -1), "None")
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.
where(null, 1000)
returns 1000
where(null)
returns an empty list
where({}, -1)
returns -1
where({})
returns an empty list
where({true, false, null, true})
returns 1, 4
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 | |
Process Reports | Compatible | |
Process Events | Compatible |
where() Function