SUBTOTAL vs SUM: What's the Difference in Excel?
In this article
The difference is simple: SUM adds every number in the range you give it, while SUBTOTAL adds only the rows that are visible after you filter or manually hide others. Use SUM when you want a grand total of everything; use SUBTOTAL when you want a total that updates as you filter a list. SUBTOTAL also has a second trick: it can ignore other SUBTOTAL formulas nested inside the range, which prevents double-counting in tables that already contain subtotals.
What You'll Need
- Excel, Google Sheets, or another spreadsheet app that supports SUBTOTAL (most do, though menu names vary).
- A list or table with a header row and at least one column of numbers.
- Basic familiarity with entering formulas and using the filter buttons.
Step-by-Step
- Set up your data as a proper table. Put headers in row 1 (for example, Region, Sales) and data below. Select any cell in the list, then on the Home tab choose Format as Table or use Insert > Table. This turns on filter arrows automatically. If you prefer not to use a table, select the data and go to Data > Filter. Labels can differ slightly by version and platform, but the filter button is usually on the Data tab.
- Add a SUM formula for the grand total. Click an empty cell below your numbers, type
=SUM(B2:B100)(replace B2:B100 with your actual range), and press Enter. This adds every value in the range, including rows you later hide or filter out. - Add a SUBTOTAL formula for the visible total. In another empty cell, type
=SUBTOTAL(109,B2:B100)and press Enter. The 109 tells SUBTOTAL to sum and to ignore manually hidden rows as well as filtered-out rows. If you only need to ignore filtered rows but still want manually hidden rows counted, use 9 instead of 109. - Filter the list to see the difference. Click the filter arrow on a column header and choose a value (for example, one region). The SUM cell stays the same; the SUBTOTAL cell changes to show only the visible rows. Clear the filter and both return to the full total.
- Use SUBTOTAL for subtotals inside a table. If you add SUBTOTAL formulas at the bottom of each group (or let Excel's Data > Subtotal command insert them), a final SUBTOTAL with function number 109 will ignore those inner SUBTOTALs and give you a clean grand total without double-counting.
- Check your range includes only numbers. Both SUM and SUBTOTAL ignore text and blanks, but they will include error values. If you see an error, trace which cell contains it and fix or remove it.
- Copy the formulas down or across if needed. When you copy a SUBTOTAL formula, the function number stays the same, so you can reuse it in multiple total rows. Relative references adjust as usual; use absolute references like $B$2:$B$100 if the range should not move.
Common Mistakes
- Using SUM when you plan to filter. SUM does not change when rows are hidden or filtered, so your total will look wrong to anyone reading the filtered view.
- Forgetting the 100-series function numbers. SUBTOTAL(9, range) ignores filtered rows but not manually hidden ones. SUBTOTAL(109, range) ignores both. Pick the one that matches how you hide rows.
- Nesting SUBTOTAL inside SUM. SUM will add the inner subtotals and double-count. Use SUBTOTAL for the outer total instead.
- Including the header row or total row in the range. Text is ignored, but a total row that contains a number will be counted twice. Keep the range to data rows only.
- Assuming SUBTOTAL works the same in every app. Google Sheets supports SUBTOTAL with the same function numbers, but menu locations differ. Other apps may have limited support; check the app's help.
Tips
- Use a table (Insert > Table) so ranges expand automatically when you add rows; then SUBTOTAL and SUM both pick up new data without editing the formula.
- Name your total cells (Formulas > Define Name) so formulas read clearly, for example
=SUBTOTAL(109,SalesData). - If you need a total that ignores errors, wrap the range in AGGREGATE instead of SUBTOTAL; AGGREGATE supports an option to ignore error values.
- For quick checks, select the visible cells and look at the status bar at the bottom of the window; it shows a sum of the selection, which can confirm what SUBTOTAL should return.
- When sharing a workbook, add a note or a label next to each total explaining whether it is a grand total (SUM) or a visible-rows total (SUBTOTAL).
Troubleshooting
- SUBTOTAL returns the same value as SUM after filtering. Check that you used 109, not 9, and that the rows are actually filtered (filter arrow active) rather than just hidden by row height. Also confirm the range covers the filtered rows.
- SUBTOTAL shows a wrong number. Look for hidden rows you forgot about, or a total row inside the range. Temporarily unhide all rows (select the whole sheet, right-click a row header, choose Unhide) to see what is being counted.
- You see #VALUE! or another error. One of the cells in the range contains an error or text that looks like a number. Fix the cell or use AGGREGATE with the ignore-errors option.
- The formula does not update when you change data. Check that calculation is set to automatic (Formulas > Calculation Options > Automatic). In some apps this setting is under a different menu; look for calculation or recalculation in settings.
- SUBTOTAL is not available in your app. Use SUM with manual filtering, or switch to a spreadsheet app that supports it. There is no reliable workaround that matches SUBTOTAL's behavior exactly.
Frequently Asked Questions
What does the 9 or 109 mean in SUBTOTAL?
The number tells SUBTOTAL which calculation to perform. 9 means sum and ignores filtered rows; 109 means sum and ignores both filtered and manually hidden rows. Other numbers cover average, count, max, and so on.
Can I use SUBTOTAL instead of SUM everywhere?
Yes, if you want the total to respond to filters. If you need a fixed grand total that never changes when rows are hidden, SUM is simpler and less surprising to readers.
Does SUBTOTAL work in Google Sheets?
Yes. Google Sheets supports SUBTOTAL with the same function numbers, though the menus for filters and tables are in different places than Excel.
Why does my SUBTOTAL ignore some visible rows?
Those rows may be inside a filtered-out group, or the range may not include them. Check the range boundaries and clear any filter that might be hiding them indirectly.
Can I nest SUBTOTAL inside another SUBTOTAL?
Yes, and the outer SUBTOTAL will ignore the inner ones, which is exactly what you want for a grand total that does not double-count group subtotals.
What is the difference between SUBTOTAL and AGGREGATE?
AGGREGATE offers more functions and options, including ignoring errors and hidden rows, but it is not available in every spreadsheet app. SUBTOTAL is more widely supported and simpler for basic visible-row totals.