Written by Allen Wyatt (last updated March 7, 2026)
This tip applies to Excel Excel in Microsoft 365
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.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2019 For Dummies today!
The INT function allows you to convert a value to an integer. The effect the function has depends on the characteristics ...
Discover MoreThe PROPER worksheet function is used to change the case of text so that only the first letter of each word is uppercase. ...
Discover MoreTwo common worksheet functions used to count things are COUNT and COUNTA. Not understanding how these functions treat ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2026 Sharon Parq Associates, Inc.
Comments