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

# Subtotal

Returns the subtotal for an aggregate expression or column using the specified mode and, optionally, partition/group columns.

**Category:** `aggregate`

**Syntax:**

```
Subtotal([aggregate_or_column], mode, |partition_by_column|)
```

**Returns:** `Float`

**Context Filtering:** ✗ No

## Parameters

| Name                  | Type     | Required | Description                                                                                                             |
| --------------------- | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| `aggregate_or_column` | `any`    | ✓ Yes    | The aggregate function (e.g., Sum(\[Amount])) or column to subtotal. If a column is provided, it will be used directly. |
| `mode`                | `text`   | ✓ Yes    | Subtotal mode ('grand\_total', 'column', 'row', etc.).                                                                  |
| `partition_by_column` | `column` | ✗ No     | Partition/group column for subtotal (required for some modes).                                                          |

## Validation

* Minimum parameters: 2
* Maximum parameters: 3

## Examples

```
Subtotal(Avg([Price]), "column", [ProductType])
```

Returns subtotal average price for each Product Type column.

```
Subtotal([Revenue], "column", [Region])
```

Returns subtotal of \[Revenue] column for each Region.
