> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/flow/tutorials/components/pivot-table/show-totals-subtotals-and-stacked-summaries.md).

# Show Totals, Subtotals and Stacked Summaries

Add a grand total, subtotals per region and two measures in one cell to a Pivot Table, so a pipeline review shows both deal value and deal count.

The pipeline grid shows how much is open per region and stage. The sales manager now wants three more things on the same screen: a subtotal for each region split by business type, the total for the whole team, and the number of deals next to their value, so one large deal does not pass for a busy region.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2F8rrZSbtEoLCbCCJpAT8n%2Fpivot-table-show-totals-subtotals-and-stacked-summaries-result.png?alt=media" alt="Pivot Table grouped by region and business type with a subtotal per region, a grand total, and each cell showing an amount above a deal count"><figcaption><p>Subtotals per region, a grand total, and value with deal count in each cell.</p></figcaption></figure>

## Before you start

* A Pivot Table on open opportunities, grouped by **Region** and **Stage**, summing **Amount**. [Show a Pipeline Summary and Drill Into Any Cell](https://docs.avonnicomponents.com/flow/tutorials/components/pivot-table/show-a-pipeline-summary-and-drill-into-any-cell.md) builds it.

## Steps

{% stepper %}
{% step %}

### Turn on the grand total

Open the Component Builder on the Pivot Table. At the top of the **Properties** tab, turn on **Show Grand Total**.

The table gets a **Total** row at the bottom and a **Total** column on the right: the pipeline per stage across all regions, and per region across all stages.
{% endstep %}

{% step %}

### Add a second row grouping

Subtotals summarize a group made of smaller groups, so the rows need a second level.

1. In **Data Mappings**, under **Group Rows**, add an item below **Region**.
2. Set **Field** to **Type**. Turn on **Custom Label** and enter `Business` as the **Label**.

The order matters: the first field is the outer group. Region first, then Type, gives one subtotal per region.
{% endstep %}

{% step %}

### Turn on subtotals

Turn on **Show Subtotals**. Each region now gets a **Subtotal** row that adds up its New Business and Existing Business lines.

The columns keep a single grouping (**Stage**), so they get no subtotal column. To get one, add a second **Group Columns** field.
{% endstep %}

{% step %}

### Count the deals beside their value

1. Under **Aggregations**, add a second item.
2. Set **Field** to **Opportunity Name** and **Aggregation** to **Count**: every opportunity has a name, so this counts the deals.
3. Turn on **Custom Label** and enter `Deals` as the **Label**.

Each stage now has two columns side by side, headed **Sum Pipeline** and **Count Deals**: the header puts the aggregation before your label.
{% endstep %}

{% step %}

### Stack the two values in one cell

Turn on **Stacked Summaries**. Each stage takes one column again, with the two values one above the other in each cell, and the measure names move into an extra column beside the row headers.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FDwWQ3pHaqpWkdtXh8qfh%2Fpivot-table-show-totals-subtotals-and-stacked-summaries-toggles.png?alt=media" alt="The Show Grand Total, Show Subtotals and Stacked Summaries toggles, all turned on" width="320"><figcaption><p>The three summary toggles, all on.</p></figcaption></figure>
{% endstep %}

{% step %}

### Save and test

Save the flow and run it.

Each region shows its two Business lines and a **Subtotal** row. The last row is the **Total** and the last column is the **Total** across stages. Every cell holds the pipeline amount with the deal count under it.
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>Show Subtotals is on, but no subtotal appears</summary>

The axis has only one grouping. Add a second field to **Group Rows** (or **Group Columns**) to get subtotals on that axis.

</details>

<details>

<summary>The subtotals group the wrong way</summary>

The first **Group Rows** field is the outer group. Reorder the items so the field you want subtotals for comes first.

</details>

<details>

<summary>Stacked Summaries changes nothing</summary>

It only has an effect with two or more **Aggregations**. With one measure, each cell already holds a single value.

</details>

## Related tutorials

* [Show a Pipeline Summary and Drill Into Any Cell](https://docs.avonnicomponents.com/flow/tutorials/components/pivot-table/show-a-pipeline-summary-and-drill-into-any-cell.md): the base grid this tutorial extends.
* [Group a Pivot Table by Date](https://docs.avonnicomponents.com/flow/tutorials/components/pivot-table/group-a-pivot-table-by-date.md): closing months or quarters across the top instead of stages.
* [Export a Pivot Table and Add Header Actions](https://docs.avonnicomponents.com/flow/tutorials/components/pivot-table/export-a-pivot-table-and-add-header-actions.md): download the grid with its totals.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avonnicomponents.com/flow/tutorials/components/pivot-table/show-totals-subtotals-and-stacked-summaries.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
