This page explains how to use the sumif aggregation function in APL.
sumif
aggregation function in Axiom Processing Language (APL) computes the sum of a numeric expression for records that meet a specified condition. This function is useful when you want to filter data based on specific criteria and aggregate the numeric values that match the condition. Use sumif
when you need to apply conditional logic to sums, such as calculating the total request duration for successful HTTP requests or summing the span durations in OpenTelemetry traces for a specific service.
Splunk SPL users
sumif
equivalent functionality requires using a stats
command with a where
clause to filter the data. In APL, you can use sumif
to simplify this operation by combining both the condition and the summing logic into one function.ANSI SQL users
CASE
statement inside the SUM
function to conditionally sum values based on a specified condition. In APL, sumif
provides a more concise approach by allowing you to filter and sum in a single function.numeric_expression
: The numeric field or expression you want to sum.condition
: A boolean expression that determines which records contribute to the sum. Only the records that satisfy the condition are considered.sumif
returns the sum of the values in numeric_expression
for records where the condition
is true. If no records meet the condition, the result is 0.
200
status code.Querytotal_req_duration |
---|
145000 |
200
).avgif
when you’re interested in the average value, not the total sum.countif
when you need to know how many records match a specific criterion.maxif
to identify the highest values under certain conditions.