---
schema_version: "1"
id: 72ca9c0067a6a8a1523c56107cb1eaf2cff3be1b8e1094d4636db13e8a2f9af7
title: avg() or average()
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/concept/bi-saql-fn-agg-avg.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-avg.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: f50f989b77fdc518bd5040557933668cdc0d4ec346167dcd57c35416ffebb6bf
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# 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()](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-med.md)
