dcount() (aggregation function)
Learn how to use the dcount() function to return an estimate of the number of distinct values of an expression within a group.
Calculates an estimate of the number of distinct values that are taken by a scalar expression in the summary group.
Syntax
dcount (expr[, accuracy])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| expr | string | ✔️ | The input whose distinct values are to be counted. |
| accuracy | int | The value that defines the requested estimation accuracy. The default value is 1. See Estimation accuracy for supported values. |
Returns
Returns an estimate of the number of distinct values of expr in the group.
Examples
The following example shows how many types of storm events happened in each state.
StormEvents
| summarize DifferentEvents=dcount(EventType) by State
| order by DifferentEvents
The results table shown includes only the first 10 rows.
| State | DifferentEvents |
|---|---|
| TEXAS | 27 |
| CALIFORNIA | 26 |
| PENNSYLVANIA | 25 |
| GEORGIA | 24 |
| ILLINOIS | 23 |
| MARYLAND | 23 |
| NORTH CAROLINA | 23 |
| MICHIGAN | 22 |
| FLORIDA | 22 |
| OREGON | 21 |
| KANSAS | 21 |
| … | … |
Estimation accuracy
Related content
- Aggregation function types at a glance
- dcountif() (aggregation function)
- count()
- count_distinct() (aggregation function)
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.