Home > Pivot > Layout > Grouping How to Group Pivot Table DataHow to group data in an Excel pivot table. Examples for grouping dates, number and text fields. Fix grouping problems "Cannot group that selection" |
Table of Contents |
Automatic Date GroupingIn Excel 2016, and later versions, dates are automatically grouped, when you add a date field to a pivot table. You can undo the grouping in Excel 2016, and turn that feature off in later versions. Tip: See more details about pivot table date grouping, and learn why it can be helpful Turn Off Automatic Date GroupingIn Excel 2019 and Excel 365, you can change an Excel Option setting, to turn this date grouping feature on or off. NOTE: This is an application-level setting, and will affect all your Excel workbooks. To turn the automatic date grouping feature off:
|
Undo the Date GroupingFor all versions (Excel 2016 and later), you can manually ungroup the dates, with one of these methods: Keyboard Shortcut
Ungroup Command
|
Grouping DatesIn a pivot table, there are several built-in options for grouping dates - Seconds, Minutes, Hours, Days, Months, Quarters, and Years. You can select one or more of those options, to create the type of date grouping that you need. The examples below show how to group dates: -- By Month and Year -- By Week -- By 4-Week Period Group Dates by Month and YearTo group the items in a Date field
|
Group Dates by 4-Week PeriodsWatch this video to see how to group the date field in 4-week periods, and set the starting date. There are written instructions below the video. |
Group Dates by 4-Week PeriodIn this example, out company has 13 sales periods each year, with 4 weeks in each period. In the pivot table Grouping dialog box, here’s no option for grouping by Weeks. Instead, we can use the Days option . With a bit of simple arithmetic, we can calculate the number of days per period:
Follow these steps to group the dates into 4 week periods:
|
Using the Default Starting DateAs a starting date, Excel automatically selects the first date in your source data. In the the screen shot above, you can see that January 1, 2013 is the starting date in this source data. If I check in Outlook, that date falls on a Tuesday. If I click OK in the Grouping window, Excel will create periods that start on a Tuesday. In the grouped dates shown below, the first period goes from Tuesday, January 1, 2013, to Monday, January 28, 2013. Fix the Starting DateInstead of using the default starting date, you can enter a different date, to get the starting date you need. In this example, we’ll change the starting date to December 31, 2012. That date falls on a Monday, so this forces all the groupings to start on a Monday, which matches the company’s sales periods. To fix the starting date:
Now the periods are grouped correctly, with a Monday as the starting date for each period. |
Grouping by Date Adds Extra ItemsWatch this short video to see how to hide the text on the extra items that are created when you group a date field, or use a timeline in Excel 2013, to filter by a date period. There are written instructions below the video. Note: You can get the Excel file used in the video, in the Download section at the end of the page. |
Grouping by Date Adds Extra ItemsWhen a date field is grouped, new items are added, for all the dates before the start date and after the end date. These items start with a "<" or a ">" symbol, such as "<1/3/2013" and ">12/30/2014", and are based on the first and last date in the source data. There is no way to remove these extra items, but you could change the captions, to replace the text with space characters. Or, add new fields in the source data, to calculate the year and year/month, for each date, and use the new fields in the pivot table, instead of grouping. In Excel 2013, you can use the Timeline filter, to quickly filter by year, quarter, month or day. Note: You can get the Excel file that shows the extra items problem, in the Download section at the end of the page. |
Problem - Cannot Group That SelectionIf you try to group a date or number field, you may see a Microsoft Excel error message, with a yellow warning label, that says, "Cannot group that selection." There are 3 common causes for this pivot table grouping error message:
See the details on these causes, and steps to fix them, below the screen shot. 1) Pivot Table Added Data ModelWhen you created the pivot table, if you checked the box to "Add this data to the Data Model", you won't be able to group the items. Instead of a normal pivot table, it is an OLAP-based Power Pivot, and the grouping feature is not available. Here are a couple of workarounds to fix this problem:
Blank Cells or TextIn a normal pivot table (not in the data model), the grouping problem usually occurs when the field contains records with
To fix the problem
Previous GroupingIf you don't have blank cells or text in the date column, there may be a grouped field left over from the previous time that you grouped the data. To fix the problem, if this is the cause, follow these steps: |
Grouping NumbersUse grouping to create a concise summary, instead of showing a long list of individual numbers. This video shows you the steps, and the written instructions are below the video. |
Grouping NumbersInstead of listing numbers individually in a Row field, you can group them, to create a concise summary of the data. In this example, the original pivot table shows the units sold, per product. In column C, it shows the number of orders where that quantity was sold. To summarize the orders, group the units by tens. So, instead of 3 and 9 appearing in separate rows, they'll be summarized in the grouping 1-10. To group the numbers
In the pivot table, the Units now appear in groups -- 1 - 10, 11 - 20, etc. To make a more concise layout, you could move the grouped units field to the Columns area, as headings. |
Grouping Text ItemsThe Grouping dialog box isn't available if you try to group items in a text field. Instead, you can manually group the items.
This creates a new field in the field list, with the original field name and a number, such as City2 The new field is positioned above the original field in the pivot table layout, and the grouped items have a generic name, such as Group1.
|
To rename the group:
To add more items to a group:
|
Get the Sample FilesPivot Table Grouping: Get the Food Sales sample file so you can try the Pivot Table grouping examples shown on this page. The zipped file is in xlsx format, and does not contain macros. Extra Items: To follow along with the Extra Items video, download this sample file for the extra items in date grouping. The zipped file is in xlsx format, and does not contain macros. |
More TutorialsOld Items: If pivot table drop downs show outdated items, see the steps to clear old items in Pivot Table, and prevent them from reappearing. Calculated Field Count: A pivot table calculated field always uses the SUM of other fields. See this workaround to use a count in Calculated Field formulas. Calculated Item: Videos and written steps show how to create a calculated item in an Excel pivot table. See the features, restrictions, warnings. |
Last updated: August 23, 2023 3:43 PM