Basic Filter Structure:
- $filter=[FieldIdentifier] Function 'Condition to Meet'
Think of filter expressions as conditions that are either met or not. Below are the two main examples for filter building, based on the reference to a field and whether the condition is met will determine if the target item is hidden / filtered.
- $filter=[FieldIdentifier] eq 'Value'
- $filter=[FieldIdentifier] ne 'Value'
Below are the different functions that can be used in a filter, the text in bold is what you can use in the '$filter=' and the text after it is the expression equivalent that is used in field expressions:
- Not equal to: ne for <>
- Equal to: eq for =
- Greater than: gt for >
- Equal to or greater than: gte for >=
- Less than: lt for <
- Equal to or less than: lte for <=
$filter=([FieldIdentifier1] gt 0 and [FieldIdentifier2] eq 'Value2') or [FieldIdentifier3] ne 'Value3'
In the above, the Filter conditions will be met if Field1 is greater than 0 and Field2 equals 'Value2, or if Field3 is not equal to value 3.
The given value will vary depending on what type of Field is initially referenced, these can be number values in the more traditional sense or text ones:
- [TextFieldIdentifier] - Quote the desired text value: 'Text'
- [NumberFieldIdentifier] - Quote the desired number, without quote marks: 1
- [BitFieldFieldIdentifier] - Quote the desired Boolean value, without quote marks: true or false
- [DateFieldIdentifier] - Quote the desired date value: datetime'2021-01-01T00:00:00'
- e.g. [FieldName] gt datetime'2021-01-01T00:00'