Watching:

How to Insert Subtotals in a Sorted Excel List


show more Inserting subtotals in a sorted list provides you with in-depth training on Business. Taught by Dennis Taylor as part of the Excel 2013 Essential Training show less
please wait ...

Inserting subtotals in a sorted list

In this worksheet called Subtotals, we've got a list of data here; it's sorted by Department and Status. And what we'd like to do here is insert subtotals every time there's a change in the Department. In fact we might even want to do that within each Department, do it by Status. So we've got a lot of Account Management people here and whenever there is a breakpoint, in other words whenever we see a change here, we'd like to insert a new row that tabulates the data from above. Now not all of our columns have data that we could tabulate. However, it might make sense to show totals for Salary, well not total for Job Rating, maybe an average.

And so we can create subtotals, insert them automatically not by painstakingly doing it manually, by using a feature available on the DATA tab. In order for this feature to work sensibly, the data must be in some kind of coherent order. For example; if we want totals by Building, we're going to get totals all over the place right now because practically every other cell here changes, location of the Building. It's not sorted by Building. We do want totals let's say by Department and possibly within that by Status.

So the data is sorted already. Then because we have no empty rows within the data, no empty columns, we don't have to select all of the data. We can simply make sure the active cell is within our list, then go to the DATA tab in the Ribbon and choose Subtotal; it's in the Outline group. Quickly calculate rows of related data by inserting totals and subtotals. In the Subtotal dialog box we want to indicate which change in a field will trigger the insertion of these subtotals.

At each change in Department, there it is. We don't want to total all the fields; by the way Sum is certainly common, probably the most common but we could choose Average instead. Unfortunately you can't mix these within the same row, let's choose Sum here and which fields do we want to Sum? Excel will make suggestions but not necessarily all the ones you want. I think both of our Salary columns; we want to have a total. We wouldn't want a total Job Rating, that wouldn't be very helpful, total years of service possibly, let's just click OK.

The first thing you might notice is the entire list has been shifted to the right, we see outlining symbols along the left side of our screen. As we scroll down here and we come to the end of Account Management; we'll see a Total row right here. We're not seeing our headings for the moment, that's Years of service and we've got our two salary fields, many times you want to readjust these columns right here because we will see pound signs if the column isn't wide enough, so we'll do that. But recognize the ADC Department is substantially smaller, we see the totals here too.

And so every time there's a break in the data here, that is every time there's a change in column C, we see subtotals. Now those outlining symbols on the left-hand side of the screen allow us to collapse this view of the data. You see a 1, 2, and 3, currently 3 is active so no change there, let's click 2 and suddenly we've collapsed the data to show only the Subtotals and the Grand Total. There it is a handy bit of analysis there.

Choosing 1 is not that valuable; it simply shows us the Grand Total. Click 2, we're back to here. And Click 3, we're seeing the detail and the Totals. Now possibly, you could be thinking, can we work with our data like this all the time, what if we just leave these here? Well when it comes time to sort the data or to work with filtering, these might get in the way. So there is a general tendency to use this feature, print it, collapse it, copy it, that sort of thing and then when you're finished; simply remove the Totals.

Now recognize here that we also have the possibility because the data was sorted ahead of time of inserting an additional level of Subtotals by Status, that's column D. So let's go back to the command, making sure the active cells within the data. On the DATA tab, Subtotal and now at each change in Status let's insert Subtotals as well. Be sure if you're using multi-levels, as we're about to do here that you do not replace the current Subtotals, uncheck that box then click OK.

And now we're about to see two levels of Subtotals. Recognize we've got four Outlining symbols and as we scroll down here, for example in the Account Management Department, we've got some Contract people and there is the Contract Total, we've got some Full Time people, Full Time Total, Half-Time, Hourly and so on. ADC, pretty short list there but we see that break out too. If we click number 3 in our outlining symbols here, we've collapsed the list to show both levels of Subtotals and the Grand Total. Let's see this here.

Clicking 2 we'll see just the main level of Subtotals like we had seen before. In both cases here you might want to print this list or possibly copy it to another worksheet. Let's imagine I want to copy this to another worksheet. I'm going to create a new worksheet by simply clicking the plus to the right, down at the bottom of the screen here, this will add a new sheet to the right of Subtotals. So going back to Subtotals what if I want to copy this data here? So I'll select it, I want to copy it just as I see it. So I'll copy the list there, there it is, press Ctrl+C or maybe Right-Click and Copy.

Go to the other sheet, the empty sheet, Right-Click and Paste and that's probably not what you were expecting. We get all the data; surely there must be a way. Not an obvious way, but there is a way if we only want to copy the visible data. If you work with Filtering you may have gotten used to the idea that when you select data out of a filter, you can Copy-Paste it and it only shows you the data that's visible. But in other situations including this one, if you want to copy this data here and not include all that hidden data, you can use a keystroke shortcut of Alt+Semicolon and when you do that, it selects only the visible data.

If we now Right-Click and Copy, watch the screen difference, you can probably sense what's happening. We are about to pick up the data in chunks or in pieces. Then if we go to the other sheet, Sheet1 and I'll Paste this just to the right of the other data, right here in J1, Right-Click and Paste, now we're getting only the visible data, that's what would make some sense. Now let's go back to the original data. If you didn't know about the keystroke shortcut or if you had forgotten about it, if you were selecting the data, it's buried pretty deeply in the Excel command structure.

So imagine we're highlighting the data, somehow we know or we think there is a way to copy just the visible data, where do we go; HOME tab, extreme right button Find & Select, Go To Special, Visible cells only. Remember the keystroke shortcut for all of this is Alt+Semicolon. Click OK, that selects the visible cells, then Right-Click Copy or Ctrl+C and then we can go to the other location, I won't do it again but we could Paste over here.

So there certainly will be times when you're working with Subtotals that you would want to copy the collapsed list, in some way if we'd collapsed the list this far too. Recognize also that if you are working with data and maybe you're using this for presentation purposes, if you were making a presentation of this data or maybe for printing reasons, if the question comes up about for example, how many Hourly people do we have here in Account Management here or who are these people. If we click the plus over here just to the left of Hourly Total, we will see the detail for that particular group for the moment, for as long as you want to keep it there.

If we no longer want to see that detail, we'll click the minus. So we have this ability for presentation purposes to quickly expand and collapse our Subtotal list here. If at some point after doing the printing, the copying and the display, if you no longer want to see the Subtotals or have this feature in effect, simply go back to the DATA tab, choose Subtotal and Remove All, sounds drastic but all we're doing is removing the Subtotals and returning the data to its starting position. So the Subtotal capability, a quick way to insert subtotals based on a sorted list.

Inserting subtotals in a sorted list
Video duration: 8m 25s 6h 32m Appropriate for all

Viewers:

Inserting subtotals in a sorted list provides you with in-depth training on Business. Taught by Dennis Taylor as part of the Excel 2013 Essential Training

Subjects:
Business Education + Elearning
Software:
Excel
Author:
please wait ...