> 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/select-an-account-to-filter-its-pipeline-chart.md).

# Select an Account to Filter Its Pipeline Chart

Connect an Account Combobox to an open-pipeline Bar chart, then test automatic query updates, account totals and an account with no open deals.

An account manager wants to inspect one account's open pipeline without opening a separate chart for every account. Connect an Avonni Combobox to a Bar chart query. Selecting an account changes the query's Account filter and automatically updates its stage totals.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FAC0Wmruth2GZV8Fjvv6h%2Ftutorial-account-filter-alpine.jpg?alt=media" alt="Account selector and Bar chart preview for Alpine open pipeline"><figcaption><p>Builder preview with Alpine selected and its open pipeline grouped by stage.</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%2FAC0Wmruth2GZV8Fjvv6h%2Ftutorial-account-filter-alpine.jpg?alt=media)

## Before You Start

* Open a Dynamic Component you can edit. You need read access to Accounts and their Opportunities.
* Use at least two accounts with open opportunities and one with no open opportunities. Keep all Amount values in one currency.
* Read [Combobox](https://docs.avonnicomponents.com/dynamic-components/components/combobox.md), [Chart](https://docs.avonnicomponents.com/dynamic-components/components/chart.md) and the reactive-query section of [Query](https://docs.avonnicomponents.com/dynamic-components/component-builder/data-sources/query.md).
* Plan to test in **Preview**. Selection changes on the editing canvas do not prove runtime filtering works.

## Steps

{% stepper %}
{% step %}

### Prepare Different Totals for Each Account

Use your own records or prepare these sandbox accounts. Give their opportunities names starting with `Chart Docs Filter Opp -` .

| Account name                      | Open stage     | Amounts          | Expected stage total |
| --------------------------------- | -------------- | ---------------- | -------------------- |
| Chart Docs Filter - Alpine        | Needs Analysis | `10000`, `30000` | `40000`              |
| Chart Docs Filter - Alpine        | Qualification  | `20000`, `40000` | `60000`              |
| Chart Docs Filter - Northstar     | Needs Analysis | `15000`, `45000` | `60000`              |
| Chart Docs Filter - Northstar     | Qualification  | `10000`, `20000` | `30000`              |
| Chart Docs Filter - No Open Deals | None           | None             | `0`                  |

Add closed controls under the opportunity prefix to check the open-only filter. The No Open Deals account can have a won opportunity of `75000`; it must still contribute no open pipeline. Record each Account's actual `Id`. Names are for people to read; the chart's relationship filter needs the Account ID.
{% endstep %}

{% step %}

### Populate an Account Combobox

Add **Combobox** from the **Component Library** above the chart. Set **Label** to `Account` and **Placeholder** to `Select an account`. Leave **Is Multi Select** off.

Use **Data Source > Query** and choose an Account query in **Records**. For this exercise, limit it to Account names starting with `Chart Docs Filter -` and sort by Name.

In **Data Mappings**, map **Label** to Account Name (`Name`) and **Value** to record ID (`Id`). Each option stores the Account ID. When a person selects it, the Combobox also publishes the selected Account record.

Leave **Content > Value** empty so this example starts without a selection. The query below uses the selected Account record, which becomes available after the person chooses an option.
{% endstep %}

{% step %}

### Bind the Chart Query to the Selection

Add **Chart**. Set **Type** to **Bar** and **Title** to `Open pipeline by stage`. Choose **Data Source > Query** and an Opportunity query in **Records**.

In **Edit the query**, combine these conditions with AND:

* The closed flag is false (`IsClosed = false`).
* Name (`Name`) starts with `Chart Docs Filter Opp -` .
* Account ID (`AccountId`) equals the selected Account record's `Id` from the Combobox.

For the **Account ID** condition, choose **Equals**. For its **Value**, open **Type of value** and choose **Mapped**. In the resource picker, choose **Components > Combobox 1 > Selected Item sObject > Id**. Search for `Id` if needed. Use your own Combobox instance if its name differs.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FHiubK37wLjS0F5gv73mr%2Ftutorial-account-filter-binding.jpg?alt=media" alt="Account ID query filter mapped to the Combobox selected Account record ID" width="480"><figcaption><p>Map Account ID to the Combobox selected record's Id.</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%2FHiubK37wLjS0F5gv73mr%2Ftutorial-account-filter-binding.jpg?alt=media)

The query directly references the selected record ID (`Combobox1.selectedItemSObject.Id`). When the selection changes, Avonni automatically re-executes the query. No **Refresh Query** interaction, Assignment or formula is needed.
{% endstep %}

{% step %}

### Sum Open Amount by Stage

In **Data Mappings > Bars**, add Stage (`StageName`) as the **Field**. In **Bar Length**, add Amount (`Amount`), set **Measures** to **Sum**, **Format Style** to **Currency Rounded** and **Multiplier** to `1`.

Keep **Normalize Values** off so bar lengths show monetary totals. A label can remain the same between accounts while its total changes. Use a chart size that leaves both the account selector and stage labels readable.

Set **No Results Message** to `No open opportunities for this account.` and hide the no-results image for a compact empty state. This message is configured for the example; it is not a default Chart message.

Click **Preview**. The selector starts empty. Choose Alpine, then check Needs Analysis totals `40000` and Qualification `60000`. Compare those values with Alpine's records only.
{% endstep %}

{% step %}

### Switch Accounts and Test No Results

In **Preview**, select Northstar. Wait for the chart query to settle, then check Needs Analysis is `60000` and Qualification is `30000`.

Select Alpine again and verify `40000` and `60000` return. This round trip checks a changing selection rather than one correct initial result.

Select No Open Deals. The chart shows `No open opportunities for this account.` with no bars or chart title. Confirm that no previous account's bars remain visible. The account's closed opportunity must not appear as open pipeline.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2F9tehXzNiqLvhNT87EPUR%2Ftutorial-account-filter-empty.jpg?alt=media" alt="Account selector preview for an account with no open opportunities"><figcaption><p>Builder preview after selecting an account with no open opportunities.</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%2F9tehXzNiqLvhNT87EPUR%2Ftutorial-account-filter-empty.jpg?alt=media)
{% endstep %}

{% step %}

### Check the Empty Selection and Save

Clear the Account selection in **Preview**. The selector returns to its placeholder and the chart shows the configured no-results message, with no stale bars. Reopen **Preview** and check the same empty state appears before the first selection. A blank selection does not mean all accounts.

Keep **Content > Value** empty and click **Save**. The figures show the Builder preview. Follow [Publishing your Dynamic Components](https://docs.avonnicomponents.com/dynamic-components/core-concepts/publishing-your-dynamic-components.md) to place the component on a Lightning Page, then repeat the selection sequence with a viewer's access.

A selection changes a query filter. It does not grant access to an Account or its Opportunities.
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>The selection changes but the chart does not</summary>

Test in **Preview**, not only on the builder canvas. Check that the query's `AccountId` condition references this Combobox's **Selected Item sObject > Id**, and that **Data Source** is **Query**. A manually typed Account ID stays fixed when the selection changes.

</details>

<details>

<summary>The chart is empty for an account with open opportunities</summary>

Check the option mapping returns Account `Id`, not `Name`. Verify the opportunity's Account ID, the open-only condition and the sample-name scope. Check the viewer can read those records. Choose an account in **Preview** before checking its totals. This example starts with an empty **Value** and uses the selected record output, rather than relying on an initial ID to populate that output.

</details>

<details>

<summary>Closed opportunities inflate the totals</summary>

Keep `IsClosed = false` alongside the reactive `AccountId` condition. The account filter limits the account; it does not decide whether an opportunity belongs to open pipeline.

</details>

## Related Tutorials

* [Compare Total and Average Deal Size](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/chart/compare-total-and-average-deal-size.md): check stage totals and average deal size over open pipeline.
* [Compare Won Revenue by Lead Source](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/chart/compare-won-revenue-by-lead-source.md): change the measure while keeping the source scope fixed.
* [Map Account Coverage by Province](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/chart/map-account-coverage-by-province.md): use Account records for a geographic view.


---

# 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/select-an-account-to-filter-its-pipeline-chart.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.
