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~: like in, 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 let statement at the top of the query, for example let suspicious = dynamic([...]);. On this site, write the list inside in (...) directly: dynamic() lists and in with a sub-query are not supported yet.

Examples

1 Sign-ins from three countries
SigninLogs
| where Location in ("DE", "AT", "NL")
| summarize SignIns = count() by Location
2 Office apps, whatever the case of the file name
DeviceProcessEvents
| where FileName in~ ("outlook.exe", "WINWORD.EXE", "excel.exe")
| summarize Runs = count() by FileName

The result shows the names as they are stored (OUTLOOK.EXE), whatever case you typed.

3 Every Windows event except logons and logoffs
SecurityEvent
| where EventID !in (4624, 4634)
| summarize count() by EventID

Practice it