The `AVG` function calculates the average value of a numeric field.

## Syntax

`AVG(X)`

### Parameters

- `X` - a field or expression that evaluates to an unaggregated number.

## How the `AVG` function works

The `AVG` function takes 1 parameter, which must be the name of a numeric field, or a numeric expression. `AVG` returns the average for all values of that field or expression.

You can't apply this function to a pre-aggregated field (Aggregation equals `Auto`), or to an expression which is the result of another aggregation function. For example, a formula such as `AVG(SUM(x))` will produce an error.

> [!NOTE]
> **Note:** This function can be applied in one of the following ways:
>
> - In a data source, change a field's Aggregation to `Average`.
> - In a report, [edit the field's aggregation](https://docs.cloud.google.com/data-studio/edit-fields-in-your-reports) in a chart.

## Examples

In these examples, the parameters passed to `AVG` are unaggregated numeric dimensions (i.e., they have an **Aggregation** type of **None** ).

| Example formula | Input | Output |
|---|---|---|
| `AVG(Latency)` | - 0.02 - 0.07 - 0.09 | 0.06 |
| `AVG(CASE WHEN My Dimension < 1 THEN.5 WHEN My Dimension >= 1 AND My Dimension < 5 THEN 1 ELSE 2 END)` | - 0 - 0.5 - 3 - 5 | 1 |

## Related resources

- [Calculated fields](https://docs.cloud.google.com/data-studio/about-calculated-fields)
- [Data Studio function list](https://docs.cloud.google.com/data-studio/function-list)