GroupBy Function

The GroupBy function returns a table with records grouped together based on the value of one or more columns. Records in the same group are placed into a single record, with a column added that holds a nested table of the remaining columns.

Power Apps Syntax GroupBy(Table, ColumnName1 [, ColumnName2, ... ], GroupColumnName )

Example: Demonstration of the GroupBy function.

Step 1: There is a sharepoint list named ‘Group List’ created to demonstrate the use of GroupBy function in power apps.

GroupBy function in Power Apps

Step 2: Add a vertical gallery in the canvas app. And set the Items property to the following power apps formula.

Power Apps Formula

GroupBy('Group List',"Country", "MyData")

Here,

After applying the GroupBy function, the data is grouped by the "Country" column. The resulting grouped data will be stored with the column name "MyData".

GroupBy function in Power Apps

Step 3: Add a Text label control and set its Text property to the following power apps formula.

Power Apps Formula

ThisItem.Country
GroupBy function in Power Apps

Step 4: Add another vertical gallery control inside the gallery itself to show the data which is grouped. As grouped data is in tabular form, and gallery support tabular data as a data source.

Power Apps Formula

ThisItem.MyData
GroupBy function in Power Apps

Step 5: Add a Text label control and set its Text property to the following power apps formula.

Power Apps Formula

ThisItem.'Student Name'
GroupBy function in Power Apps

Step 6: Add another Text label control and set its Text property to the following power apps formula.

Power Apps Formula

ThisItem.Salary
GroupBy function in Power Apps

Step 7: Now its time to preview the application.

GroupBy function in Power Apps