# Metric

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FlpLP7EWStuaDjtEuZVGp%2Fimage%20(52).avif?alt=media&#x26;token=3aee43af-13a6-4c07-b768-9c7c5db4f09f" alt="" width="375"><figcaption></figcaption></figure>

***

## Tutorials

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><strong>Introduction 101 [VIDEO]</strong></td><td></td><td></td><td><a href="https://flow.avonnicomponents.com/tutorials/components/metric/introduction">https://flow.avonnicomponents.com/tutorials/components/metric/introduction</a></td><td><a href="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2Fy6J8VOu9ge9M1HJywxRb%2Fmodern%20(26).png?alt=media&#x26;token=d0f5e27a-bc28-4188-b17a-aad5e5bc2433">modern (26).png</a></td></tr><tr><td><strong>Building a Dynamic Map with reactive metrics</strong></td><td></td><td></td><td><a href="https://app.gitbook.com/s/dHOej9Pd5IxJNGEJMZKW/flow-components/data-display-and-interaction/dynamic-map">Dynamic Map</a></td><td><a href="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FeoAyaClzqauRid9WTQD4%2Fimage%20(20).avif?alt=media&#x26;token=f1b39f18-d4bb-4070-80f4-b9e3d33182b7">image (20).avif</a></td></tr><tr><td><strong>Build a Reactive Metrics Dashboard using the Avonni Metric and Data Table [VIDEO]</strong></td><td></td><td></td><td><a href="https://youtu.be/sRtkMi2Mmqg">https://youtu.be/sRtkMi2Mmqg</a></td><td><a href="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FFImC6GxxpLqM1yq7f9v6%2Fmodern%20(25).png?alt=media&#x26;token=8dd7c881-4d2f-4e2b-bda4-2da5e1aa02af">modern (25).png</a></td></tr><tr><td><strong>Build a user activity report</strong></td><td></td><td></td><td><a href="https://app.gitbook.com/s/dHOej9Pd5IxJNGEJMZKW/flow-components/data-display-and-interaction/user-activity-report">User Activity Report</a></td><td><a href="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2F16ut9zEQZ6o0ARXWo4DU%2FDesign%20sans%20titre%20(52).png?alt=media&#x26;token=032f44cb-051d-4df7-8959-6bebe249f34c">Design sans titre (52).png</a></td></tr></tbody></table>

***

## Configuring the Metric component&#x20;

### **Adding Data to the Metric Component**

You can customize the information displayed in the Metric component by providing the following values:

* **Value:** This is the primary, prominent number displayed in the component.
* **Secondary Value:** Use this to show an additional number following to the primary value (useful for comparisons or supplementary data).
* **Description:** Include a brief text description to give more context to the values shown

### Connect Salesforce Data

The Metric component can display data from various sources: enter values directly, connect to existing Salesforce records, or build custom queries for complex calculations.

<table><thead><tr><th width="135">Name</th><th>Description</th></tr></thead><tbody><tr><td><a href="../component-builder/data-sources/manual"><strong>Manual</strong></a></td><td>This is the simplest option for displaying fixed locations. You can manually enter the latitude and longitude coordinates for each marker.</td></tr><tr><td><a href="../component-builder/data-sources/variable"><strong>Variable</strong></a></td><td>It is ideal for displaying locations that change based on data within your Salesforce flow. You can link the marker coordinates to flow variables, allowing for dynamic updates as the flow progresses.</td></tr><tr><td><a href="../component-builder/data-sources/query"><strong>Query</strong></a></td><td>The most versatile option lets you pull data directly from Salesforce objects. This is ideal for displaying metrics based on an aggregate function.</td></tr></tbody></table>

#### Query Data Source configuration

The Query Data Source in the Metric component displays values calculated directly from your Salesforce data.&#x20;

Here's how it works:

* **Define Your Query:** Write a query that targets a specific Salesforce object (like the Opportunity object) and selects the field you want to work with (like the Amount field).
* **Apply an Aggregate Function:** Choose an aggregate function (e.g., sum, average, count) to perform a calculation on the selected field. In the example, the 'sum' function would calculate the total value of all opportunities.
* **Connect the Query to the Metric Component:** Link the query you created to the Metric component's Query Data Source.

**The Avonni Metric component will now dynamically display the result of your query, providing real-time insights into your Salesforce data.**

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2Fz1o5AKc6Ty527oP6E8HP%2F2024-04-19_11-49-59%20(1).gif?alt=media&#x26;token=0f52e337-7bed-4624-99a5-63993ac25c19" alt=""><figcaption></figcaption></figure>

***

## Adding Interactions

The Avonni Metric component supports interactions on both the primary and secondary metrics. This lets you make your metrics more dynamic and user-friendly by letting users take action directly from the metrics.

Here's how you can add interactions:

1. **Select the Metric:** Choose the primary or secondary metric within your Avonni Metric component.
2. **Configure the Interaction:** In the properties panel, you'll find a new section for configuring interactions.
3. **Choose an Action:** Select the type of action you want to trigger. Options may include:
   * **Navigate to Page:** Redirect the user to a specific page within your application.
   * **Open Flow:** Launch another flow to provide more detailed information or to guide the user through a process.
   * **And More:** Explore the options to find the best fit for your use case.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2Fq0TEmzjii2CKpYOzbvS6%2Fimage%20(28).avif?alt=media&#x26;token=c9950927-b419-47a5-9f64-9c830e345d37" alt=""><figcaption></figcaption></figure>

***

## Styling the Metric

From the Styles panel, you can customize styling attributes for the Metric component:&#x20;

* **`Label`**: to customize the label that is displayed on top of the data.
* **`Description`**: to customize the additional text that is displayed below the label.
* **`Value`**: to customize the look and feel of each item text.
* **`Prefix`**: if any, customize the style of the Prefix metric.
* **`Suffix`**: if any, customize the style of the Suffic metric.
* **`Secondary Value`**: if any, customize the style of the Secondary Value
* **`Secondary Prefix`**: if any, customize the style of the Secondary Prefix
* **`Trend`**: to customize trend colors
* **`Secondary Trend`**: to customize secondary trend colors

{% hint style="info" %}
If "Show Trend Color" is activated, it overrides the related metrics' styling settings. <img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FsYctS7jXTDwlI3xt1Pv5%2F2022-10-25_11-53-12.png?alt=media&#x26;token=ff5f50fd-e1c5-4218-86a6-00b8fee3232a" alt="" data-size="line">
{% endhint %}

***
