The difference comes down to one thing: SUBTOTAL ignores rows that are hidden by a filter (and can skip other SUBTOTAL results nested inside it), while SUM adds every value in the range whether the row is filtered out or not. If you filter a table and want the total to match what you see on screen, use SUBTOTAL(9,range). If you need a true grand total of all data, use SUM(range). Both are calculated totals, not the status-bar number, and both are plain worksheet functions that work the same in Excel for Windows, Mac and the web app.
What You'll Need
- A spreadsheet with numeric data, ideally laid out as a contiguous block with a header row and no blank rows or columns inside it.
- One cell free below or beside the data to hold the formula.
- If you plan to filter, use Excel's filter (Data > Filter) rather than manually hiding rows, because that is the case SUBTOTAL is designed for.
- No add-ins or special settings — everything here is built in.
One note before you start: menu and ribbon labels can differ slightly by Excel version, platform and region, so the exact wording you see may not match word for word.
Step-by-Step
- Set up clean data. Put your values in a single column (say A2:A100) with a header in A1. Remove blank rows inside the range, because they can confuse filters and make your totals harder to audit.
- Add a SUM total first. Click a cell below the data and type
=SUM(A2:A100), then press Enter. This is your grand total — every number in the range, visible or not. - Turn on AutoFilter. Select any cell in the data and go to Data > Filter (or press Ctrl+Shift+L on Windows; on Mac the shortcut can vary, so use the Data menu). Dropdown arrows appear in the header row.
- Add a SUBTOTAL total. In a separate cell, type
=SUBTOTAL(9,A2:A100). The 9 is the function number for SUM; it tells SUBTOTAL to add the values. - Filter a category. Click a header dropdown and keep only one item, for example one region or product. Watch the two totals: the SUM cell stays the same, while the SUBTOTAL cell drops to the filtered amounts only.
- Confirm what each one does. Clear the filter. Both totals should now match. That equality is the proof that SUBTOTAL is calculating the same values as SUM, just with a visibility rule.
- Use 109 instead of 9 if you also hide rows manually.
SUBTOTAL(9,range)ignores rows hidden by a filter but still counts rows you hide by right-clicking and choosing Hide.SUBTOTAL(109,range)ignores both filtered and manually hidden rows. Decide which behaviour you want and be consistent. - Apply the same idea to other functions. SUBTOTAL supports 1 for AVERAGE, 2 for COUNT, 3 for COUNTA, 4 for MAX, 5 for MIN and more. Add 100 to each number (101, 102, 103…) to also exclude manually hidden rows.
- Place SUBTOTAL totals correctly in grouped tables. If you use Data > Subtotal to insert group totals, the generated totals use the SUBTOTAL function automatically. Keep your own grand total outside those grouped ranges so it does not double count.
Common Mistakes
- Using SUM and expecting it to follow the filter. SUM does not care about visibility. If the total must match what is displayed, it has to be SUBTOTAL.
- Nesting SUBTOTAL ranges that overlap. A SUBTOTAL placed inside the range of another SUBTOTAL is skipped by design, which is useful for grand totals but confusing if you expected it to be included.
- Forgetting the difference between 9 and 109. People hide rows manually, see the total unchanged, and assume SUBTOTAL is broken. It is working as specified.
- Building a total over a range that includes the total cell itself. That creates a circular reference. Keep the total one row below the data, never inside the range.
- Mixing text and numbers. SUM and SUBTOTAL both ignore text, so a total can look wrong when numbers were entered as text. Check for left-aligned numbers or green error triangles.
- Assuming a filtered-out row is deleted. Filtering hides it. Totals elsewhere, charts and pivot sources can still include it.
Tips
- Park the SUM grand total and the SUBTOTAL filtered total side by side with labels. Seeing both numbers change or stay put makes the behaviour obvious to anyone reading the sheet.
- Put the SUBTOTAL formula into a proper Excel Table (Insert > Table). Tables add structured references and are easier to extend than fixed ranges.
- Start your total rows with a blank row or a clear label so filters do not accidentally swallow them.
- For multi-condition totals, SUBTOTAL alone is not enough — pair it with SUMPRODUCT or use a pivot table, which recalculates based on the filters you apply to the pivot fields.
- If you want the filtered total to follow a slicer, use a pivot table rather than SUBTOTAL. Slicers drive pivot fields, not ordinary filters.
- Press F4 while editing to lock ranges with dollar signs so copy-down totals keep pointing at the same data.
Troubleshooting
- The totals never differ when you filter. Check that filter is really on (Data > Filter) and that you are filtering the same range the formula points to. If you hid rows by hand, use 109 instead of 9.
- The SUBTOTAL result looks too small. The range may be clipped, or a nested SUBTOTAL inside it is being skipped. Widen the range and re-check.
- You get an error like #VALUE!. Confirm the first argument is a function number (9 or 109) and not a cell reference, and that the numbers in the range are true numbers.
- The total changes when nothing should have changed. Look for a filter on a different column, or rows hidden with a group/outline collapse — groups count as hidden rows for 109.
- You see #CIRCULAR REFERENCE. The formula's range includes its own cell. Move the total below the data or shrink the range.
- A subtotal row in grouped data double counts. The grand total range includes the inserted subtotal rows. Point the grand total at the detail rows only, or rely on SUBTOTAL's behaviour of ignoring nested subtotals.
- If that did not work, rebuild the test on a small copy of a handful of rows. Reproduce it with five values and one filter, confirm the difference, then apply the same formula pattern to your real data.
Frequently Asked Questions
Does SUBTOTAL include hidden rows?
It depends on the function number. 9 ignores rows hidden by a filter. 109 ignores both filtered rows and rows you hide manually. Neither deletes anything.
Can I use SUBTOTAL for average, count or max?
Yes. Use 1 for AVERAGE, 2 for COUNT, 3 for COUNTA, 4 for MAX, 5 for MIN, and add 100 to each (101, 102 and so on) to exclude manually hidden rows as well.
Why does my SUM total not change when I filter?
That is how SUM works — it adds every value in the range regardless of visibility. Switch to SUBTOTAL(9,range) if the total should match what is on screen.
Is SUBTOTAL the same as the Subtotal command on the Data tab?
They are related. The Data > Subtotal command inserts group totals that use the SUBTOTAL function. The function itself can be typed anywhere and calculates over whatever range you give it.
Does SUBTOTAL work with pivot tables or slicers?
Not directly. SUBTOTAL responds to worksheet filters, not pivot slicers. For totals that follow a slicer, use the pivot table's own total row or a calculated field.
Can SUBTOTAL count text instead of numbers?
Yes, with 3 for COUNTA (or 103 to also skip manually hidden rows). It counts non-empty cells rather than numeric values.