How to Use the Filter
The Filter enables users to filter a dataset based on a human-readable filter string. This tool allows for dynamic and complex filtering by specifying conditions and logical operators like and
and or
.
Here is a detailed guide on how to use the filter function, specifically using the dataset fields provided as examples:
Filter String Format
The filter string should consist of conditions and logical operators (and
, or
).
Conditions
A condition specifies:
Field: The name of the field in the dataset you want to filter (e.g.,
id
,deviceName
,userDisplayName
).Operator: The comparison or matching operator (e.g.,
eq
,gt
,contains
).Value: The value you want to compare, enclosed in single (
'
) or double ("
) quotes.
Example Condition:
deviceName startsWith 'iPhone'
Logical Operators
and
: Combines multiple conditions where all conditions must be true.or
: Combines multiple conditions where at least one condition must be true.
Note: You can use either and
or or
in a single filter but not both at the same time.
Supported Operators
Operator | Description | Example |
---|---|---|
eq | Field is equal to the value | complianceState eq 'Compliant' |
ne | Field is not equal to the value | jailBroken ne 'Yes' |
gt | Field is greater than the value | lastSyncDateTime gt '2024-01-01T00:00:00Z' |
lt | Field is less than the value | freeStorageSpaceInBytes lt 500000 |
ge | Field is greater than or equal to the value | totalStorageSpaceInBytes ge 64000000 |
le | Field is less than or equal to the value | managementCertificateExpirationDate le '2023-12-31T23:59:59Z' |
contains | The field contains the value (for strings) | userDisplayName contains 'Smith' |
startsWith | The field starts with the value (for strings) | deviceName startsWith 'Android' |
endsWith | The field ends with the value (for strings) | emailAddress endsWith '@example.com' |
isEmpty | The field is empty (null, undefined, or empty string) | emailAddress isEmpty |
isNotEmpty | The field is not empty | emailAddress isNotEmpty |
Examples
Find Devices Managed by a Specific User:
userDisplayName eq 'John Doe'
Find Devices Last Synced After a Specific Date:
lastSyncDateTime gt '2024-01-01T00:00:00Z'
Find Devices with a Specific Operating System and Compliant State:
operatingSystem eq 'iOS' and complianceState eq 'Compliant'
Find Devices Registered in Azure AD or Supervised Devices:
azureADRegistered eq 'Yes' or isSupervised eq 'Yes'
Find Devices with Free Storage Below 1GB:
freeStorageSpaceInBytes lt 1000000000
Key Rules
Case Sensitivity:
Field names and string comparisons are case-sensitive. Ensure your field names and values match the case in the dataset.
Quotes:
Use single (
'
) or double ("
) quotes to enclose values.
Logical Operators:
You cannot mix
and
andor
in the same filter.
Empty Filter String:
If the filter string is empty or
null
, the function returns the original dataset.