Aggregation functions
Learn how to use and combine different aggregation functions in APL.
Statistical functions
All of these functions are used in the context of Summarize operator
Function Name | Description |
---|---|
avg() | Returns an average value across the group. |
avgif() | Calculates the average value of Expr in records for which Predicate evaluates to true . |
count() | Returns a count of the group without/with a predicate. |
countif() | Returns a count of rows for which Predicate evaluates to true |
dcount() | Returns an estimate for the number of distinct values that are taken by a scalar expression in the summary group. |
dcountif() | Returns an estimate of the number of distinct values of Expr of rows for which Predicate evaluates to true. |
max() | Returns the maximum value across the group. |
maxif() | Calculates the maximum value of Expr in records for which Predicate evaluates to true. |
min() | Returns the minimum value across the group. |
minif() | Returns the minimum of Expr in records for which Predicate evaluates to true . |
sum() | Calculates the sum of Expr across the group. |
sumif() | Calculates the sum of Expr in records for which Predicate evaluates to true . |
histogram() | Returns a timeseries heatmap chart across the group. |
topk() | calculates the top values of Expr across the group in a dataset |
percentile() | calculates the requested percentiles of the group and produces a timeseries chart. |
variance() | Calculates the variance of Expr across the group. |
varienceif() | Calculates the variance of Expr in records for which Predicate evaluates to true . |
stdev() | Calculates the standard deviation of Expr across the group. |
stdevif | Calculates the standard deviation of Expr in records for which Predicate evaluates to true . |
make_list() | Creates a dynamic JSON object (array) of all the values of Expr in the group |
make_list_if() | Creates a dynamic JSON object (array) of Expr values in the group for which Predicate evaluates to true . |
make_set() | Creates a dynamic JSON array of the set of distinct values that Expr takes in the group. |
make_set_if() | Creates a dynamic JSON object (array) of the set of distinct values that Expr takes in records for which Predicate evaluates to true . |
rate() | Calculates the rate of values in a group per second. |
Each argument has a required section which is denoted with required
or optional
- If it’s denoted by
required
it means the argument must be passed into that function before it’ll work. - if it’s denoted by
optional
it means the function can work without passing the argument value.
expr
is short for expression
In APL, an expression is a combination of functions, operators, and constants used to compute a value or produce a result.
In the context of data explorer, an expression is used to define the specific data manipulation or extraction operation you want to perform on your dataset.
avg()
Calculates the average (arithmetic mean) of Expr across the group.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation |
Returns
The average value of Expr across the group.
Examples
avgif()
Calculates the average value of Expr in records for which Predicate evaluates to true
.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Predicate | string | Required | Predicate that if true, the Expr calculated value will be added to the average. |
Returns
Returns the average value of Expr in records for which Predicate evaluates to true
.
Examples
count()
Returns a count of the records per summarization group (or in total, if summarization is done without grouping).
Returns
Returns a count of the records per summarization group.
Examples
countif()
Returns a count of rows for which Predicate evaluates to true
.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Predicate | string | Required | Expression that will be used for aggregation calculation. Predicate can be any scalar expression with return type of bool (evaluating to true/false). |
Returns
Returns a count of rows for which Predicate evaluates to true.
Examples
dcount()
Returns an estimate for the number of distinct values that are taken by a scalar expression in the summary group.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | scalar | Required | A scalar expression whose distinct values are to be counted |
Returns
Returns an estimate of the number of distinct values of Expr
in the group.
Examples
dcountif()
Returns an estimate of the number of distinct values of Expr of rows for which Predicate evaluates to true.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Predicate | string | Required | Expression that will be used to filter rows. |
Returns
Returns an estimate of the number of distinct values of Expr of rows for which Predicate evaluates to true
in the group.
Example
max()
Returns the maximum value across the group.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Returns
The maximum value of Expr across the group.
Examples
maxif()
Calculates the maximum value of Expr in records for which Predicate evaluates to true
.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Predicate | string | Required | Expression that will be used to filter rows. |
Returns
Returns the maximum value of Expr in records for which Predicate evaluates to true
.
Examples
min()
Returns the minimum value across the group.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Returns
The minimum value of Expr across the group.
Example
minif()
Returns the minimum of Expr in records for which Predicate evaluates to true
.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Predicate | string | Required | Expression that will be used to filter rows. |
Returns
The minimum value of Expr in records for which Predicate evaluates to true
.
Examples
sum()
Calculates the sum of Expr across the group.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Returns
The sum value of Expr across the group.
Examples
sumif()
Calculates the sum of Expr in records for which Predicate evaluates to true
.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Predicate | string | Required | Expression that will be used to filter rows. |
Returns
Returns the sum of Expr for which Predicate evaluates to true
.
Examples
histogram()
Returns a timeseries heatmap chart across the group
Arguments
- Expr: Expression that will be used for aggregation calculation.
Returns
Returns a timeseries heatmap chart across the group
Examples
topk()
calculates the top values of Expr across the group in a dataset
Arguments
- Expr: Expression that will be used for aggregation calculation.
Returns
- A separate result for each group plotted on a timeseries chart.
Examples
percentile(), percentiles_array()
Calculates the requested percentile of the group and produces a timeseries chart.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Percentile | double | Required | A constant that specifies the percentile. |
Returns
A separate result for each group plotted on a horizontal bar chart, allowing for visual comparison across the groups.
Examples
variance()
Calculates the variance of Expr across the group.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Returns
The variance value of Expr across the group.
Examples
varienceif()
Calculates the variance of Expr in records for which Predicate evaluates to true
.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Predicate | string | Required | Predicate that if true, the Expr calculated value will be added to the variance. |
Returns
Returns the variance value of Expr in records for which Predicate evaluates to true
.
Examples
stdev()
Calculates the standard deviation of Expr across the group.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Returns
The standard deviation value of Expr across the group.
Examples
stdevif()
Calculates the standard deviation of Expr in records for which Predicate evaluates to true
.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculation. |
Predicate | string | Required | Predicate that has to evaluate to true , in order for Expr to be added to the result. |
Returns
Returns the standard deviation value of Expr in records for which Predicate evaluates to true
.
Examples
make_list()
Creates a dynamic
JSON object (array) of all the values of Expression in the group.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | dynamic | Required | Expression that will be used for aggregation calculations. |
MaxSize | integer | Optional | The limit on the maximum number of elements returned. |
Returns
Returns a dynamic
JSON array of all the values of Expr in the group.
Examples
make_list_if()
Creates a dynamic
JSON object (array) of Expr values in the group for which Predicate evaluates to true
.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculations. |
Predicate | string | Required | Predicate that has to evaluate to true , in order for Expr to be added to the result. |
MaxSize | integer | Optional | The limit on the maximum number of elements returned. |
Returns
Returns a dynamic
JSON object (array) of Expr vlaues in the group for which Predicate evaluates to true
.
Examples
make_set()
Creates a dynamic
JSON array of the set of distinct values that Expression takes in the group.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculations. |
MaxSize | integer | Optional | The limit on the maximum number of elements returned. |
Returns
Returns a dynamic
JSON array of the set of distinct values that Expr takes in the group. The array’s sort order is undefined.
Example
make_set_if()
Creates a dynamic
JSON object (array) of the set of distinct values that Expr takes in records for which Predicate evaluates to true
.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | string | Required | Expression that will be used for aggregation calculations. |
Predicate | string | Required | Predicate that has to evaluate to true , in order for Expr to be added to the result. |
MaxSize | integer | Optional | The limit on the maximum number of elements returned. |
Returns
Returns a dynamic
JSON object (array) of the set of distinct values that Expr takes in records for which Predicate evaluates to true
.
Example
rate()
Calculates the rate of values in a group per second.
Arguments
Name | Type | Required or Optional | Description |
---|---|---|---|
Expression | The column can contain one of the following data types: integer, float, or timespan | Required | Expression that will be used for aggregation calculation. |
Returns
Returns the rate of X
per second, as a float.
X = Column with summable data (i.e. request duration, file size, $ spent, etc.)
Tip: If you want to see the rate of events, use Rate(1).