Power Apps Data Table Group By [With Examples]

If you want to group the Power Apps data table records, you can easily do that using the Power Apps GroupBy() function.

In this Power Apps tutorial, I will explain the Power Apps data table group with real-time examples like:

  • Power Apps Data Table Group By Column
  • How to group Power Apps data table using multiple columns
  • Working with Power App data table group by filter
  • Power App Data Table Group By Sum
  • How to ungroup the Power Apps data table

Power Apps Data Table Group By

We can group the Power Apps data table to organize our data based on specific requirements. For example, you can group a list of Project tasks by their status (e.g., “In Progress,” “Completed,” “Pending”) to provide a more structured and organized view for better understanding.

Using the GroupBy() function in the Power Apps Data table, you can easily group data based on one or more columns in your data source [SharePoint, Excel, Collection, etc…].

Power Apps GroupBy() Syntax:

GroupBy(Table, ColumnName1[ColumnName2, ... ], GroupColumnName)

Where,

  • Table = It is required, and it will be grouped
  • ColumnName (s) = We can create a group based on the column names
  • GroupColumnName = It stores the group records like a nested table

If you want more information about grouping the Power Apps data table, follow the scenarios below. Such as:

  1. Power Apps Data Table Group By Column
  2. How to Group the Power Apps Data Table using Multiple Columns
  3. Power App Data Table Group By Filter
  4. Power App Data Table Group By Sum
  5. Working with Power Apps Data Table UnGroup

Let me explain one by one.

Power Apps Data Table Group By Column

I have a SharePoint Online list [Expense Tracker], this list contains the different columns with various data types.

Input:

Column NameData Type
Expense NameIt is a default single line of text column
Expense TypeChoice
BudgetChoice
AmountNumber
Power Apps Data Table GroupBy

I want to group this text field [Expense Name], and all the Expense names will appear in the Power Apps data table control.

Output:

PowerApps Data Table Group By

To do so, follow the below steps.

1. Create a Blank Canvas app and connect it to the specific SharePoint list -> Select the Power Apps Screen -> Insert a Data table control and use the below code to set its Items property.

Items = GroupBy(
    AddColumns(
        'Expense Tracker',
        "ExpenseName",
        Title
    ),
    "ExpenseName",
    "GroupByExpenses"
)

Where,

  • ‘Expense Tracker’ = SharePoint Online list
  • “ExpenseName” = New column name
  • Title = SharePoint list text field
  • “GroupByExpenses” = Group name
How to group Power Apps data table

2. Save, Publish, and Preview the app. The Power Apps data table displays the group records from the SharePoint list based on the text field column as shown below.

How to group the Power Apps data table

Group Power Apps Data Table using Multiple Columns

1. In the above example, we saw how to group the Power Apps data table using a single column. I will show you how to group the data table using multiple columns.

2. Here also I will take the above SharePoint list. Insert a Button control and set its OnSelect property as:

OnSelect = ClearCollect(
    colMultipleColumns,
    GroupBy(
        'Expense Tracker',
        "Title",
        "Description",
        "Date",
        "Amount",
        "ExpenseGroup"
    )
)

Where,

  • colMultipleColumns = Collection name
  • “Title”, “Description”, “Date”, etc… = SharePoint list columns which we want to group in the data table
How to group a Power Apps data table

3. Now, insert a Data table and set its Items property as:

Items = colMultipleColumns
How to group PowerApps data table

4. Whenever the user clicks on the button control, the data table displays the grouped records based on the multiple columns.

Have a look at the below screenshot for the output.

How to group a PowerApps data table

Power App Data Table Group By Filter

Let’s see how to filter and group the Power Apps data table. Select the data table and provide the code below to its Items property.

Items = GroupBy(
    Filter(
        'Expense Tracker',
        "Within Budget" exactin Budget.Value
    ),
    "Title",
    "Amount",
    "GroupByBudget"
)

Where,

  • Budget, Title, Amount = SharePoint list fields
How to group the PowerApps data table

Once it is done, look at the out for how to filter and display the data table records based on the SharePoint list choice field value.

How to group data table in Power Apps

Power App Data Table Group By Sum

In this section, I will explain how to group the Power Apps data table using the Sum() function with a simple scenario:

Scenario:

I have a Power Apps collection[colTravel], containing different fields, including two number columns [Estimated Airfare & Estimated Hotel Cost].

How to group data table in PowerApps

Now, I would like to display grouped record [TotalCost] in the data table using a sum of two collection number fields. For that, insert a data table and set its Items property as:

Items = GroupBy(
    AddColumns(
        colTravel,
        "TotalCost",
        TripTitle & " - " & Sum(
            EstimatedAirfare,
            EstimatedHotelCost
        )
    ),
    "TotalCost",
    "GroupByTotal"
)

Where,

  • colTravel = Power Apps collection name
  • “TotalCost” = New column name
How to group a data table in PowerApps

Once your app is ready, Save, Publish, and Preview the app. The data table groups and displays the records based on the sum of the two collection number fields like below.

How to group a data table in Power Apps

How to UnGroup Power Apps Data Table

In the last, let me show you how to ungroup the Power Apps grouped data table. To achieve it, insert a Button control and set its OnSelect property to the code below.

OnSelect = ClearCollect(
    colUngroup,
    Ungroup(
        colMultipleColumns,
        "ExpenseGroup"
    )
)

Where,

  • colUngroup = Power Apps new collection name
  • colMultipleColumns = Name of the grouped collection
How to group the data table in Power Apps

Next, insert a Data table control and set its Items property as:

Items = colUngroup
Group data table in Power Apps

Now, whenever the user clicks on the button control, the data table displays ungroup records as in the screenshot below.

Group data table in Power Apps app

If you have any requirements to work on the Power Apps data table group items, I hope you find this article helpful. This article taught in detail information about how to group the Power Apps data table with different and useful scenarios.

Also, you may like some more Power Apps articles:

>