> 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/chart/compare-total-and-average-deal-size.md).

# Compare Total and Average Deal Size

Build a Combo chart that compares open pipeline totals with average deal size by stage, then verify its measures against the source records.

A stage with a large pipeline total can contain many small deals or a few large ones. Use an Avonni Combo chart to put the total and average Amount side by side for each open opportunity stage.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FVFrObD4Iq6oFuAAhg3CS%2Fchart-combo-result.jpg?alt=media" alt="Combo chart preview with blue total Amount bars and an orange average Amount line by stage"><figcaption><p>Builder preview using sample opportunities. Needs Analysis totals 40,000 with an average of 20,000; closed opportunities are excluded.</p></figcaption></figure>

[View this capture at full size](https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FVFrObD4Iq6oFuAAhg3CS%2Fchart-combo-result.jpg?alt=media)

## Before You Start

* Open a Dynamic Component you can edit, or follow [Creating a new component](https://docs.avonnicomponents.com/dynamic-components/avonni-components-app/creating-a-new-component.md).
* You need access to Opportunity records and their Stage, Amount, Account and closed status. Use one currency for this exercise so the two measures are comparable.
* Choose a small set of opportunities whose amounts you can check. The sample below uses six open opportunities belonging to one sample Account, plus one closed opportunity to test the filter.
* See the [Chart reference](https://docs.avonnicomponents.com/dynamic-components/components/chart.md) for all properties and [Query](https://docs.avonnicomponents.com/dynamic-components/component-builder/data-sources/query.md) for filter setup. Avonni groups and measures the returned records; Salesforce access rules determine which records you can read.

## Steps

{% stepper %}
{% step %}

### Define the Records You Will Compare

Use your own records, or prepare sample opportunities in a sandbox with these open-stage values:

| Stage                | Amount values    | Expected sum | Expected average |
| -------------------- | ---------------- | ------------ | ---------------- |
| Needs Analysis       | `10000`, `30000` | `40000`      | `20000`          |
| Qualification        | `20000`, `40000` | `60000`      | `30000`          |
| Proposal/Price Quote | `50000`, `70000` | `120000`     | `60000`          |

Keep the six records under one sample Account. Give sample record names the prefix `Chart Docs -` so you can identify them. The captured sample also has a closed-won opportunity for `100000`; it must not appear in the open pipeline.

For your own records, write down one stage's individual amounts before configuring the chart. You will use them to check both calculations.
{% endstep %}

{% step %}

### Add a Combo Chart and Limit Its Query

Add **Chart** from the **Component Library** and select it on the canvas. In **Edit Chart > Properties > Content**, set **Type** to **Combo**.

In **Data Source**, select **Query**. In **Records**, choose or create an Opportunity query. Use **Edit the query** to check its conditions:

| Query requirement  | Set it to                                                 |
| ------------------ | --------------------------------------------------------- |
| Object             | Opportunity                                               |
| Open opportunities | The closed flag is false (`IsClosed = false`)             |
| Sample scope       | Account (`AccountId`) equals the sample Account you chose |

Combine the two conditions with AND. For a live pipeline, replace the sample Account condition with your intended business scope while keeping the open-opportunity condition.

Do not change a query shared with other components unless they should use the same filters.
{% endstep %}

{% step %}

### Group by Stage and Add Both Calculations

Open **Data Mappings > X-Axis**. Add Stage (`StageName`) as the **Field** and leave **Group** unset.

Open **Y-Axis** and add two entries using Amount (`Amount`):

| Entry order | Measures | Display As | Meaning                                    |
| ----------- | -------- | ---------- | ------------------------------------------ |
| First       | Sum      | Bar        | Total open pipeline in the stage           |
| Second      | Average  | Line       | Average populated deal amount in the stage |

Open each Y-Axis row to set **Display As**. Leave **Treat Blank Value As Zero** off in both entries for this example.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2F2sSsGZLCzcXiN78H3ywG%2Fchart-combo-y-axis.jpg?alt=media" alt="Combo Y-Axis entry with Amount, Average and Display As Line" width="480"><figcaption><p>Open a Y-Axis row to set its measure and Display As. This second Amount entry draws the average as a line.</p></figcaption></figure>

[View this capture at full size](https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2F2sSsGZLCzcXiN78H3ywG%2Fchart-combo-y-axis.jpg?alt=media)

Combo uses its own entry editor. It offers **Measures**, **Treat Blank Value As Zero** and **Display As**, without **Format Style**, **Format** or **Multiplier**.
{% endstep %}

{% step %}

### Make the Two Measures Readable

In **Content**, set **Title** to `Open pipeline: total and average deal size`.

In **Legend**, turn on **Show Legend** and set **Position** to **Bottom**. In **Content > Custom Palette**, add `#0176d3` first and `#f28b00` second. The first measure becomes blue and the second orange. A custom list takes priority over **Palette**.

In **Style > Size**, set **Height** to `400 px`. The sample uses a width of `760 px`; check that the stage labels and legend remain readable in the space where you will place the chart.
{% endstep %}

{% step %}

### Check the Arithmetic and Interpret the Difference

Compare one stage with the source records. For Needs Analysis, `10000 + 30000 = 40000`; dividing by two populated amounts gives `20000`. The bar and line must match those two values.

Check all three sample stages against the table. The open total is `220000`. The closed-won opportunity for `100000` must be excluded.

A higher bar means more pipeline value. A higher line means a larger average deal amount. The average does not tell you how many deals a stage contains; check the source record count before drawing that conclusion.

If your records contain a blank Amount, review the blank-value rule. With `10000`, `30000` and one blank, **Treat Blank Value As Zero** off gives an average of `20000`. Turning it on includes the blank as zero and gives about `13333.33`. Test this only in a sandbox with your own sample records, then restore the intended setting.
{% endstep %}

{% step %}

### Save and Test

Click **Preview** and repeat the arithmetic check. The screenshots show the Builder preview with sample records, not a completed deployment to a Lightning Page.

Click **Save**. When you are ready to share your own component, follow [Publishing your Dynamic Components](https://docs.avonnicomponents.com/dynamic-components/core-concepts/publishing-your-dynamic-components.md) to activate the version and place it on a Lightning Page.

Check the page with a person who will use it. Queries run with the viewing person's object access, field access and sharing, so their totals can differ from yours.
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>Both measures look like lines or bars</summary>

Open each **Y-Axis** entry. Set the Sum entry's **Display As** to **Bar** and the Average entry's **Display As** to **Line**. Changing the chart's **Type** alone does not choose a different rendering for each entry.

</details>

<details>

<summary>The average is lower than the value you calculated</summary>

Check the query's records and **Treat Blank Value As Zero**. Count populated Amount values when the setting is off. Count every included record when it is on. Also confirm that the second entry uses **Average**, rather than **Sum** or **Count**.

</details>

<details>

<summary>The totals include closed deals or unrelated accounts</summary>

Check both query conditions and their AND relationship. Use the same filter in your independent record check. A correct Y-Axis mapping cannot compensate for a query that includes the wrong records.

</details>

<details>

<summary>The colors do not match the legend you expected</summary>

Check the Y-Axis entry order and **Custom Palette** order. Colors follow the series order. **Item Order** changes legend reading order without changing which color belongs to each series.

</details>

## Related Tutorials

* [Track Won Revenue by Month](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/chart/track-won-revenue-by-month.md): compare closed-won totals over time using a Line chart.
* [Map Account Coverage by Province](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/chart/map-account-coverage-by-province.md): count customer records by geography.
* [All Chart tutorials](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/chart.md): choose another question to answer with Chart.


---

# 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/chart/compare-total-and-average-deal-size.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.
