in / !in / in~
in tests whether a value equals any item in a list. It is a shorter and clearer way to write a chain
of == conditions joined with or:
// These two are the same
| where EventID in (4624, 4625, 4634)
| where EventID == 4624 or EventID == 4625 or EventID == 4634
There are four variants:
in: the value is in the list. For strings, case matters, like==.!in: the value is not in the list.in~: likein, but ignores case for strings, like=~.!in~: not in the list, ignoring case.
The list goes in parentheses and can hold strings, numbers or dates. Keep the items the same type as the column.
Things to know
- For lists of file names, user names or domains, prefer
in~: the same name is often logged in different cases. - A long list is easier to maintain in a
letstatement at the top of the query, for examplelet suspicious = dynamic([...]);. On this site, write the list insidein (...)directly:dynamic()lists andinwith a sub-query are not supported yet.
Examples
SigninLogs
| where Location in ("DE", "AT", "NL")
| summarize SignIns = count() by LocationDeviceProcessEvents
| where FileName in~ ("outlook.exe", "WINWORD.EXE", "excel.exe")
| summarize Runs = count() by FileNameThe result shows the names as they are stored (OUTLOOK.EXE), whatever case you typed.
SecurityEvent
| where EventID !in (4624, 4634)
| summarize count() by EventIDPractice it
+ 1 in the full SC-200 set · all exercises