Data Analytics Roadmap
Excel Basics → Basic Formulas → SUBTOTAL Function
PHASE 01 · BASIC FORMULAS

Excel SUBTOTAL Function

The secret formula for filtered tables and dynamic dashboards. Learn how to calculate SUM, AVERAGE, and COUNT on visible rows only.

⏱ ~15 Minutes📊 Data Analytics🎮 Interactive Filter Table

The Problem: Why Standard =SUM() Fails on Filtered Data

Imagine you have a sales report with 1,000 rows. You apply a filter to view only "Electronics" in the "North" region.

❌ STANDARD =SUM(C2:C1000)

Fails on Filtered Data

Standard =SUM() ignores your table filters and continues adding up all 1,000 rows in the background — giving an inflated, incorrect total!

✅ =SUBTOTAL(9, C2:C1000)

Dynamically Recalculates

=SUBTOTAL() detects active table filters and calculates ONLY the visible rows on your screen! Every filter change updates the total live.

Formula Syntax & Function Codes

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

The first argument (function_num) tells Excel which calculation type to perform (SUM, AVERAGE, COUNT, etc.).

1 / 101AVERAGE

Calculates the mean of visible numerical values

2 / 102COUNT

Counts visible cells containing numbers

3 / 103COUNTA

Counts visible non-empty cells (text & numbers)

4 / 104MAX

Finds the maximum value among visible cells

5 / 105MIN

Finds the minimum value among visible cells

9 / 109SUM

Adds up all visible numbers in the range (Most Popular!)

💡 Code 9 vs Code 109: What is the Difference?
Codes 1–11 (e.g. 9 = SUM)

Ignores rows hidden by Table Filters, but INCLUDES rows that were manually hidden using right-click → Hide.

Codes 101–111 (e.g. 109 = SUM)

Ignores BOTH Filtered-out rows AND Manually hidden rows! Best for absolute clean totals.

Interactive Filter Table & Live Counters

Filter the sales table below or toggle manual row hiding. Observe how =SUM() stays stuck while =SUBTOTAL() updates live!

Standard =SUM(Sales)$4,770❌ Static (Includes hidden rows)
=SUBTOTAL(9, Sales)$4,770✅ Dynamic SUM of 8 visible rows
=SUBTOTAL(1, Sales)$596⚡ Dynamic AVERAGE of visible rows
Row #Item NameCategoryRegionSales AmountStatus
Row 2MacBook ProElectronicsNorth$1800👁️ Visible
Row 3Ergonomic DeskFurnitureSouth$450👁️ Visible
Row 4Wireless HeadphonesElectronicsEast$200👁️ Visible
Row 5Winter HoodieClothingNorth$120👁️ Visible
Row 64K Gaming MonitorElectronicsWest$650👁️ Visible
Row 7Office ChairFurnitureEast$300👁️ Visible
Row 8Running ShoesClothingSouth$150👁️ Visible
Row 9iPhone 15ElectronicsNorth$1100👁️ Visible

3 Superpowers of the SUBTOTAL Function

🔍

1. Auto-Ignores Filtered Rows

Calculates only what is visible on screen. Ideal for interactive executive dashboards.

🛡️

2. Prevents Double Counting

Automatically skips other SUBTOTAL formulas inside the range! No more accidental doubled totals.

3. Works with Excel Tables (Ctrl+T)

When you enable the Total Row in Excel Tables, Excel automatically uses SUBTOTAL under the hood!

🧪 Knowledge Check — SUBTOTAL Quiz

Question 1 of 5Score: 0

📊 Why does standard =SUM(C2:C100) fail on a filtered Excel table?

Was this Excel SUBTOTAL workspace helpful?