---
title: distinct_count
description: |
  Returns the number of distinct, non-null values for a given expression.

  * Each unique value is counted once per group.

  !!! note
      `distinct_count` is an aggregation function and must be used with a grouping keyword such as `groupby`.

  !!! warning
      `distinct_count` isn't supported on the **High (Frequent Search)** tier. On
      `frequentsearch` data, use [`approx_count_distinct`](./approx_count_distinct.mdx)
      instead, which returns an approximate count of distinct values.
url: https://coralogix.com/docs/dataprime/language-reference/functions-reference/aggregation/distinct_count/
product: dataengine
feature: DataPrime Language
feature_id: dataprime-language
feature_identifier: dataengine/dataprime-language
last_updated: '2026-10-21'
---

# `distinct_count`

## Description

Returns the number of distinct, non-null values for a given expression.

* Each unique value is counted once per group.

Note

`distinct_count` is an aggregation function and must be used with a grouping keyword such as `groupby`.

Warning

`distinct_count` isn't supported on the **High (Frequent Search)** tier. On `frequentsearch` data, use [\`approx\_count\_distinct\`](https://coralogix.com/docs/dataprime/language-reference/functions-reference/aggregation/approx_count_distinct.md) instead, which returns an approximate count of distinct values.

## Syntax

```
distinct_count(expression: any): number
```

## Arguments

| Name         | Type  | Required | Description                                          |
| ------------ | ----- | -------- | ---------------------------------------------------- |
| `expression` | `any` | **true** | Expression whose unique, non-null values are counted |

## Example

**Use case: Count active users per application**

Suppose you want to know how many unique users have been active in a given timeframe.

### Example data

```
{ "applicationname": "checkout-service", "username": "alice" },

{ "applicationname": "checkout-service", "username": "bob" },

{ "applicationname": "checkout-service", "username": "alice" }
```

### Example query

```
groupby $l.applicationname aggregate distinct_count($d.username) as active_users
```

### Example output

| applicationname  | active\_users |
| ---------------- | ------------- |
| checkout-service | 2             |
