Skip to main content

How to Group Records in Power Apps with GroupBy

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

GroupBy turns a table into one row per value of a column. Each row keeps that value and a nested table of the records that share it. GroupBy(Entries, WeekStart, WeekEntries) gives one row per week, with the week's entries in WeekEntries.

The example is the Overtime Timesheet app, whose My Overtime screen groups each person's overtime into weeks.

Syntax​

Syntax
GroupBy(Table, ColumnName1 [, ColumnName2, ...], GroupColumnName)
  • ColumnName(s): the columns to group by. They become columns of the result.
  • GroupColumnName: a new column that holds, for each group, a table of the records' other columns.

Column names are written as they are, without quotes. Microsoft's GroupBy reference notes that before Power Apps version 3.24042 they were text in double quotes, and that apps were updated to the new syntax automatically.

Prerequisites​

Step 1: Add the Column to Group By​

The example's entries have a date, WorkDate, but not the week. AddColumns adds each entry's Monday, using the app's MondayOf function (How to Find the Monday of a Week in Power Apps):

The entries with their week
AddColumns(locLoadedMO, WeekStart, MondayOf(WorkDate))

locLoadedMO is a context variable holding the entries the screen loaded: for November 2026, four entries on 29 October, 1, 2 and 6 November.

Step 2: Group Them​

Any text control → Text
CountRows(GroupBy(AddColumns(locLoadedMO, WeekStart, MondayOf(WorkDate)), WeekStart, WeekEntries))

I put the formula into a text control's Text for a moment, so Studio's preview strip shows the result. CountRows counts the groups: 2 weeks.

The expanded formula bar with CountRows of GroupBy of AddColumns(locLoadedMO, WeekStart, MondayOf(WorkDate)) by WeekStart into WeekEntries, and the preview strip reading 2 with Data type number

Step 3: Look Inside the Groups​

Each group has its WeekStart and a WeekEntries table. Concat writes one line per group, and CountRows counts each group's entries (How to Join Table Values into Text in Power Apps with Concat):

Any text control → Text
Concat(
GroupBy(AddColumns(locLoadedMO, WeekStart, MondayOf(WorkDate)), WeekStart, WeekEntries),
$"{Text(WeekStart, "dd/mm/yyyy")}: {CountRows(WeekEntries)} entries",
"; "
)

The week of 26 October has two entries, 29 October and 1 November, and so does the week of 2 November:

The expanded formula bar with the Concat over the GroupBy, and the preview strip reading 26/10/2026: 2 entries; 02/11/2026: 2 entries with Data type text

GroupBy and SharePoint​

The delegation overview lists GroupBy among the functions that can't be delegated to any data source. On a SharePoint list it would group only the first 500 rows Power Apps fetches.

The example loads the rows it needs with a filter SharePoint can run, keeps them in a context variable, and groups that. A table held by UpdateContext is a static in-memory list, so GroupBy sees all of it: How to Filter a SharePoint List Between Two Dates in Power Apps.

How the Example Uses It​

The groups are the weeks of the screen's weekly totals: How to Total Each Group in Power Apps with GroupBy and Sum.

Common Mistakes​

MistakeWhat happensDo this instead
GroupBy directly on a SharePoint listOnly the first 500 rows are groupedGroup a filtered copy held in a variable
Grouping by a date and time columnEvery different time is its own groupGroup by a column made with AddColumns, such as the week's Monday
Quoting the column names, from an older exampleThat's the syntax from before version 3.24042Write the names as they are

Troubleshooting​

SymptomLikely causeFix
One group per recordThe grouping column is different on every recordGroup by a coarser value: day, week or month
The groups aren't in the order you wantNothing in the formula sorts themSort the result by the grouping column

FAQ​

Can I group by two columns?​

Yes: list both before the group column, such as GroupBy(Entries, Department, WeekStart, WeekEntries). Each pair of values is one group.

How do I undo a grouping?​

Ungroup turns the groups back into records: Ungroup(Grouped, WeekEntries).

Conclusion​

GroupBy(Table, Column, GroupColumn) makes one row per value of the column, with the matching records in a nested table. Add the column you need with AddColumns first, and group a table held in memory when the data comes from SharePoint.

Additional Resources​