Excel 2016: Groups and Subtotals

Lesson 21: Groups and Subtotals

/en/excel2016/filtering-data/content/

Introduction

Worksheets with a lot of content can sometimes feel overwhelming and even become difficult to read. Fortunately, Excel can organize data into groups, allowing you to easily show and hide different sections of your worksheet. You can also summarize different groups using the Subtotal command and create an outline for your worksheet.

Optional: Download our practice workbook.

Watch the video below to learn more about groups and subtotals in Excel.

To group rows or columns:

  1. Select the rows or columns you want to group. In this example, we'll select columns B, C, and D.
    Selecting cells
  2. Select the Data tab on the Ribbon, then click the Group command.
    The Group button on the Data tab
  3. The selected rows or columns will be grouped. In our example, columns B, C, and D are grouped.
    The selected cells are now grouped

To ungroup data, select the grouped rows or columns, then click the Ungroup command.

The Ungroup button on the Data tab

To hide and show groups:

  1. To hide a group, click the minus sign, also known as the Hide Detail button.
    The Hide Detail button
  2. The group will be hidden. To show a hidden group, click the plus sign, also known as the Show Detail button.
    The Show Detail button

Creating subtotals

The Subtotal command allows you to automatically create groups and use common functions like SUM, COUNT, and AVERAGE to help summarize your data. For example, the Subtotal command could help to calculate the cost of office supplies by type from a large inventory order. It will create a hierarchy of groups, known as an outline, to help organize your worksheet.

Your data must be correctly sorted before using the Subtotal command, so you may want to review our lesson on Sorting Data to learn more.

To create a subtotal:

In our example, we'll use the Subtotal command with a T-shirt order form to determine how many T-shirts were ordered in each size (Small, Medium, Large, and X-Large). This will create an outline for our worksheet with a group for each T-shirt size and then count the total number of shirts in each group.

  1. First, sort your worksheet by the data you want to subtotal. In this example, we'll create a subtotal for each T-shirt size, so our worksheet has been sorted by T-shirt size from smallest to largest.
    Selecting cells
  2. Select the Data tab, then click the Subtotal command.
    The Subtotal button on the Data tab
  3. The Subtotal dialog box will appear. Click the drop-down arrow for the At each change in: field to select the column you want to subtotal. In our example, we'll select T-Shirt Size.
  4. Click the drop-down arrow for the Use function: field to select the function you want to use. In our example, we'll select COUNT to count the number of shirts ordered in each size.
  5. In the Add subtotal to: field, select the column where you want the calculated subtotal to appear. In our example, we'll select T-Shirt Size. When you're satisfied with your selections, click OK.
  6. The worksheet will be outlined into groups, and the subtotal will be listed below each group. In our example, the data is now grouped by T-shirt size, and the number of shirts ordered in that size appears below each group.
    Subtotal rows and groups have been applied to the worksheet

To view groups by level:

When you create subtotals, your worksheet it is divided into different levels. You can switch between these levels to quickly control how much information is displayed in the worksheet by clicking the Level buttons to the left of the worksheet. In our example, we'll switch between all three levels in our outline. While this example contains only three levels, Excel can accommodate up to eight.

  1. Click the lowest level to display the least detail. In our example, we'll select level 1, which contains only the grand count, or total number of T-shirts ordered.
    Setting the group detail to level 1
  2. Click the next level to expand the detail. In our example, we'll select level 2, which contains each subtotal row but hides all other data from the worksheet.
    Setting the group detail to level 2
  3. Click the highest level to view and expand all of your worksheet data. In our example, we'll select level 3.
    Setting the group detail to level 3

You can also use the Show and Hide Detail buttons to show and hide the groups within the outline.

Using the Show and Hide Detail buttons in a subtotal


To remove subtotals:

Sometimes you may not want to keep subtotals in your worksheet, especially if you want to reorganize data in different ways. If you no longer want to use subtotaling, you'll need remove it from your worksheet.

  1. Select the Data tab, then click the Subtotal command.
    The Subtotal button on the Data tab
  2. The Subtotal dialog box will appear. Click Remove All.
    Removing subtotals in the Subtotal dialog
  3. All worksheet data will be ungrouped, and the subtotals will be removed.

To remove all groups without deleting the subtotals, click the Ungroup command drop-down arrow, then choose Clear Outline.

Clear Outline in the Ungroup menu on the Data tab

Challenge!

  1. Open our practice workbook.
  2. Click on the Challenge tab in the bottom-left of the workbook.
  3. Sort the workbook by Grade from smallest to largest.
  4. Use the Subtotal command to group at each change in Grade. Use the SUM function and add subtotals to Amount Raised.
  5. Select Level 2 so that you only see the subtotals and grand total.
  6. When you're finished, your workbook should look like this:

    Grouping and Subtotals Challenge

/en/excel2016/tables/content/