# Summing with Filters in Excel, Reminding Yourself “Why”

- Link: https://cagrimmett.com/2016/03/07/summing-with-filters/
- Published: 2016-03-07T05:00:00-05:00
- Author: Chuck Grimmett

### Today I learned:

#### Summing in Excel with Filters

If you’ve ever tried to write a `sum()` function in Excel while you have filters
on, you likely didn’t get the result you expected. The `sum()` function adds up 
what is in the raw cells. It does not take whether or not they’ve been hidden via
a filter into account.

`subtotal()` is the function you are looking for. Specifically, `subtotal(9,range)`.
The 9 refers to sum for hidden (not at a result of filtering, though) and non-hidden
rows. [See the documentation.](https://support.office.com/en-us/article/SUBTOTAL-function-7B027003-F060-4ADE-9040-E478765B9939)`
subtotal()` functions only on the results of filtered data.

`=SUBTOTAL(9,G1670:G640501)` gave me the sum of the the filtered data from G1670
to G640501. (You can see why filtering would be important with such a large data
set!)

---

#### Remind yourself _why_

Sometimes I spend too much time and effort trying to convince myself to do something
I don’t want to do. This leads to general angst and despair.

My wife reminded me yesterday that the best way of convincing myself is to reflect
on _why_ I’m doing it in the first place.

Whatever your reason _why_ is, as long as it outweighs the cost of not doing it,
you’ll get over it and find a way. I keep an index card with some _why_ bullet points
on it nearby to keep things in perspective.
