> 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/metric/branch-the-flow-on-a-metric-click.md).

# Branch the flow on a metric click

Make a Metric clickable so a click on the number takes the user to a screen with the records behind it, using Flow Navigation and a Decision.

Before a rep submits the weekly forecast, the first screen shows "Deals closing this week: 7". Clicking that number should open the list of those seven deals. Clicking **Next** should go on to the submit step. The Metric's click interaction moves the flow forward, and a Decision reads which way the user left the screen.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FKfK1mzcWw49XjqDVMOq0%2Fmetric-click-result.png?alt=media" alt="Avonni Metric labelled Deals Closing This Week showing 7, with the description Click to see the deals under it" width="450"><figcaption></figcaption></figure>

## Before you start

* A Metric that counts the deals closing this week. Build it like [Show a KPI from a query](https://docs.avonnicomponents.com/flow/tutorials/components/metric/show-a-kpi-from-a-query.md), with **Count** as the **Aggregate Function** and the filter `"IsClosed = false AND (CloseDate = TODAY OR CloseDate = NEXT_N_DAYS:7)"`. `NEXT_N_DAYS:7` starts tomorrow, so the `TODAY` condition keeps a deal that closes today.
* A second screen that lists those deals, for example with an Avonni Data Table, and the submit step after it.

## Steps

{% stepper %}
{% step %}

### Add a Primary Metric Click interaction

Open the Metric in the Component Builder and go to the **Interactions** tab. Under **Primary Metric Click**, add an interaction:

* **Type**: **Flow Navigation**.
* The second **Type**, which appears under it: **Next Screen**.

A value is clickable only once it has an interaction, so this step is also what turns the number into a link.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FlvjsXQFb053SE3gv9vEI%2Fmetric-click-interaction-panel.png?alt=media" alt="Metric Component Builder, Interactions tab: Primary Metric Click holds a Flow Navigation interaction, open in a popover with Type Flow Navigation and Type Next Screen" width="600"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Add a Decision after the screen

On the canvas, add a Decision right after the screen. Create an outcome `Clicked the metric`:

* **Resource**: the screen's Metric component, then **Primary Metric Clicked**.
* **Operator**: **Equals**.
* **Value**: `{!$GlobalConstant.True}`.

The default outcome covers the **Next** button.
{% endstep %}

{% step %}

### Connect the two paths

* `Clicked the metric` goes to the screen with the list of deals. Its **Previous** button brings the rep back to the forecast screen.
* The default outcome goes to the submit step.
  {% endstep %}

{% step %}

### Tell the user the number is clickable

Set **Description** to `Click to see the deals`. Nothing else on the Metric marks it as a link, and a rep who does not know will press **Next** every time.
{% endstep %}

{% step %}

### Save and test

Run the flow with **Debug**, not the Component Builder preview: the preview ignores clicks. Click the number: the next screen lists the seven deals. Go back, press **Next** instead: the flow goes to the submit step. In the **Debug** panel, the Decision shows which outcome ran.
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>Clicking the number does nothing</summary>

The value has no interaction, or you are clicking in the Component Builder preview. Add the **Primary Metric Click** interaction and test in **Debug** or in a running flow.

</details>

<details>

<summary>The Decision always takes the default path</summary>

Check that the outcome reads **Primary Metric Clicked** from the right Metric. A screen with two Metrics has two sets of outputs, and the secondary value has its own **Secondary Metric Clicked**.

</details>

## Related tutorials

* [Show a KPI from a query](https://docs.avonnicomponents.com/flow/tutorials/components/metric/show-a-kpi-from-a-query.md): the count this tutorial makes clickable.
* [Add a trend against a target](https://docs.avonnicomponents.com/flow/tutorials/components/metric/add-a-trend-against-a-target.md): color the number before the rep clicks it.
* [Use a combobox selection in a query or flow](https://docs.avonnicomponents.com/flow/tutorials/components/combobox/use-a-combobox-selection-in-a-query-or-flow.md): another way to carry a choice from one screen to the next.


---

# 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/metric/branch-the-flow-on-a-metric-click.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.
