Skip to main content

How to Total Each Group in Power Apps with GroupBy and Sum

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

To total each group of records, group them with GroupBy, then add a column with AddColumns whose value is Sum over the group's nested table. Microsoft's own GroupBy reference describes this pattern. Grouping a person's overtime by week gives totals such as 26/10/2026: 6.00 hours.

The example is the Overtime Timesheet app, whose My Overtime screen shows each week's total, Monday to Sunday.

Prerequisites​

Step 1: Group the Records​

The entries grouped by the Monday of their week, as in the GroupBy guide:

The weeks
GroupBy(AddColumns(locLoadedMO, WeekStart, MondayOf(WorkDate)), WeekStart, WeekEntries)

Each row is a week: its WeekStart, and its entries in WeekEntries.

Step 2: Add Each Group's Total​

AddColumns works out a formula for each row. In a grouped table, WeekEntries is that row's own table of entries, so Sum(WeekEntries, Hours) is the week's total:

The weeks with their totals
AddColumns(
GroupBy(AddColumns(locLoadedMO, WeekStart, MondayOf(WorkDate)), WeekStart, WeekEntries),
WeekHours,
Sum(WeekEntries, Hours)
)

To see the result in Studio's preview strip, I joined the weeks into one line with Concat in a text control for a moment:

Any text control → Text
Concat(
AddColumns(
GroupBy(AddColumns(locLoadedMO, WeekStart, MondayOf(WorkDate)), WeekStart, WeekEntries),
WeekHours,
Sum(WeekEntries, Hours)
),
$"{Text(WeekStart, "dd/mm/yyyy")}: {Text(WeekHours, "0.00")} hours",
"; "
)

The week of 26 October has 2 and 4 hours, and the week of 2 November 3 and 4:

The expanded formula bar with Concat over AddColumns of the GroupBy with WeekHours as Sum(WeekEntries, Hours), and the preview strip reading 26/10/2026: 6.00 hours; 02/11/2026: 7.00 hours with Data type text

How the Example Uses It​

The My Overtime screen writes one line per week, in date order, and leaves rejected entries out of the totals:

A macOS-style code window titled lblWeeksMO → Text: Concat over Sort of AddColumns of GroupBy, where the entries without rejected ones get a WeekStart from MondayOf(WorkDate), are grouped by WeekStart, and get WeekHours as the Sum of their hours, with one line per week reading the Monday to the Sunday and the hours

lblWeeksMO → Text
Concat(
Sort(
AddColumns(
GroupBy(
AddColumns(Filter(locLoadedMO, Status.Value <> "Rejected"), WeekStart, MondayOf(WorkDate)),
WeekStart,
WeekEntries
),
WeekHours,
Sum(WeekEntries, Hours)
),
WeekStart
),
$"{Text(WeekStart, "ddd dd/mm/yyyy")} to {Text(DateAdd(WeekStart, 6, TimeUnit.Days), "ddd dd/mm/yyyy")}: {Text(WeekHours, "0.00")} hours",
Char(10)
)
  • Filter first leaves rejected entries out of every week's total.
  • Sort by WeekStart puts the weeks in date order (How to Sort a Table in Power Apps with Sort).
  • Char(10) between the lines is a line break, so each week is on its own line.

In Preview, for November 2026:

The My overtime screen in Preview for November 2026: Total for November 2026: 11.00 hours, the weekly totals Mon 26/10/2026 to Sun 01/11/2026: 6.00 hours and Mon 02/11/2026 to Sun 08/11/2026: 7.00 hours, the note about weeks and rejected entries, and three Pending entries

The first week starts in October: its total counts Thursday 29 October as well as Sunday 1 November, because the screen loads whole weeks.

Common Mistakes​

MistakeWhat happensDo this instead
Sum(locLoadedMO, Hours) inside AddColumnsEvery group gets the total of all recordsSum the group's own table: Sum(WeekEntries, Hours)
Filtering after grouping to drop some recordsThe groups' tables still hold themFilter before GroupBy
Grouping a SharePoint list directlyOnly the first 500 rows are groupedGroup a filtered copy held in a variable

Troubleshooting​

SymptomLikely causeFix
All the groups show the same totalSum reads the whole table, not the groupUse the group column's name in Sum
The weeks are out of orderThe result isn't sortedSort by the grouping column
A week is missingIt has no records, so GroupBy has no group for itExpected: only weeks with records appear

FAQ​

Yes: use the AddColumns(GroupBy(...)) table as the gallery's Items, and show ThisItem.WeekStart and ThisItem.WeekHours in each row. The example uses one Text control because the list is short.

How does Excel do this?​

SUMIFS adds up the rows that match each group: How to Total Hours by Person and Month in Excel with SUMIFS.

Conclusion​

AddColumns(GroupBy(Table, Column, Group), Total, Sum(Group, Value)) totals each group. Filter before grouping, sort the result, and keep a SharePoint table in memory before grouping it.

Additional Resources​