avg() (aggregation function)
Learn how to use the avg() function to calculate the average value of an expression.
Calculates the average (arithmetic mean) of expr across the group.
Syntax
avg(expr)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| expr | string | ✔️ | The expression used for aggregation calculation. Records with null values are ignored and not included in the calculation. |
Returns
Returns the average value of expr across the group.
Example
The following example returns the average number of damaged crops per state.
StormEvents
| summarize AvgDamageToCrops = avg(DamageCrops) by State
The results table shown includes only the first 10 rows.
| State | AvgDamageToCrops |
|---|---|
| TEXAS | 7524.569241 |
| KANSAS | 15366.86671 |
| IOWA | 4332.477535 |
| ILLINOIS | 44568.00198 |
| MISSOURI | 340719.2212 |
| GEORGIA | 490702.5214 |
| MINNESOTA | 2835.991494 |
| WISCONSIN | 17764.37838 |
| NEBRASKA | 21366.36467 |
| NEW YORK | 5.714285714 |
| … | … |
Related content
- Aggregation function types at a glance
- min() (aggregation function)
- max() (aggregation function)
- percentile(), percentiles() (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.