The SUBTOTAL function in Microsoft Excel returns the subtotal value from a range of cells. It allows you to use other functions, like AVERAGE or COUNT, to find custom totals from a dataset. We’ll explain how to use the SUBTOTAL function, step-by-step, in this tutorial.
Mathematical functions like SUM, AVERAGE, and MIN exist in their own right in Excel, allowing you to analyze data in your own way. If you want to use these functions to find subtotals, however, you can easily do this using the SUBTOTAL function.
SUBTOTAL automatically ignores any other examples of SUBTOTAL formulas, making it a better option if you’re looking to add subtotals within your dataset without impacting the data that’s reported.
Are you thinking about using the SUBTOTAL function to analyze your spreadsheet data? To help, we’ll explain how it works and how to use it effectively.
Subtotals are an incredibly useful feature in Excel that allow you to summarize and analyze large datasets. With just a few clicks, you can add subtotals to group and total figures by categories, saving tons of time and giving you the ability to view high-level summaries as well as drill down into the details.
In this comprehensive guide, you’ll learn everything you need to know about using subtotals in Excel, including:
What are Subtotals in Excel?
Subtotals in Excel refer to sums or other summary statistics calculated for subgroups within a larger dataset. For example in a sales dataset you may want to insert subtotals by region to quickly see totals per region.
The Excel Subtotal feature allows you to automatically:
- Group data by categories like region, product, date, etc.
- Calculate sums, averages, counts, etc. for each group.
- Show different layer views like overall summary, group subtotals, or detailed rows.
This provides a powerful way to segment and summarize large datasets for reporting and analysis
How to Insert Subtotals in Excel
Adding subtotals in Excel is very easy thanks to the Subtotal command. Here are the steps:
-
Organize your data – Sort your data by the column you want to subtotal. Remove any blank rows.
-
Select your data – Select one or more cells within your dataset.
-
Go to Data > Subtotal. The Subtotal dialog box appears.
-
In the At each change in box, select the column to subtotal by.
-
In the Use function box, pick the calculation type (Sum, Count, Average, etc).
-
In the Add subtotal to box, check the columns to be subtotaled.
-
Click OK. Excel adds the subtotals and grand total rows.
That’s it! Excel will now recalculate the subtotals automatically when the source data changes.
Adding Multiple Subtotal Levels
One very useful trick is to insert nested subtotals to group your data by multiple fields.
For example, you can subtotal first by Region, then by Product within each Region. Here’s how:
-
Sort your data by the outer grouping column (Region).
-
Insert the top level subtotals (by Region).
-
Go to Data > Subtotal again and add a second-level (by Product).
-
Be sure to uncheck Replace current subtotals so you don’t overwrite the first level.
Repeat steps 3-4 to add more levels as desired. This builds a hierarchy with outer and inner groups summarized independently.
Showing and Hiding Subtotal Details
Once you’ve inserted subtotals, you can collapse and expand the different grouping levels as needed.
-
Click the 1-2-3 buttons in the top left to show summaries or details.
-
Use the + and – buttons to expand/collapse individual groups.
This lets you view high-level overviews or drill into the underlying rows very easily.
Copying Only the Subtotal Values
To copy only the subtotal values to another place:
-
Show the subtotal rows you want to copy.
-
Press Ctrl+A to select the entire dataset.
-
Go to Home > Find & Select > Go To Special and pick Visible cells only.
-
Press Ctrl+C to copy, then paste where needed.
This copies only the visible subtotal cells, leaving out the hidden details.
Changing Existing Subtotals
To modify existing subtotals:
-
Select any subtotal cell.
-
Go to Data > Subtotal.
-
In the dialog box, change the grouping column, calculation, etc.
-
Ensure Replace current subtotals is checked.
-
Click OK.
This will replace your existing subtotals with the new settings.
Removing Subtotals
To delete subtotals:
-
Select any subtotal cell.
-
Go to Data > Subtotal.
-
Click the Remove All button.
This will remove all subtotals, undoing the grouping while keeping the original data intact.
Subtotal Tips and Tricks
Here are some additional pointers for working with Excel subtotals:
-
Subtotals ignore hidden or filtered rows. Use structured references or SUMIFS to subtotal filtered data.
-
Grand totals calculate from the original data, not the subtotals.
-
You can’t use Subtotals within Excel tables. Convert the table to a range first.
-
Use the GETPIVOTDATA function to pull summarized values from PivotTables.
-
Add custom subtotal labels using the Subtotal Name Manager under Data > Outline.
-
Turn automatic subtotals on/off for future PivotTables under PivotTable Options.
-
The SUBTOTAL function gives you more flexibility to control hidden rows, nested subtotals, etc.
Subtotals in PivotTables
PivotTables have their own Subtotals and Grand Totals features that provide similar grouping and summarizing functionality.
To add subtotals to a PivotTable:
-
Click anywhere in the PivotTable.
-
Go to PivotTable Analyze > PivotTable and choose Subtotals.
-
Check the boxes for the fields you want subtotals for.
-
Pick a calculation type – Sum, Count, Average, etc.
You can also turn on grand totals for entire PivotTables and enable or remove subtotals for future PivotTables using the PivotTable Options dialog.
The functionality works the same way – you get automatic grouping and summarizing, collapsible details, and multiple subtotal layers. The main difference is PivotTables let you summarize multidimensional data instead of flat ranges.
Summary
Subtotals are an extremely helpful reporting tool in Excel. In just a few clicks, you can:
-
Group datasets by categories.
-
Calculate sums, averages, counts and other statistics for those groups.
-
Collapse and expand to view summaries or details.
-
Build multiple subtotal layers for multidimensional analysis.
Using Excel’s Subtotal or PivotTable subtotal features, you can gain new perspective and extract insights from your business data.
So next time you’re faced with a large dataset, don’t spend hours manually summarizing – use Subtotals to automate it instantly. With this guide, you should have all the knowledge needed to master this time-saving tool.
Things to consider before using SUBTOTAL in Excel
While SUBTOTAL has advantages, there are also a few things you’ll need to consider before you start using it. These include:
- As mentioned, using 1-11 for the function_num argument will ensure that SUBTOTAL includes hidden values, while 101-111 ignores them.
- Using a value other than 1-11 or 101-111 will cause Excel to return a #VALUE! Error. This will also occur for 3D cell references (where the same cell, across multiple worksheets, is referenced in a range).
- When horizontal cell ranges like A1:D1 are used, hidden values are included automatically (regardless of the function_num argument value). This is a limitation of the SUBTOTAL function and can’t be overcome.
- Using SUBTOTAL on filtered data will ensure that hidden values are always ignored, regardless of the function_num argument used.
- SUBTOTAL can be used as a nested function as part of other functions, including formulas containing the IF function.
- If another SUBTOTAL formula is within the ref1 data range, then SUBTOTAL will ignore it and exclude it from the overall calculation.
- Excel allows a maximum of 254 cell ranges to be used in a SUBTOTAL formula, although only 1 is required for the formula to work.
What is the SUBTOTAL function and what is it used for?
At first glance, you might wonder: what is the point of the SUBTOTAL function? After all, it’s easy enough to find a subtotal from a range of cells using existing functions like SUMIF or AVERAGE.
While it’s true that you don’t necessarily need to use SUBTOTAL, it makes targeted data analysis a lot easier. You can insert a formula using SUBTOTAL into a range of cells without it affecting the overall total, because SUBTOTAL ignores other cells that contain a SUBTOTAL formula.
SUBTOTAL works with other Excel features, such as cell filtering. If you filter a table using a value, the SUBTOTAL formula updates, recognizing the filter and excluding cells accordingly. SUBTOTAL is also useful for ignoring hidden values, which other functions (like SUM) can’t do.
Thankfully, you can use other functions as part of a SUBTOTAL formula. 11 different subtotal methods are available, each matching an existing Excel function. If you want a SUM formula that works with filtered cells and ignores other SUBTOTAL formulas, then using SUBTOTAL is best, although a pivot table could work in a similar way.
Calculating Subtotals in Excel
How are subtotals calculated?
Each region is totaled for each quarter, then each quarter is totaled, and finally a grand total is calculated. The subtotals use the by position option. To view how these subtotals are set up, select Subtotals from the Data menu. You can press F11 to toggle the grand total display for reports in Desktop.
How to automatically add a subtotal function in Excel?
Excel can automatically add SUBTOTAL functions for you. 1. The first option. Create a table and add a total row to the bottom of the table. Next, click any cell in the last row to automatically add a SUBTOTAL function. Explanation: in this example, we also filtered by Country.
Does a hidden column affect a subtotal in Excel?
The Excel SUBTOTAL function with function_num 101-111 neglects values in hidden rows, but not in hidden columns. For example, if you use a formula like SUBTOTAL (109, A1:E1) to sum numbers in a horizontal range, hiding a column won’t affect the subtotal. Example 2.