SUBTOTAL Function in Excel

SUBTOTAL Function in Excel

August 29th, 2026
2
07:00 Minutes

Working with Excel data becomes confusing the moment you apply filters. Your totals stop making sense, numbers don’t match, and you’re left wondering what went wrong. This is exactly where the SUBTOTAL function in Excel becomes a game-changer. It lets you calculate totals that automatically adjust based on visible data, making your analysis accurate and reliable.

In this article, you’ll learn what the SUBTOTAL function is, how it works, the meaning of different function numbers, and how to use it with real examples you can try yourself. By the end, you’ll be able to handle filtered data confidently and build smarter Excel reports without errors. Let’s begin.

Read Also: How to Find Standard Deviation in Excel?

What Is the SUBTOTAL Function in Excel?

The SUBTOTAL function in Excel is a built-in function used to perform calculations like SUM, AVERAGE, COUNT, MAX, and MIN on a selected range of data. What makes it different from regular formulas is that it works intelligently with filtered data.

When you apply filters in Excel, normal functions like SUM still calculate all values, even the hidden ones. But SUBTOTAL only considers visible rows, which makes your results more accurate and meaningful. This is especially useful when working with large datasets, reports, or dashboards where you frequently filter data based on categories.

Another important feature of SUBTOTAL is that it gives you flexibility through function numbers. These numbers define what type of calculation you want to perform. For example, you can use one number for SUM and another for AVERAGE. You can also choose whether to include or ignore manually hidden rows.

In simple terms, SUBTOTAL helps you perform dynamic calculations that automatically adjust when your data view changes. Because of this, it is widely used in business analysis, financial reporting, and data management tasks where accuracy and flexibility are important.

Why Use the SUBTOTAL Function Instead of SUM in Excel? 

At first, SUM seems enough. It adds numbers quickly and works well for simple data. But the moment you start filtering your dataset, SUM shows its limitation. It still includes hidden rows in the calculation, which can give you misleading results.

This is where the SUBTOTAL function in Excel becomes a better choice. It calculates only the visible data, meaning your totals automatically update when filters are applied. You don’t need to adjust formulas again and again.

Another advantage is flexibility. With SUBTOTAL, you can do more than just SUM. You can calculate AVERAGE, COUNT, MAX, and more using different function numbers, all within the same function.

It also avoids double counting. If your dataset already contains subtotals, the SUBTOTAL function ignores them, keeping your results clean and accurate.

In short, SUM is static, while SUBTOTAL is dynamic. If you are working with filtered data, reports, or dashboards, SUBTOTAL saves time, reduces errors, and gives you results you can actually trust.

Also Read: How to Subtract in Excel?

SUBTOTAL Syntax

The SUBTOTAL function in Excel follows a simple and flexible structure. Once you understand the syntax, using it becomes very easy.

Formula: =SUBTOTAL(function_num, ref1, [ref2], ...)

Breakdown of Each Part:

  • function_num
    This defines the type of calculation you want to perform.
    For example:

    • 9 → SUM

    • 1 → AVERAGE

    • 2 → COUNT

    • 109 → SUM (ignores hidden rows)

  • ref1
    This is the main range of cells you want to calculate. Example: B2:B10

  • [ref2], ... (Optional)
    You can add more ranges if needed. This is optional and not always required.

Example: =SUBTOTAL(9, C2:C8)

This calculates the SUM of values in the range C2 to C8.

Tip: The most important part of this function is the function number. It controls:

  • What calculation is performed

  • Whether hidden rows are included or ignored

The 11 SUBTOTAL Function Numbers

The most important part of the SUBTOTAL function in Excel is the function number. This number tells Excel what calculation to perform and whether hidden rows should be included or ignored. Excel provides two sets of function numbers. The first set (1–11) includes manually hidden rows, while the second set (101–111) ignores them.

Understanding this is key because it gives you full control over how your data is calculated, especially when working with filtered reports or dashboards.

SUBTOTAL Function Numbers Table

FunctionInclude Hidden RowsIgnore Hidden Rows
AVERAGE1101
COUNT2102
COUNTA3103
MAX4104
MIN5105
PRODUCT6106
STDEV7107
STDEVP8108
SUM9109
VAR10110
VARP11111
  • 1–11 → Includes manually hidden rows

  • 101–111 → Ignores manually hidden rows (recommended for most cases)

For practical use, most people prefer the 100+ series because it keeps calculations clean and focused only on visible data.

Read Also: KPI in Power BI: Key Performance Indicators Dashboards

SUBTOTAL Function Examples

Now that you understand how the SUBTOTAL function works, let’s apply it in real scenarios.

Example 1: SUBTOTAL SUM Function (Ignoring Filtered Data)

Goal: To calculate the total revenue that automatically updates when filters are applied.

FORMULA: 

=SUBTOTAL(109, C2:C7)
Example 1: SUBTOTAL SUM Function (Ignoring Filtered Data)

In this example, I have used function number 109 that means SUM while ignoring hidden rows. Initially, the formula calculates the total revenue of all products. But the real power appears when you apply a filter. For example, if you filter only Electronics, the formula will automatically update and show the total revenue of just those visible rows.

Unlike the normal SUM function, this formula does not include hidden or filtered-out data. This makes it extremely useful for reports where you frequently change views using filters.

Example 2: SUBTOTAL COUNT Function for Visible Rows

Goal: To count how many products are currently visible after applying filters.

FORMULA: =SUBTOTAL(103, A2:A7)

Example 2: SUBTOTAL COUNT Function for Visible Rows

In this example, I used function number 103, which represents COUNTA and ignores hidden rows. This formula counts all non-empty cells in the Product column, but only for visible rows. So, if you apply a filter (for example, showing only Furniture), the count will automatically adjust to show only the visible products.

This is especially helpful when you want to track how many records meet certain conditions without manually counting or updating formulas.

Read Also: How to Remove Blank Rows in Excel?

Example 3: SUBTOTAL AVERAGE for Filtered Data

Goal: To calculate the average revenue based only on visible data.

FORMULA:  
=SUBTOTAL(101, C2:C7)

Example 3: SUBTOTAL AVERAGE for Filtered Data

In this example, I used function number 101, which calculates the AVERAGE while ignoring hidden rows. When no filter is applied, it calculates the average of all revenue values. But once you filter the data, the formula automatically updates and calculates the average only for the visible rows.

This is very useful in analysis scenarios where you want insights based on a selected category instead of the entire dataset.

SUBTOTAL with Filters: Step-by-Step

In this section, my goal is to calculate total revenue that updates automatically when filters are applied by using the SUBTOTAL function. Let’s begin. 

FORMULA: =SUBTOTAL(109, C2:C8)

Now, you just need to follow these simple steps to see how the SUBTOTAL function works with filters in real time.

STEP 1: Enter the Dataset

Paste the dataset into Excel properly with headers (Product, Category, Revenue). Make sure your data is clean and aligned in columns.

SUBTOTAL with Filters: step1: enter the dataset

Step 2: Apply Filter

  • Now, you need to select the entire dataset

  • Next, go to Data and then apply Filter

  • You will see dropdown arrows appear in the header row

SUBTOTAL with Filters: step 2: apply filter

Step 3: Apply SUBTOTAL Formula

Now, go in any empty cell (for example, C10) and enter this formula: =SUBTOTAL(109, C2:C8). At this point, it will show you the total revenue of all products.

SUBTOTAL with Filters: step 3: apply SUBTOTAL  formula

Step 4: Use Filter to Change View

  • First, go and click the filter dropdown in the Category column.

Step 4: Use Filter to Change View

  • Then here, you need to select only Electronics. 

Step 4: Use Filter to Change View

  • Now, the worksheet displays only Electronics records, and the subtotal updates automatically to 180,000.

subtotal updates

Explanation: When you applied the SUBTOTAL formula, Excel calculated the total revenue using function number 109, which means SUM while ignoring hidden rows.

Initially, all rows were visible, so the formula returned the total of the entire dataset. But once you applied a filter and selected only Electronics, Excel automatically hid the other rows.

The SUBTOTAL function responded to this change and recalculated the total based only on the visible rows. This is what makes it different from the normal SUM function, which would still include all values.

In simple terms, the formula adjusts itself based on what you are viewing. This makes it extremely useful for real-time analysis, reports, and dashboards where data is constantly filtered.

Read Also: How to Use HLOOKUP Function?

1–11 vs 101–111: When Does It Matter?

At first glance, the two sets of SUBTOTAL function numbers might look confusing. But the difference is actually simple and very important in real use.

The numbers 1–11 include manually hidden rows in the calculation. This means if you hide rows using “Hide” in Excel, those values are still counted. On the other hand, 101–111 ignores manually hidden rows, so only visible data is used.

Now here’s the key point. Both sets automatically ignore filtered rows. So even if you use 9 or 109, filtered-out data will not be included. The real difference shows up only when rows are hidden manually.

When Should You Use 1–11?

  • When you want to include hidden rows
    If rows are hidden temporarily but still important for your total, this option ensures nothing is missed.

  • When data visibility is not affecting calculations
    For static reports where hiding rows is just for better viewing, not analysis, using 1–11 works fine.

When Should You Use 101–111?

  • When you want accurate visible-only calculations
    This is the most common case. If you are analyzing filtered or cleaned data, you want only visible rows included.

  • When building dashboards or reports
    Dashboards often involve hiding unnecessary data. Using 101–111 ensures your results stay clean and relevant.

  • When avoiding calculation errors
    Ignoring hidden rows prevents accidental inclusion of unwanted data, which improves accuracy. 

SUBTOTAL vs SUM

Both SUM and SUBTOTAL are used to calculate totals in Excel, but they behave very differently when your data changes. While SUM is simple and works well for basic calculations, it does not adjust when you filter or hide data. SUBTOTAL, on the other hand, is designed for dynamic datasets and updates results based on what is visible. This makes it much more useful for real-world analysis, reports, and dashboards.

FeatureSUM FunctionSUBTOTAL Function
Basic calculationAdds numbersAdds numbers (and more)
Works with filtersNoYes
Ignores filtered rowsNoYes
Ignores manually hidden rowsNoYes (with 101–111)
Supports multiple operationsNo (only SUM)Yes (SUM, AVERAGE, COUNT, etc.)
Dynamic updatesNoYes
Avoids double countingNoYes

Also Read: XLOOKUP() vs. VLOOKUP()

SUBTOTAL vs AGGREGATE

Both SUBTOTAL and AGGREGATE are powerful Excel functions used for calculations on datasets, especially when working with filtered or hidden data. While SUBTOTAL is simple and widely used, AGGREGATE is more advanced and gives you extra control, especially when dealing with errors and complex scenarios.

FeatureSUBTOTAL FunctionAGGREGATE Function
Ease of useVery simpleSlightly complex
Functions supported11 functions19 functions
Works with filtersYesYes
Ignores hidden rowsYes (with 101–111)Yes
Ignores errors (like #DIV/0!)NoYes
Ignores nested subtotalsYesYes
Supports arraysNoYes
Best forBasic reportingAdvanced analysis

Common Errors and Fixes

Even though the SUBTOTAL function in Excel is simple to use, small mistakes can lead to incorrect results. Most errors happen because of wrong function numbers, incorrect ranges, or misunderstanding how hidden and filtered rows work. The good part is that these issues are easy to fix once you know what to check.

Using the Wrong Function Number

One of the most common mistakes is selecting the wrong function number. For example, using 9 instead of 109 can include hidden rows when you actually want to ignore them.
Fix: Always double-check whether you need to include or ignore hidden rows. In most cases, use the 101–111 series for accurate results.

Forgetting to Apply Filters

Many users expect SUBTOTAL to behave differently without applying filters. But if no filter is applied, the result will look the same as a normal formula.
Fix: Apply filters to your dataset to see the dynamic behavior of SUBTOTAL.

Incorrect Data Range Selection

If your range is wrong or incomplete, your result will also be incorrect. For example, selecting only part of the data can give a lower total.
Fix: Always verify that your range (like C2:C8) covers the full dataset.

Confusion Between Hidden and Filtered Rows

SUBTOTAL treats filtered and manually hidden rows differently. Many users assume both behave the same way.
Fix: Remember:

  • Filtered rows are always ignored

  • Hidden rows are ignored only with 101–111

Including Headers in the Range

Sometimes users accidentally include column headers in the formula range, which can affect functions like COUNT or AVERAGE.
Fix: Start your range from actual data rows (e.g., C2, not C1).

Nested SUBTOTAL Confusion

If your data already contains SUBTOTAL formulas, Excel automatically ignores them to prevent double counting. This can confuse users who expect those values to be included.
Fix: Understand that this is intentional behavior. If needed, adjust your structure or use a different approach.

Read Also: How to Separate Names in Excel?

When to Use SUBTOTAL?

The SUBTOTAL function in Excel is best used when your data is not static. If you are simply adding numbers in a fixed dataset, a normal SUM formula works fine. But the moment your data involves filtering, hiding, or frequent changes, SUBTOTAL becomes the better choice.

It is mainly used in situations where you want your calculations to adjust automatically based on what is visible on the screen.

When Working with Filtered Data

If you apply filters to your dataset, SUBTOTAL ensures that only visible rows are calculated. This makes your totals accurate and relevant without needing to change the formula again and again.

When Creating Reports and Dashboards

In reports, you often hide or filter data to focus on specific insights. SUBTOTAL helps maintain dynamic totals that update instantly as the data view changes. This is very useful in business and financial reports.

When You Want Multiple Calculations in One Function

Instead of using separate formulas like SUM, AVERAGE, or COUNT, you can use SUBTOTAL with different function numbers. This keeps your formulas simple and consistent.

When Avoiding Double Counting

If your dataset already includes subtotals, SUBTOTAL automatically ignores them. This prevents errors and keeps your final result accurate.

When Handling Large Datasets

In large Excel sheets, manually adjusting formulas can be time-consuming. SUBTOTAL saves time by automatically adapting to filters and hidden data.

Wrap-Up

The SUBTOTAL function in Excel is one of the most useful tools for working with filtered and dynamic data. Unlike regular formulas, it updates automatically based on visible rows, making your calculations more accurate and reliable.

By understanding function numbers and how filtering affects results, you can use SUBTOTAL for real-world tasks like reports, dashboards, and data analysis. Whether you are calculating totals, averages, or counts, this function helps you save time and avoid common errors.

Once you start using SUBTOTAL in your workflow, managing large datasets becomes much easier and more efficient.

Also Read: Countif Function in Excel

FAQs

Q1. What does SUBTOTAL do in Excel?

SUBTOTAL performs calculations like SUM, AVERAGE, and COUNT while considering only visible data in a filtered dataset.

Q2. What is the difference between 9 and 109 in SUBTOTAL?

9 includes hidden rows, while 109 ignores hidden rows and calculates only visible data.

Q3. Does SUBTOTAL ignore filtered rows?

Yes, SUBTOTAL automatically ignores filtered rows in all cases.

Q4. Can SUBTOTAL be used instead of SUM?

Yes, SUBTOTAL can replace SUM, especially when working with filtered or dynamic datasets.

About the Author
Vinay Agarwal | igmGuru
About the Author

Vinay Agarwal has worked extensively with Microsoft technologies, from Azure infrastructure to productivity tools, helping IT professionals prepare for certification exams. Having sat the exams himself, he knows the gap between exam content and real-world application. He tracks Microsoft's product and certification updates, keeping his guidance current and genuinely useful.

Drop Us a Query
Fields marked * are mandatory
×

Your Shopping Cart


Your shopping cart is empty.