percentile_tdigest()
Learn how to use the percentile_tdigest() function to calculate the percentile value of an expression.
Calculates the percentile result from the tdigest results (which was generated by tdigest() or tdigest_merge())
Syntax
percentile_tdigest(expr, percentile [, typeLiteral])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| expr | dynamic | ✔️ | An expression that was generated by tdigest or tdigest_merge(). |
| percentile | real | ✔️ | The value that specifies the percentile. |
| typeLiteral | string | A type literal. If provided, the result set will be of this type. For example, typeof(long) will cast all results to type long. |
Returns
The percentile value of each value in expr.
Examples
The examples in this section show how to use the syntax to help you get started.
Maximum damage by state
This query aims to find the maximum property damage caused by storm events in each state.
StormEvents
| summarize tdigestRes = tdigest(DamageProperty) by State
| project percentile_tdigest(tdigestRes, 100)
Output
| percentile_tdigest_tdigestRes |
|---|
| 0 |
| 62000000 |
| 110000000 |
| 1200000 |
| 250000 |
Maximum damage and latest end time by state
This query aims to find the maximum property damage and the latest end time of storm events in each state.
StormEvents
| summarize tdigestRes = tdigest(DamageProperty) by State
| union (StormEvents | summarize tdigestRes = tdigest(EndTime) by State)
| project percentile_tdigest(tdigestRes, 100)
Output
| percentile_tdigest_tdigestRes |
|---|
| [0] |
| [62000000] |
| [“2007-12-20T11:30:00.0000000Z”] |
| [“2007-12-31T23:59:00.0000000Z”] |
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.