Using GROUPBY to Create a Summary Table

Written by Allen Wyatt (last updated March 7, 2026)
This tip applies to Excel Excel in Microsoft 365


1

Tressa has a worksheet that includes raw customer sales transaction data for the western division of her company. Column E contains the state in which each customer lives, and column G contains the order amount for each transaction. She's been told that she can use the new GROUPBY function to create a simple summary table that shows sales by state, but she's unclear on exactly how to do this.

The traditional way to create a summary table is to create a PivotTable, but some of the newest functions in Excel have provided simple ways to get the summary without doing so. One of those functions is GROUPBY, which is currently only available in Microsoft 365. In Tressa's situation, the function would be quite easy:

=GROUPBY(E:.E,G:.G,SUM)

There are three parameters in this instance, all of which are required. The first is the values to be used for grouping. Since Tressa wants a summary by state, that is why column E is specified as a range for this parameter. The second parameter is the range of values to be aggregated. The first range and this second range should both have the same number of elements. Finally, the third parameter is the function to be used in doing the aggregating. In this case, the SUM function is specified because Tressa wants to add all the amounts together, by state.

The result of this is a two-column summary based on the states in column E, summing the values in column G. At the bottom of the summary is a grand total of all the states. The appearance of the summary table can be modified a bit by using some of GROUPBY's optional parameters. Personally, I like to add two parameters, as shown here:

=GROUPBY(E:.E,G:.G,SUM,3,0)

The fourth parameter (3) indicates if the source data has headers or not, as well as what to do with them. This can be a value of 0 (no headers), 1 (yes, no show), 2 (no, generate), or 3 (yes, show).

The fifth parameter (0) indicates if subtotals or totals should be included in the summary. Possible values are 0 (no totals), 1 (grand totals), 2 (grand and subtotals), -1 (grand totals at top), and -2 (grand and subtotals at top). If you leave this parameter off, then GROUPBY provides grand and subtotals according to its best guess.

If you want more info on the GROUPBY function, here are two good places to find it:

https://support.microsoft.com/en-us/office/5e08ae8c-6800-4b72-b623-c41773611505
https://exceljet.net/functions/groupby-function

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13965) applies to Microsoft Excel Excel in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Changing the Way Endnotes Are Numbered

Word is flexible on how it numbers your endnotes. This tip shows how easy it is to make the changes to the numbering system.

Discover More

Making Revisions

You've turned on Highlight Changes, but how do you know what has been changed? This tip explains how Excel displays those ...

Discover More

Converting Forced Text to Numbers

If you have some numbers stored in cells that are formatted as text, you may get some surprises when you try to use those ...

Discover More

Best-Selling VBA Tutorial for Beginners Take your Excel knowledge to the next level. With a little background in VBA programming, you can go well beyond basic spreadsheets and functions. Use macros to reduce errors, save time, and integrate with other Microsoft applications. Fully updated for the latest version of Office 365. Check out Microsoft 365 Excel VBA Programming For Dummies today!

More ExcelTips (ribbon)

Understanding the VLOOKUP Function

Functions are at the heart of Excel's power in working with data. One of the most misunderstood functions provided by ...

Discover More

Colors in an IF Function

You can use the IF worksheet function to test for a number of different conditions or values. You can't use it to check ...

Discover More

Disabling #SPILL! Errors

In the newest version of Excel, a change in how formulas are calculated can cause havoc for some "older" formulas. Here ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is three more than 8?

2026-03-07 23:25:33

Alex Blakenburg

The example would probably have been clearer if it has used a hard coded range and not used TrimRange (ie the period after the colon in the range signifies TrimRange 'drop trailing blank rows'). TrimRange is quite nuanced.
For anyone trying the formula out as is, make sure that your headings for the data are in row 1 of the sheet.
Also the last row used has to have data in both columns E and G or you will get a #VALUE! error.


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.