> ## Documentation Index
> Fetch the complete documentation index at: https://docs.invoca.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Group Aggregation Functions

> Group aggregation functions, or pinned Measures, aggregate a value by a specific attribute, such as showing revenue by product.

What if you want to aggregate a value by a specific attribute — for example, show revenue by product? This is known as a grouped aggregation, also called a pinned Measure or level-based Measure. You can do this for any aggregation using the grouping functions.

Each grouping function accepts a Measure and one or more optional attributes:

```text theme={null}
formula (Measure, [attribute, attribute, ...])
```

Only the Measure value is required. If you supply both a Measure and an attribute, the function returns the aggregate of the Measure grouped by the attribute(s). Try it with only a Measure, and then with an attribute added, to see which output best fits your use case.

`group_*` functions act like their own sub-queries, aggregating a column at groupings specified in the formula, which can differ from the groupings in the search query. For example:

```text theme={null}
group_max(balance date)
```

has no groupings specified, so it's like a sub-query `max balance date`, giving you the last balance date across all balance dates.

```text theme={null}
group_max(balance date, balance date)
```

has `balance date` as a grouping, so it's like a sub-query grouped by balance date, giving you the last balance date within every segment.

<Note>
  **Note**

  [Pivot tables](/s/article/pivot-table) don't support use of group aggregation functions.
</Note>

## List of group functions

Group aggregation functions follow the naming pattern `group_<aggregation>`:

| Function             | Description                                               | Example                                     |
| :------------------- | :-------------------------------------------------------- | :------------------------------------------ |
| `group_average`      | Average of the Measure grouped by attribute(s)            | `group_average (revenue, customer region)`  |
| `group_count`        | Count of the Measure grouped by attribute(s)              | `group_count (revenue, customer region)`    |
| `group_max`          | Maximum of the Measure grouped by attribute(s)            | `group_max (revenue, customer region)`      |
| `group_min`          | Minimum of the Measure grouped by attribute(s)            | `group_min (revenue, customer region)`      |
| `group_stddev`       | Standard deviation of the Measure grouped by attribute(s) | `group_stddev (revenue, customer region)`   |
| `group_sum`          | Sum of the Measure grouped by attribute(s)                | `group_sum (revenue, customer region)`      |
| `group_unique_count` | Unique value count of a column, grouped by attribute(s)   | `group_unique_count (product, supplier)`    |
| `group_variance`     | Variance of the Measure grouped by attribute(s)           | `group_variance (revenue, customer region)` |

## Flexible aggregation

The `group_aggregate` function gives you more control over aggregation and filtering. See [Flexible aggregation functions](/s/article/flexible-aggregation-functions) to learn more.

## Where to go next

* [Cumulative functions](/s/article/cumulative-functions)
* [Moving functions](/s/article/moving-functions)
* [Flexible aggregation functions](/s/article/flexible-aggregation-functions)
* [Filtered aggregation functions](/s/article/filtered-aggregation-functions)
