> 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/pivot-table/summarize-pipeline-by-stage-and-quarter.md).

# Summarize Pipeline by Stage and Quarter

Build a pivot table of this year's opportunities, stages down the side and quarters across the top, so a manager reads pipeline without running a report.

Every Monday, a sales manager asks the same question: how much pipeline sits in each stage, and in which quarter is it expected to close? A Pivot Table answers it on a Lightning Page, with one row per stage, one column per quarter, and the amount and number of deals in each cell.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2Fn01Uc5rY3ORJUQ141P2V%2Fpivot-table-summarize-pipeline-by-stage-and-quarter-result.png?alt=media" alt="Pipeline pivot table with one row per stage, one column group per quarter of this year showing amount and deal count, and grand totals"><figcaption><p>Pipeline and number of deals for each stage and quarter of this year.</p></figcaption></figure>

## Before you start

* Opportunities with **Amount**, **Stage** and **Close Date** filled in. The steps use the standard fields only, so any org with opportunity data works.
* Access to the Avonni Dynamic Components app. If you have never built a component, start with the [Quickstart Guide](https://docs.avonnicomponents.com/dynamic-components/getting-started/quickstart-guide.md).

## Steps

{% stepper %}
{% step %}

### Add a Pivot Table to a new component

1. Create a Dynamic Component and name it `Pipeline by Stage and Quarter`.
2. Drag **Pivot Table** from the component library onto the canvas.
3. Select it. The **Edit Pivot Table** panel opens on the right, on the **Properties** tab.
   {% endstep %}

{% step %}

### Query this year's opportunities

1. In the data source part of the panel, create a new query. See [Query](https://docs.avonnicomponents.com/dynamic-components/component-builder/data-sources/query.md) if you have never built one.
2. **Object**: **Opportunity**.
3. Add two filter conditions: **Close Date** equals `THIS_YEAR`, and **Amount** greater than `0`.
4. Save the query.

*Why:* deals without an amount add rows to the counts and nothing to the sums. The Pivot Table query has no sort or limit settings.
{% endstep %}

{% step %}

### Put the stages in the rows

1. In **Data Mappings**, add an item to **Group Rows**.
2. **Field**: **Stage**.

Each stage present in the records becomes a row.
{% endstep %}

{% step %}

### Put the quarters in the columns

1. Add an item to **Group Columns**.
2. **Field**: **Close Date**.
3. **Group**: **Year-Quarter**. This setting appears as soon as the field is a date.

*Note:* **Year-Quarter** keeps the year in the header, so the columns stay correct when the query covers more than one year.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2F4FAbVs6kHOyAgiwj3FNW%2Fpivot-table-summarize-pipeline-by-stage-and-quarter-mapping.png?alt=media" alt="Pivot Table data mapping with Stage in Group Rows, Close Date grouped by Year-Quarter in Group Columns, and Amount and Id in Aggregations" width="320"><figcaption><p>The Group setting appears as soon as the field is a date.</p></figcaption></figure>
{% endstep %}

{% step %}

### Add the amount and the number of deals

1. Add an item to **Aggregations**: **Field** **Amount**, **Measure** **Sum** (the default).
2. Add a second item: **Field** **Id**, **Measure** **Count**.
3. On the second item, turn on **Custom Label** and set **Label** to `Deals`.

Each quarter now shows two values per stage: the pipeline and the number of deals. Their headers read **Sum Amount** and **Count Deals**.
{% endstep %}

{% step %}

### Turn on the totals

1. Open the **Content** section.
2. Turn on **Show Grand Total**: a total row closes the table and a total column closes each row.
3. Leave **Show Subtotals** off. It needs a second group on rows or columns, which this table does not have.
4. Try **Stacked Summaries** on and off. It changes how **Sum Amount** and **Count Deals** sit next to each other in each quarter. Keep the layout your managers read faster.
   {% endstep %}

{% step %}

### Give the table a title

1. Open the **Header** section.
2. **Title**: `Pipeline by Stage and Quarter`.
3. **Caption**: `Close dates this year`.
   {% endstep %}

{% step %}

### Save and test

1. Click **Save**.
2. Place the component on a Lightning Page: in the Lightning App Builder, drag **AX - Dynamic Component** onto the page and select `Pipeline by Stage and Quarter`. See [Publishing your Dynamic Components](https://docs.avonnicomponents.com/dynamic-components/core-concepts/publishing-your-dynamic-components.md).

The page shows the title and caption, the stages down the left side, and this year's quarters across the top. Each cell holds the summed amount and the number of deals for that stage and quarter, and the last row and column hold the totals.
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>There is no Group setting under Close Date</summary>

**Group** only appears for a date or date/time field. Check that the item's **Field** is **Close Date** and not a text or formula field holding a date.

</details>

<details>

<summary>Show Subtotals changes nothing</summary>

Subtotals need more than one group on one side. Add a second item to **Group Rows**, for example **Lead Source** under **Stage**, to get a subtotal per stage.

</details>

<details>

<summary>The table is empty for a colleague</summary>

The query runs with the permissions of the person viewing the page. Check that they can read opportunities and the **Amount** field, and that they can see the records.

</details>

## Related tutorials

* [Group Revenue by Month](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/pivot-table/group-revenue-by-month.md): month columns with full month names.
* [Filter and Export a Pivot Table](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/pivot-table/filter-and-export-a-pivot-table.md): header filters and an Excel export.


---

# 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/pivot-table/summarize-pipeline-by-stage-and-quarter.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.
