U Love Office
Home › Blog › Excel & Data
Excel & Data

Excel GROUPBY and PIVOTBY functions: summaries without PivotTables

✍️ admin 📅 23 November 2026

Quick answer: GROUPBY and PIVOTBY are Excel functions that summarise data like a PivotTable, but as a formula. =GROUPBY(Sales[Branch], Sales[Amount], SUM) returns a list of branches with their total sales. =PIVOTBY(Sales[Branch], Sales[Month], Sales[Amount], SUM) returns branches down the side and months across the top. The results spill into the sheet and update instantly when the data changes, with no Refresh button. They are available in Excel for Microsoft 365 (and Excel for the web); older perpetual versions do not have them.

PivotTables are powerful, but they have drawbacks: they must be refreshed, they break formulas that point at them when they change shape, and they are hard to combine with other formulas. GROUPBY and PIVOTBY fill that gap for everyday summaries.

Excel GROUPBY formula summarising sales by branch with a total row
Change any amount on the left and the summary updates immediately.

Check you have the functions

Type =GROUP in a cell. If GROUPBY appears in the suggestions, you have it. If not, you are probably on Excel 2021, 2024 perpetual or an older Microsoft 365 update channel. Ask your IT team about updating, or use the PivotTable approach in our PivotTable tutorial.

Prepare your data

Like a PivotTable, GROUPBY works best with a clean table:

Structured references like Sales[Branch] make formulas readable and grow automatically as you add rows.

GROUPBY syntax

=GROUPBY(row_fields, values, function, [field_headers], [total_depth], [sort_order], [filter_array], [field_relationship])

The first three arguments are all you need to start:

The optional arguments control headers, totals, sorting and filtering.

Useful GROUPBY examples

Total by branch, sorted from highest to lowest:

=GROUPBY(Sales[Branch], Sales[Amount], SUM, , , -2)

The sort order -2 sorts by the second column (the totals) descending.

Count of invoices by customer:

=GROUPBY(Sales[Customer], Sales[Invoice], COUNTA)

Average sale by product:

=GROUPBY(Sales[Product], Sales[Amount], AVERAGE)

Two levels: branch then product, with subtotals:

=GROUPBY(Sales[[Branch]:[Product]], Sales[Amount], SUM, , 2)

Selecting two adjacent columns as row fields creates a two-level grouping. The 2 in total_depth adds subtotals and a grand total.

Only October sales (filter):

=GROUPBY(Sales[Branch], Sales[Amount], SUM, , , , MONTH(Sales[Date])=10)

Share of total:

=GROUPBY(Sales[Branch], Sales[Amount], PERCENTOF)

PERCENTOF returns each branch’s percentage of the total. Format the result as a percentage.

Table explaining each argument of the Excel GROUPBY function
Start with the first three; add the rest as you need them.

PIVOTBY: rows and columns

PIVOTBY adds a column dimension, like dragging a field into the Columns area of a PivotTable.

=PIVOTBY(row_fields, col_fields, values, function, ...)

Branches by month:

=PIVOTBY(Sales[Branch], TEXT(Sales[Date],"yyyy-mm"), Sales[Amount], SUM)

Using TEXT(...,"yyyy-mm") turns dates into month labels that sort correctly. You get branches down the side, months across the top, and totals for both.

Products by branch, count of orders:

=PIVOTBY(Sales[Product], Sales[Branch], Sales[Invoice], COUNTA)

Excel PIVOTBY result showing sales by branch and month with totals
A live cross-tab without creating a PivotTable.

GROUPBY vs PivotTable: which to use?

A practical rule: use a PivotTable when you are exploring data and do not know yet what you want to see. Use GROUPBY or PIVOTBY when you know the summary you need every month and want it to update without anyone clicking Refresh, or when the summary feeds other formulas or a dashboard.

Combining GROUPBY with other functions

Because GROUPBY returns an array, you can feed it into other dynamic array functions:

Worked example: a monthly management report

A Dubai office furniture company keeps all invoices in a table called Sales. On a Report sheet, the finance manager builds:

  1. Sales by branch this month: GROUPBY with a filter for the current month.
  2. Branch by month for the year: PIVOTBY with TEXT(Date,"yyyy-mm").
  3. Top 10 customers year to date: TAKE wrapped around GROUPBY.
  4. Product mix: GROUPBY with PERCENTOF.

Each month, the team pastes new invoices into the Sales table. Every summary updates immediately, and the report is ready without rebuilding or refreshing anything.

Finance manager presenting a sales summary chart to colleagues

Common problems

Sharing with colleagues on older Excel

If a colleague opens your file in an older version, GROUPBY results show as errors or as static values, depending on the version. For files that must work everywhere, use a PivotTable or classic SUMIFS formulas. Our SUMIF vs SUMIFS guide shows how to build summaries that work in any version.

Comparison of Excel GROUPBY and PIVOTBY functions with PivotTables
Use formulas for fixed reports and PivotTables for exploration.

Formatting and presenting the results

Because GROUPBY returns ordinary cells, you format them like any other range, with a few tips:

Common office uses

Each of these is one formula once the data is in a clean table, and each updates automatically as new rows are added. That makes GROUPBY ideal for small dashboards that several people look at during the month.

Step-by-step: your first GROUPBY report

  1. Select your data and press Ctrl+T to make it a table. Name it Sales in Table Design > Table Name.
  2. On a new sheet, type a title in A1, such as “Sales by branch”.
  3. In A3, type =GROUPBY(Sales[Branch], Sales[Amount], SUM) and press Enter. The summary spills down.
  4. Change the formula to =GROUPBY(Sales[Branch], Sales[Amount], SUM, 3, 1, -2) to show headers, a grand total and sort by amount from highest to lowest.
  5. Format column B as numbers with thousands separators.
  6. Add a new row to the Sales table with a new branch name and watch it appear in the summary.

Once this works, copy the sheet and change the row field to Product or Customer to create more summaries in minutes. Keep each summary on its own area of the sheet with plenty of empty space around it, so the results can grow without causing #SPILL! errors. When your colleagues ask how the report works, the formula itself documents the logic: what is grouped, what is calculated and how it is sorted, all visible in one line.

Key takeaways

Checklist for getting started with Excel GROUPBY and PIVOTBY
Six steps to your first formula summary.

📘 Continue reading

Frequently asked questions

Can GROUPBY replace all my PivotTables?
Not all. PivotTables remain better for exploration, slicers and users who prefer drag-and-drop.

Can I use my own calculation instead of SUM?
Yes. You can pass a LAMBDA as the function, for example to calculate a median or a custom margin. See our guide to the Excel LAMBDA function.

Does GROUPBY work in Google Sheets?
No, Google Sheets uses QUERY and pivot tables instead.

Can I group by more than two fields?
Yes, select several adjacent columns as row fields, or combine them with HSTACK.

Conclusion

GROUPBY and PIVOTBY bring PivotTable-style summaries into ordinary formulas. Start with =GROUPBY(Table[Field], Table[Value], SUM), then add sorting, totals and filters as you need them, and use PIVOTBY for cross-tabs. For recurring reports in Microsoft 365, they save time every month and remove the “did you refresh it?” question for good.

Last checked: 9 November 2026. Function availability depends on your Microsoft 365 update channel.