> 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/dynamic-components/tutorials/components/data-table/add-subtotals-and-totals.md).

# Add Subtotals and Totals

Show the pipeline amount of each stage and a grand total row in a grouped Data Table, so a manager no longer exports the rows to a spreadsheet.

A sales manager wants to know how much pipeline sits in each stage, and how much in total, without exporting the table to a spreadsheet. With **Summarize By** on the **Amount** column, the table adds the total of each stage to its group and a grand total row at the bottom.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FHTNyxgH5QOVNZVi1Ei0W%2Fdata-table-tutorial-add-subtotals-and-totals-result.png?alt=media" alt="The grouped pipeline table with Sum $54,000.00 to Sum $507,000.00 on the right of each stage header and a final row reading Sum $1,639,000.00"><figcaption><p>Each stage shows the sum of its amounts, and the last row the total for all stages.</p></figcaption></figure>

## Before you start

* A Data Table with a **Query** data source on Opportunity, with at least **Opportunity Name**, **Stage** and **Amount** as columns. See [Data Table](/dynamic-components/components/data-table.md).
* For subtotals, the table must be grouped. Follow [Configuring Data Grouping](/dynamic-components/tutorials/components/data-table/configuring-data-grouping.md) first and group by **Stage**. Without grouping you still get one total row.
* The column to summarize must use the **Currency**, **Number** or **Percent** type. **Summarize By** is not offered on other types.

## Steps

{% stepper %}
{% step %}

### Open the Amount column

1. Select the Data Table on the canvas.
2. In **Data Mappings**, open **Columns** and click the **Amount** column.
3. Check that **Type** is **Currency**. A currency field gets this type by default.
   {% endstep %}

{% step %}

### Choose how to summarize

In the column's **Type Attributes**, set **Summarize By**:

| Value       | What the row shows         | Use it for                   |
| ----------- | -------------------------- | ---------------------------- |
| **Sum**     | The total of the column    | Pipeline amount per stage    |
| **Average** | The mean of the values     | Average deal size            |
| **Count**   | How many rows have a value | Deals with an amount entered |

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2F5ZBr0CDjnspACs7SR8MN%2Fdata-table-tutorial-add-subtotals-and-totals-column-panel.png?alt=media" alt="The Amount column settings popover in the builder: Source Field Amount, Type Currency, and under Type Attributes, Summarize By set to Sum and Treat Blank Values As Zero off" width="320"><figcaption><p>Summarize By is in the column's Type Attributes, available on Currency, Number and Percent columns.</p></figcaption></figure>
{% endstep %}

{% step %}

### Decide what a blank amount means

By default, a blank value is skipped. Turn on **Treat Blank Values As Zero** to count it as 0 instead.

This changes **Average** and **Count** only. Five deals worth 100,000 in total, one of them without an amount, average 25,000 with the setting off and 20,000 with it on.
{% endstep %}

{% step %}

### Keep or hide the grand total

On a grouped table, each group shows its subtotal and a grand total row closes the table. If the manager only needs the per stage figures, open the **Group By** section of the Properties panel and turn on **Hide Grand Total**.
{% endstep %}

{% step %}

### Save and test

Save and open the page. Each stage shows the sum of its amounts after the word `Sum`, and the last row shows the sum for all stages. Collapse a stage: its subtotal stays visible on the group.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
You can summarize several columns in the same table, each with its own method: **Sum** on **Amount** and **Average** on **Probability (%)**, for example.
{% endhint %}

## Troubleshooting

<details>

<summary>The total did not change after I edited or added a record</summary>

On a table with a **Query** data source, the total row can keep its previous value after a record is created or edited, even after the table refreshes. Reload the browser page to recompute it. This is a known issue.

</details>

<details>

<summary>Can the row say "Total" instead of "Sum"?</summary>

No. The label in front of the value is fixed: `Sum`, `Avg` or `Count`, in English, whatever the user's language. There is no setting to change or translate it today.

</details>

<details>

<summary>Summarize By does not appear</summary>

The column type is not **Currency**, **Number** or **Percent**. A number stored in a text field cannot be summarized: change the column's source field, or create a number formula field on the object.

</details>

## Related tutorials

* [Configuring Data Grouping](/dynamic-components/tutorials/components/data-table/configuring-data-grouping.md): build the stage groups that carry the subtotals.
* [Apply Conditional Cell Styling](/dynamic-components/tutorials/components/data-table/apply-conditional-cell-styling.md): highlight the large deals inside each stage.
* [Enable Data Export](/dynamic-components/tutorials/components/data-table/enable-data-export.md): when the manager still needs the rows in a spreadsheet.


---

# 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/dynamic-components/tutorials/components/data-table/add-subtotals-and-totals.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.
