# avg() or average()

Returns the average of the values of a measure field.

## Example - Calculate the Average Amount of an Opportunity Grouped by Type

Use `avg()` to compare the average size of opportunities for each account type.

```nolang
q = load "DTC_Opportunity";
q = group q by 'Account_Type';
q = foreach q generate 'Account_Type' as 'Account_Type', avg('Amount') as 'avg_Amount';
```

**See Also**

- [median()](/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-med.md)
