> ## Documentation Index
> Fetch the complete documentation index at: https://www.domo.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Group and Aggregate Data in App Components

export const BetaNote = ({generic = false}) => <Note>
    <strong>Note:</strong>{" "}
    {generic ? "" : "This feature is in beta. "}
    Beta Program participants can enable features{" "}
    <a href="https://embed.domo.com/embed/pages/DQ8Ek">here</a>. To join the
    Beta Program, fill out{" "}
    <a href="https://embed.domo.com/embed/pages/BP6Eo">this form</a>. For beta
    questions or feedback, email{" "}
    <a href="mailto:beta.admin@domo.com">beta.admin@domo.com</a>.
  </Note>;

<BetaNote />

## Intro

This article explains how to group and aggregate data in an app component with a Number widget, and how to use a component header to add KPIs, resize the Search and Sort buttons, and add other widgets.

To place a component and power it from a DataSet first, see [Create and Customize App Components in App Studio](/docs/s/article/000005864).

***

## Required Grants

To access app components, the following grants must be enabled for your role:

* **Edit App (App Studio) —** Allows you to edit App Studio pages within App Studio.
* **Edit Cards —** Allows you to edit Cards in Domo.

Learn more about [grants](/docs/s/article/360043438973).

## Group and Aggregate Data in an App Component

After you power a component from a DataSet, you can group its rows by one or more columns and aggregate a column with a Number widget. This produces summarized values—such as total sales by region—directly in the component, without a Beast Mode calculation or a separate pre-aggregated DataSet.

1. In the App Studio app editor, select **Components** in the left pane, then select an app component template to start with (List, Gallery, or Grid).

   <Frame>
     <img src="https://mintcdn.com/domoinc/qedzGap4g0jWK-1b/images/kb/appcomponent-templates.png?fit=max&auto=format&n=qedzGap4g0jWK-1b&q=85&s=80489fbc0ce0e0de503b74f4679c2889" alt="The Components pane with the app component templates." width="336" height="522" data-path="images/kb/appcomponent-templates.png" />
   </Frame>
2. After you select the template, select the power icon and choose a DataSet to power the component.
3. In the left pane, select the filter icon, then select **Group by**.

   <Frame>
     <img src="https://mintcdn.com/domoinc/qedzGap4g0jWK-1b/images/kb/appcomponent-group-by.png?fit=max&auto=format&n=qedzGap4g0jWK-1b&q=85&s=9afed4a132e198cea28df4529e399832" alt="The Group by option under the filter icon in the left pane." width="381" height="1076" data-path="images/kb/appcomponent-group-by.png" />
   </Frame>
4. Select one or more columns to group by.
   The component summarizes each unique combination of the grouped columns into a single row.
5. To aggregate a column, change its widget to a **Number** widget—a Number widget aggregates the column's values, such as a sum or an average, while other widget types display the column's rows. To change a widget's type, select the widget, then in the right pane select **Widget** > **Number**.

   <Frame>
     <img src="https://mintcdn.com/domoinc/qedzGap4g0jWK-1b/images/kb/appcomponent-number-widget.png?fit=max&auto=format&n=qedzGap4g0jWK-1b&q=85&s=2dfbef6d44f3f3c04a04363e630cf43f" alt="Changing a widget to a Number widget in the right pane." width="344" height="725" data-path="images/kb/appcomponent-number-widget.png" />
   </Frame>
6. Save your app component.

## Sort by an Aggregated Value

After you group and aggregate a component, you can sort it by an aggregated value—for example, Sales from high to low.

1. In the left pane, select the filter icon.
2. Select **Sort** at the top.

   <Frame>
     <img src="https://mintcdn.com/domoinc/qedzGap4g0jWK-1b/images/kb/appcomponent-sort.png?fit=max&auto=format&n=qedzGap4g0jWK-1b&q=85&s=0b8c730f8d643f044604befecc38f9df" alt="The Sort option at the top of the filter panel." width="380" height="541" data-path="images/kb/appcomponent-sort.png" />
   </Frame>
3. Select the column, then select the arrow to choose the aggregation to sort by.
4. Select the aggregation and the sort order.

   <Frame>
     <img src="https://mintcdn.com/domoinc/qedzGap4g0jWK-1b/images/kb/appcomponent-sort-order.png?fit=max&auto=format&n=qedzGap4g0jWK-1b&q=85&s=bdde1ff0bb1d62d7c92e2e440cd238a9" alt="Selecting the aggregation and sort order for a grouped component." width="381" height="792" data-path="images/kb/appcomponent-sort-order.png" />
   </Frame>

The component sorts by the grouped, aggregated value.

<Note>**Note:** You can apply one level of sort.</Note>

## Add a Header to Your Component

A List, Gallery, or Grid component has a header at the top that works as a container for supporting content. Use the header to add KPIs above the component, resize the Search and Sort buttons, and add other widgets.

In a component header, you can:

* **Add KPIs above the component —** place KPI metrics above a List, Gallery, or Grid to summarize the data below. To build the KPIs, see [Create a KPI Component in App Studio](/docs/s/article/Create-a-KPI-Component-in-App-Studio).
* **Resize the Search and Sort buttons —** adjust the width and height of the Search and Sort buttons in the header.
* **Add other widgets —** add more widgets to the header alongside the search and sort controls.

To configure the header:

1. In the App Studio app editor, select the component to open its configuration panel.
2. Add the KPIs, widgets, or controls you want in the header.

   <Frame>
     <img src="https://mintcdn.com/domoinc/qedzGap4g0jWK-1b/images/kb/appcomponent-header.png?fit=max&auto=format&n=qedzGap4g0jWK-1b&q=85&s=fe83138fd5dea82fba49b48c408554d5" alt="A component header with KPIs and the Search and Sort buttons." width="1076" height="502" data-path="images/kb/appcomponent-header.png" />
   </Frame>
3. To resize the Search and Sort buttons, select a button and adjust its width and height.
4. Save your app component.

   <Frame>
     <img src="https://mintcdn.com/domoinc/qedzGap4g0jWK-1b/images/kb/appcomponent-with-header.png?fit=max&auto=format&n=qedzGap4g0jWK-1b&q=85&s=3fba34113d36a35a3ade3349439a6536" alt="An app component with a header showing KPIs above the list and the Search and Sort buttons." width="1480" height="692" data-path="images/kb/appcomponent-with-header.png" />
   </Frame>
