!in operator in APL filters records based on whether a value doesn’t match any element in a specified set using case-sensitive comparison. Use this operator to exclude records where a field value equals one of several values, which is more concise and efficient than chaining multiple inequality checks with and. The !in operator works with any scalar type, including strings, numbers, booleans, datetime values, and dynamic arrays.
Use the !in operator when you need to exclude specific values with exact case-sensitive matching, such as filtering out known good status codes, excluding requests from specific regions, or removing traces from certain services.
For users of other query languages
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.Splunk SPL users
Splunk SPL users
In Splunk SPL, you negate the
IN function using NOT to exclude values. APL’s !in operator provides a more concise syntax for the same operation and is case-sensitive by default.ANSI SQL users
ANSI SQL users
In ANSI SQL, you use
NOT IN within a WHERE clause to exclude rows where a column value matches any value in a list. APL’s !in operator behaves the same way but is case-sensitive for string comparisons.Usage
Syntax
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| Expression | scalar | Yes | The value to check against the exclusion set. |
| Value | scalar or tabular | Yes | The values to exclude. Specify individual scalar values, a dynamic array, or a subquery. When using a subquery with multiple columns, APL uses the first column. The operator supports up to 1,000,000 unique values in the set. |
Returns
Returnstrue if the expression value is not found in the specified set. Returns false otherwise.
Use case examples
- Log analysis
- OpenTelemetry traces
Filter HTTP logs to exclude successful responses and focus on potential issues.QueryRun in PlaygroundOutput
This query filters the HTTP logs to return only requests that did not result in successful status codes, helping you identify errors and issues.
| _time | method | uri | status |
|---|---|---|---|
| 2024-10-17 10:20:00 | GET | /api/missing | 404 |
| 2024-10-17 10:25:30 | POST | /api/data | 500 |
| 2024-10-17 10:30:45 | GET | /api/forbidden | 403 |
Use with dynamic arrays
When you pass a dynamic array with nested arrays, APL flattens them into a single list. For instance,x !in (dynamic([1, [2, 3]])) is equivalent to x !in (1, 2, 3).
List of related operators
- in: Use for case-sensitive matching to include values. Returns
trueif the value is in the set. - in~: Use for case-insensitive matching. Matches values regardless of case.
- !in~: Use for case-insensitive exclusion. Excludes values regardless of case.
- where: Use to filter rows based on conditions. The
!inoperator is commonly used withinwhereclauses. - !=: Use for single value inequality checks. Use
!inwhen checking against multiple values for more concise queries.