> For the complete documentation index, see [llms.txt](https://sandyzeng.gitbook.io/kql/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sandyzeng.gitbook.io/kql/kql-quick-guide/my-favorites/summarize/dcount-dcountif.md).

# dcount, dcountif

The **`dcount()`** aggregation function is primarily useful for estimating the cardinality of huge sets

### Estimation accuracy <a href="#estimation-accuracy" id="estimation-accuracy"></a>

The **`dcount()`** aggregate function uses a variant of the [HyperLogLog (HLL) algorithm](https://en.wikipedia.org/wiki/HyperLogLog), which does a stochastic estimation of set cardinality. The algorithm provides a "knob" that can be used to balance accuracy and execution time per memory size:

| Accuracy | Error (%) | Entry count |
| -------- | --------- | ----------- |
| 0        | 1.6       | 212         |
| 1        | 0.8       | 214         |
| 2        | 0.4       | 216         |
| 3        | 0.28      | 217         |
| 4        | 0.2       | 218         |

```
dcount, dcountifIntuneDevices
```

```
| where TimeGenerated > ago (30d)
        and isnotempty(OS)
| summarize Count = dcount(SerialNumber, 4)
```

<figure><img src="/files/vA4lTE7xULjnF3p4R4Jz" alt=""><figcaption></figcaption></figure>

### dcountif

```
IntuneDevices
| where TimeGenerated > ago (30d)
        and isnotempty(OS)
| summarize Count = dcountif(SerialNumber, OS != 'Windows')
```

<figure><img src="/files/5RbRd0z2CbTewbHdWFHR" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sandyzeng.gitbook.io/kql/kql-quick-guide/my-favorites/summarize/dcount-dcountif.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
