This page explains how to use the stdevif aggregation function in APL.
stdevif
aggregation function in APL computes the standard deviation of values in a group based on a specified condition. This is useful when you want to calculate variability in data, but only for rows that meet a particular condition. For example, you can use stdevif
to find the standard deviation of response times in an HTTP log, but only for requests that resulted in a 200 status code.
The stdevif
function is useful when you want to analyze the spread of data values filtered by specific criteria, such as analyzing request durations in successful transactions or monitoring trace durations of specific services in OpenTelemetry data.
Splunk SPL users
stdev
function is used to calculate the standard deviation, but you need to use an if
function or a where
clause to filter data. APL simplifies this by combining both operations in stdevif
.ANSI SQL users
STDDEV
function is used to compute the standard deviation, but it requires the use of a CASE WHEN
expression to apply a conditional filter. APL integrates the condition directly into the stdevif
function.stdevif
function returns a floating-point number representing the standard deviation of the specified column for the rows that satisfy the condition.
req_duration_ms
), but only for successful HTTP requests (status code 200).Querygeo.country | stdev_req_duration_ms |
---|---|
US | 120.45 |
Canada | 98.77 |
Germany | 134.92 |
stdevif
, but instead of calculating the standard deviation, avgif
computes the average of values that meet the condition.sumif
when you want to aggregate total values instead of analyzing data spread.