isnotnull

This page explains how to use the isnotnull function in APL.

The isnotnull function returns true if the argument isn’t null. Use this function to filter for records with defined values, validate data presence, or distinguish between null and other values including empty strings.

Usage

Syntax

isnotnull(value)

Parameters

NameTypeRequiredDescription
valuescalarYesThe value to check for non-null.

Returns

Returns true if the value isn't null, otherwise returns false. Note that empty strings return true because they're not null.

Use case examples

Filter HTTP logs to only include requests where duration information is available for performance analysis.

Query

['sample-http-logs']
| where isnotnull(req_duration_ms)
| summarize avg_duration = avg(req_duration_ms),
            max_duration = max(req_duration_ms),
            request_count = count() by status
| sort by avg_duration desc
| limit 10

Run in Playground

Output

statusavg_durationmax_durationrequest_count
500987.55432234
200145.334218765
40489.79871234

This query filters to only include requests with duration data, ensuring accurate performance metrics without skewing calculations with null values.

Analyze traces with recorded durations to calculate accurate service performance metrics.

Query

['otel-demo-traces']
| where isnotnull(duration)
| summarize p50_duration = percentile(duration, 50),
            p95_duration = percentile(duration, 95),
            trace_count = count() by ['service.name']
| sort by p95_duration desc
| limit 10

Run in Playground

Output

service.namep50_durationp95_durationtrace_count
checkout234ms987ms3421
frontend145ms654ms4532
cart89ms456ms2987

This query ensures duration calculations are based only on spans with recorded timing data, preventing null values from affecting percentile calculations.

Track requests with identified users to analyze authenticated access patterns versus anonymous attempts.

Query

['sample-http-logs']
| extend has_user_id = isnotnull(id)
| summarize requests_by_type = count() by has_user_id, status, ['geo.country']
| sort by requests_by_type desc
| limit 10

Run in Playground

Output

has_user_idstatusgeo.countryrequests_by_type
true401United States456
true403Unknown345
false401Russia234
false403China123

This query distinguishes between authenticated and truly anonymous access attempts by checking for user ID presence, helping identify different attack patterns.

  • isnull: Returns true if a value is null. Use this for the inverse check of isnotnull.
  • isnotempty: Checks if a value isn't empty and not null. Use this when you need to ensure both conditions.
  • coalesce: Returns the first non-null value from a list. Use this to provide default values for null fields.
  • gettype: Returns the type of a value. Use this to distinguish between null and other types.

Other query languages