Pinterest Pixel

How to Use Subtotal Function in Excel

John Michaloudis
The subtotal function in Microsoft Excel is a versatile tool designed to simplify data analysis by performing a variety of calculations, such as sums, averages, and counts, on a specified range of cells.
Unlike the standard SUM function, Subtotal can dynamically include or exclude hidden and filtered rows, making it ideal for working with dynamic datasets.

This powerful feature allows users to efficiently manage and analyze large sets of data with precision and ease.
How to Use Subtotal Function in Excel | MyExcelOnline How to Use Subtotal Function in Excel | MyExcelOnline

Key Takeaways:

  • Versatile Calculations: The Subtotal function can perform a variety of aggregate calculations such as sum, average, count, max, and more, making it a powerful tool for data analysis.
  • Dynamic Data Handling: Unlike the SUM function, Subtotal can ignore hidden or filtered rows, making it ideal for dynamic datasets that change frequently.
  • Easy Integration: Integrating subtotals into your Excel sheets is straightforward and involves just a few clicks, making it accessible even for beginners.
  • Advanced Nesting: For complex datasets, Subtotal allows for nested calculations, enabling multi-dimensional analysis by layering subtotals.
  • Error Troubleshooting: Common errors like #NAME?, #VALUE!, and #DIV/0! can be easily identified and corrected, ensuring smooth and accurate calculations.

 

Unveiling the Magic of Excel’s Subtotal Function

What Is the Subtotal Function?

Imagine having a wizard at your fingertips to effortlessly crunch numbers, weaving in and out of data with precision and speed. That’s what the Subtotal function in Excel feels like—a spell that conjures up a variety of calculations on your dataset with simplicity and agility.

Imagine you have a range of cells, each brimming with numbers. Instead of applying multiple formulas to sum up or average these figures, the Subtotal function is your go-to tool. It deftly calculates everything from sums to averages, counts to max values, all while allowing you to either factor in or ignore rows that you’ve decided to hide manually.

Subtotal Function

 

Harnessing the Power of Subtotal in Excel

Step-by-Step Guide to Inserting Subtotals

Injecting subtotals into your Excel sheets is an expedition that’ll take you just a few clicks. Here’s a compass to guide you through:

STEP 1: Select Your Data: Before summoning subtotals, ensure your data is sorted and selected based on the column you want to subtotal. Remember, no blank rows should lurk between your data; they could disrupt the spell.

Subtotal Function

STEP 2: Begin the Magic: Navigate to the ‘Data’ tab and find the ‘Subtotal’ button tucked in the ‘Outline’ group. It’s the gateway to your data transformation.

Subtotal Function

STEP 3: Subtotal Dialog Box: This is where the enchantment happens. The dialog box will ask you to select the magic words (‘At each change:’ in as ‘Region’), the sorcery you wish to perform (choose ‘Sum’), and the potion concoction (‘Add subtotal to:’ as ‘Sales’).

Subtotal Function

STEP 4: Refine the Spell: Ensure that ‘Replace current subtotals’ is checked if you want to overwrite any previously cast subtotal spells. You wouldn’t want the old and new magics to clash. Then click, ‘OK’.

Subtotal Function

RESULT: Finalize Your Incantation: With a swift click on ‘OK’, watch as the rows bend to your will, arranging themselves with neat subtotals as demanded.

Subtotal Function

If your dataset has multiple portals needing the touch of subtotal magic, repeat the steps for each. Think of it as creating layers of spells, one atop another, for a multi-dimensional view of your numbers.

 

Advanced Techniques with Nested Subtotals

As you delve deeper into the sorcery of Excel, nested subtotals emerge as your wand for crafting a masterful financial analysis spellbook. Here’s how to summon these advanced enchantments:

  • Layer Your Sorts: Start by ordering your cauldron’s contents—sort your data by the most outer group first (say, ‘Region’), then by the subsequent inner groups (like ‘Item’). Each layer prepares the potion for more complex flavors.
  • Insert the First Subtotal Layer: Select any cell in your dataset, then activate the Subtotal command. Choose your first group (like ‘Region’) for the ‘At each change in’ field, pick the potion—’Sum’ to amass wealth, ‘Average’ to find the golden mean, and so on. Choose your treasures, the columns filled with riches, to apply the function.
  • The Art of Collapsing: Use the grouping outlines on the left to fold and unfold the layers of your analysis. Revel in how it reveals or conceals information, offering insights at different levels, from the grand overview to the detailed underside.

How to Use Subtotal Function in Excel | MyExcelOnline

The dexterity lies in the balance; carefully layering subtotals can yield a magical mirror reflecting every facet of your financial realm, making it a crystal ball to foresee and navigate through the numerals of fate.

 

Breaking Down the Subtotal Function

Decoding the Syntax and Parameters

In the grand library of Excel functions, the ancient scrolls reveal the following incantation for the SUBTOTAL function:

SUBTOTAL( method, range1, [range2, … range_n] )

Here’s the key to unlocking its power:

  • method: This mystical parameter determines the type of calculation the SUBTOTAL function will perform. Excel recognizes a variety of numerical codes—1 for average, 2 for count, 3 for counta, and so forth up to 11. If you require subtotal to consider only visible data, cast the incantation with codes 101 to 111.
  • range1, [range2, ... range_n]: These are the cells over which the SUBTOTAL function will wave its wand. You can specify one or more ranges, and it doesn’t shy away from multiple areas. Just remember, these ranges must be separated by commas in this arcane formula.

When woven correctly, this formula allows you to consolidate your data like a seasoned sage, transforming entire columns and rows with a simple spoken word—or rather, a simple input in Excel’s function bar.

Example

subtotal function

The formula =SUBTOTAL(1,B2:B6) in Excel is used to calculate a subtotal for a specified range of cells, in this case, the range B2:B6. The SUBTOTAL function is quite versatile and can perform different types of calculations based on the function number provided as the first argument.

Here’s a breakdown of the formula components:

  • SUBTOTAL: The function that performs a variety of aggregate calculations on a specified range.
  • 1: The function number that specifies which type of calculation to perform. The number 1 corresponds to the AVERAGE function.
  • B2:B6: The range of cells on which the subtotal calculation will be performed.

So, =SUBTOTAL(1,B2:B6) calculates the average of the values in the range B2:B6.

 

Tricky Terrain: Troubleshooting Common Errors

Identify and Fix Excel Subtotal Glitches

Stumbling into the occasional spellbinding issue with SUBTOTAL in Excel is as inevitable as a cauldron bubbling over — it happens to the best of wizards. Here’s how to identify and rectify some common glitches:

  • #NAME?: If the cells whisper this incantation error, it means you’ve likely misspelled “SUBTOTAL” — a simple misstep on the spelling spell. To set it right, perform a quick spell-check and correct the function name.

subtotal function

  • #VALUE!: This one’s tricky as it suggests your function number isn’t in the range 1-11 or 101-111, or you’ve included a three-dimensional charm where a flat spell was expected. To banish this error, double-check your function_num argument and pare down your references to the second dimension only.

subtotal function

  • #DIV/0!: This happens when a particular function, such as calculating an average or standard deviation, attempts to divide by zero within a range of cells that don’t contain any numeric values.

subtotal function

By keeping a vigilant eye out for these anomalies and a steady hand ready to correct them, you ensure that your Subtotal function weaves a flawless tapestry of numbers and data.

 

FAQ – Your Questions Answered

What is the subtotal in Excel?

In Excel, the subtotal is like your trusty Swiss Army knife for data analysis. It lets you quickly calculate summary statistics like sums, averages, or counts for subsets of your data while allowing the option to include or exclude filtered and hidden rows in the calculations. It’s a formula, using the SUBTOTAL function, that flexes to your needs and keeps your data analysis sharp and concise.

How is subtotal different from sum Excel?

Subtotal in Excel is a seasoned traveler through your data, whereas Sum is more of a homebody. Sum tallies all numbers in a range, without discretion. Subtotal, on the other hand, is selective—it can perform the same sum operation while optionally ignoring rows you’ve hidden or filtered out, making it ideal for dynamic, changing datasets. [Include screenshot showcasing SUM vs. SUBTOTAL with filtered data].

How Do I Only Calculate Visible Cells Using SUBTOTAL?

To calculate only visible cells in Excel, embrace the SUBTOTAL function with codes 101-111, like 109 for sum. These codes tell SUBTOTAL to become a seer, turning its gaze only to what is visible, ignoring the hidden rows shrouded by filters or manual concealment with eagle-eyed precision.

Can You Explain the Difference Between SUBTOTAL 9 and 109?

Certainly! Imagine SUBTOTAL function numbers as two different keys to the same door. SUBTOTAL 9 opens up to include both visible and manually hidden rows in its calculation. Meanwhile, SUBTOTAL 109 is a more selective key, ignoring the rows you’ve tucked away out of sight and only accounting for the ones in plain view. Both calculate the sum, but with a slight twist in visibility.

How to subtotal in Excel excluding hidden rows?

To subtotal in Excel while excluding hidden rows, use the crafty SUBTOTAL function with codes 101-111. For sum, it’s 109; for average, 101. These special codes let SUBTOTAL know you wish to leave out those sneaky hidden rows from your totals, focusing only on the rows that bathe in the light of your spreadsheet.

If you like this Excel tip, please share it
Founder & Chief Inspirational Officer at

John Michaloudis is a former accountant and finance analyst at General Electric, a Microsoft MVP since 2020, an Amazon #1 bestselling author of 4 Microsoft Excel books and teacher of Microsoft Excel & Office over at his flagship MyExcelOnline Academy Online Course.

See also  CountIfs Formula in Excel

Get Video Training

Advance your Microsoft Excel & Office Skills with the MyExcelOnline Academy!

Dramatically Reduce Repetition, Stress, and Overtime!
Exponentially Increase Your Chances of a Promotion, Pay Raise or New Job!

Learn in as little as 5 minutes a day or on your schedule.

Learn More!

Share to...