This page explains how to use the percentileif aggregation function in APL.
The percentileif
aggregation function calculates the percentile of a numeric column, conditional on a specified boolean predicate. This function is useful for filtering data dynamically and determining percentile values based only on relevant subsets of data.
You can use percentileif
to gain insights in various scenarios, such as:
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
Splunk SPL users
The percentileif
aggregation in APL works similarly to percentile
combined with conditional filtering in SPL. However, APL integrates the condition directly into the aggregation for simplicity.
ANSI SQL users
In SQL, you typically calculate percentiles using window functions or aggregate functions combined with a WHERE
clause. APL simplifies this by embedding the condition directly in the percentileif
aggregation.
Parameter | Description |
---|---|
Field | The numeric field from which to calculate the percentile. |
Percentile | A number between 0 and 100 that specifies the percentile to calculate. |
Predicate | A Boolean expression that filters rows to include in the calculation. |
The function returns a single numeric value representing the specified percentile of the Field
for rows where the Predicate
evaluates to true
.
You can use percentileif
to analyze request durations for specific HTTP methods.
Query
Output
post_p90 | get_p90 |
---|---|
1.691 ms | 1.453 ms |
This query calculates the 90th percentile of request durations for HTTP POST and GET methods.
You can use percentileif
to analyze request durations for specific HTTP methods.
Query
Output
post_p90 | get_p90 |
---|---|
1.691 ms | 1.453 ms |
This query calculates the 90th percentile of request durations for HTTP POST and GET methods.
You can use percentileif
to measure span durations for specific services and operation kinds.
Query
Output
Percentile95 |
---|
1.2s |
This query calculates the 95th percentile of span durations for server spans in the frontend
service.
You can use percentileif
to calculate response time percentiles for specific HTTP status codes.
Query
Output
Percentile75 |
---|
350 |
This query calculates the 75th percentile of request durations for HTTP 404 errors.
percentile
when you don’t need conditional filtering.avgif
for mean calculations instead of percentiles.minif
for identifying the lowest values within subsets.maxif
for identifying the highest values within subsets.sumif
for conditional total calculations.This page explains how to use the percentileif aggregation function in APL.
The percentileif
aggregation function calculates the percentile of a numeric column, conditional on a specified boolean predicate. This function is useful for filtering data dynamically and determining percentile values based only on relevant subsets of data.
You can use percentileif
to gain insights in various scenarios, such as:
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
Splunk SPL users
The percentileif
aggregation in APL works similarly to percentile
combined with conditional filtering in SPL. However, APL integrates the condition directly into the aggregation for simplicity.
ANSI SQL users
In SQL, you typically calculate percentiles using window functions or aggregate functions combined with a WHERE
clause. APL simplifies this by embedding the condition directly in the percentileif
aggregation.
Parameter | Description |
---|---|
Field | The numeric field from which to calculate the percentile. |
Percentile | A number between 0 and 100 that specifies the percentile to calculate. |
Predicate | A Boolean expression that filters rows to include in the calculation. |
The function returns a single numeric value representing the specified percentile of the Field
for rows where the Predicate
evaluates to true
.
You can use percentileif
to analyze request durations for specific HTTP methods.
Query
Output
post_p90 | get_p90 |
---|---|
1.691 ms | 1.453 ms |
This query calculates the 90th percentile of request durations for HTTP POST and GET methods.
You can use percentileif
to analyze request durations for specific HTTP methods.
Query
Output
post_p90 | get_p90 |
---|---|
1.691 ms | 1.453 ms |
This query calculates the 90th percentile of request durations for HTTP POST and GET methods.
You can use percentileif
to measure span durations for specific services and operation kinds.
Query
Output
Percentile95 |
---|
1.2s |
This query calculates the 95th percentile of span durations for server spans in the frontend
service.
You can use percentileif
to calculate response time percentiles for specific HTTP status codes.
Query
Output
Percentile75 |
---|
350 |
This query calculates the 75th percentile of request durations for HTTP 404 errors.
percentile
when you don’t need conditional filtering.avgif
for mean calculations instead of percentiles.minif
for identifying the lowest values within subsets.maxif
for identifying the highest values within subsets.sumif
for conditional total calculations.