dcount
This page explains how to use the dcount aggregation function in APL.
The dcount
aggregation function in Axiom Processing Language (APL) counts the distinct values in a column. This function is essential when you need to know the number of unique values, such as counting distinct users, unique requests, or distinct error codes in log files.
Use dcount
for analyzing datasets where it’s important to identify the number of distinct occurrences, such as unique IP addresses in security logs, unique user IDs in application logs, or unique trace IDs in OpenTelemetry traces.
For users of other query languages
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
Usage
Syntax
Parameters
- column_name: The name of the column for which you want to count distinct values.
Returns
The function returns the count of distinct values found in the specified column.
Use case examples
In log analysis, you can count how many distinct users accessed the service.
Query
Output
distinct_users |
---|
45 |
This query counts the distinct values in the id
field, representing the number of unique users who accessed the system.
List of related aggregations
- count: Counts the total number of records in the dataset, including duplicates. Use it when you need to know the overall number of records.
- countif: Counts records that match a specific condition. Use
countif
when you want to count records based on a filter or condition. - dcountif: Counts the distinct values in a column but only for records that meet a condition. It’s useful when you need a filtered distinct count.
- sum: Sums the values in a column. Use this when you need to add up values rather than counting distinct occurrences.
- avg: Calculates the average value for a column. Use this when you want to find the average of a specific numeric field.