hll_if() (aggregation function)
Learn how to use the hll_if() function to calculate the intermediate results of the dcount() function.
Calculates the intermediate results of dcount in records for which the predicate evaluates to true.
Read about the underlying algorithm (HyperLogLog) and the estimation accuracy.
Syntax
hll_if (expr, predicate [, accuracy])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| expr | string | ✔️ | The expression used for the aggregation calculation. |
| predicate | string | ✔️ | The Expr used to filter records to add to the intermediate result of dcount. |
| accuracy | int | The value that controls the balance between speed and accuracy. If unspecified, the default value is 1. For supported values, see Estimation accuracy. |
Returns
Returns the intermediate results of distinct count of Expr for which Predicate evaluates to true.
Examples
The following query results in the number of unique flood event sources in Iowa and Kansas. It uses the hll_if() function to show only flood events.
StormEvents
| where State in ("IOWA", "KANSAS")
| summarize hll_flood = hll_if(Source, EventType == "Flood") by State
| project State, SourcesOfFloodEvents = dcount_hll(hll_flood)
Output
| State | SourcesOfFloodEvents |
|---|---|
| KANSAS | 11 |
| IOWA | 7 |
Estimation accuracy
| Accuracy | Speed | Error (%) | |
|---|---|---|---|
| 0 | Fastest | 1.6 | |
| 1 | Balanced | 0.8 | |
| 2 | Slow | 0.4 | |
| 3 | Slow | 0.28 | |
| 4 | Slowest | 0.2 |
Related content
- Aggregation function types at a glance
- Using hll() and tdigest()
- hll() (aggregation function)
- hll_merge() (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.