> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-poc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# average_y() | average_x()

> Calculate the average from a two-dimensional statistical aggregate for the dimension specified

<Icon icon="tag" iconType="duotone" /> Since [1.3.0][toolkit-1.3.0]

Calculate the average from a two-dimensional aggregate for the given dimension. For example, `average_y()` calculates
the average for all the values of the `y` variable, independent of the values of the `x` variable.

## Samples

Calculate the average of the integers from 0 to 100:

```sql theme={"dark"}
SELECT average_x(stats_agg(y, x))
  FROM generate_series(1, 5) y,
       generate_series(0, 100) x;
```

```
average
-----------
50
```

## Arguments

The syntax is:

```sql theme={"dark"}
average_y(
  summary StatsSummary2D
) RETURNS DOUBLE PRECISION
```

```sql theme={"dark"}
average_x(
  summary StatsSummary2D
) RETURNS DOUBLE PRECISION
```

| Name    | Type           | Default | Required | Description                                              |
| ------- | -------------- | ------- | -------- | -------------------------------------------------------- |
| summary | StatsSummary2D | -       | ✔        | The statistical aggregate produced by a `stats_agg` call |

## Returns

| Column                   | Type             | Description                                            |
| ------------------------ | ---------------- | ------------------------------------------------------ |
| average\_y \| average\_x | DOUBLE PRECISION | The average of the values in the statistical aggregate |

[toolkit-1.3.0]: https://github.com/timescale/timescaledb-toolkit/releases/tag/1.3.0
