take_any
This page explains how to use the take_any aggregation function in APL.
take_any returns values from an arbitrary row in each group.
Usage
Syntax
APL
Parameters
expr: An expression to return a value for.*: Returns all columns from one row, except the grouping columns.GroupingColumn(optional): A column to group the results by. If you omit it, all records form one group.
Returns
Returns values from an arbitrary row in each group. The selected row can differ between query runs.
any is a deprecated alias of take_any.
Use case examples
One value for each group
This example returns one status for each service. take_any(status) skips nulls and empty strings.
Query
APL
Output
| service | status |
|---|---|
| checkout | 500 |
| frontend | 200 |
One complete row for each group
This example returns all columns from one row for each service, including empty values.
Query
APL
Output
| service | region | status |
|---|---|---|
| checkout | eu | |
| frontend | us | 200 |
Another run can return the checkout row with the status 500 instead.
take_any(region, status) returns both values from the same row. Separate calls, such as take_any(region), take_any(status), can select different rows.
List of related aggregations
- take_anyif: Returns a value from one arbitrary row for which a predicate is true.
- arg_max: Returns the row with the maximum value of an expression.
- arg_min: Returns the row with the minimum value of an expression.
- make_set: Returns all distinct values of an expression in the group.