isempty / isnotempty / isnull

Missing data looks different depending on the column type:

  • A string column in Kusto is never null. A missing string is the empty string "".
  • A number, date, time span or boolean can be null.

That is why there are two pairs of functions:

Function Use it on True when
isempty(x) strings (mostly) x is "" or null
isnotempty(x) strings (mostly) x has a value
isnull(x) numbers, dates, times x is null
isnotnull(x) numbers, dates, times x is not null

isempty() also returns true for a null number, so it works on any type. isnull() on a string is always false, because strings are never null. So for strings, always use isempty() / isnotempty().

Typical uses

  • Drop rows without the field you need: where isnotempty(IPAddress).
  • Count how often a field is filled: summarize countif(isnotempty(RemoteUrl)).
  • Before a join, remove rows with an empty key, so that empty values don’t match each other.

Examples

1 Network connections with and without a URL
DeviceNetworkEvents
| summarize WithUrl = countif(isnotempty(RemoteUrl)), WithoutUrl = countif(isempty(RemoteUrl))

Connections made straight to an IP address have no URL.

2 Only the sign-ins that have an error description
SigninLogs
| where isnotempty(ResultDescription)
| distinct ResultType, ResultDescription
3 A number that is missing is null, a string is empty
SecurityEvent
| where EventID == 4672
| summarize Rows = count(), NoLogonType = countif(isnull(LogonType)), NoIp = countif(isempty(IpAddress))

Event 4672 (special privileges) has no logon type and no IP here: LogonType is a number, so it is null; IpAddress is a string, so it is empty.

Practice it

None of the free exercises needs this one yet.