Avatar of MirageSF
MirageSF
 asked on

SUM problems on an AUtoFilter range

Hi,

If I use SUM($A$1:$A$200) I get the sum of those cells no problems as expected.

However when I autofilter and only about half are visible, the SUM goes out of sync and shows different value, what I need is it still to SUM all the cells in the defined range regardless of whether its visible/filtered or not.
Microsoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Rob Henson

8/22/2022 - Mon
Rob Henson

SUM does not normally adjust for hidden/filtered rows. There are formulas available which do adjust though, eg SUBTOTAL.

Can you upload the file showing the problem.
MirageSF

ASKER
that's exactly what I thought, however SUM is definitely going weird.  Would take me too long to strip it down to post the book.
Rob Henson

How is the filter being applied, is it just using the AutoFilter dropdowns on the column header?
Your help has saved me hundreds of hours of internet surfing.
fblack61
MirageSF

ASKER
Hi,

Yes, I have row 20 with about 10 headers, and then selected those and applied the AutoFilter
MirageSF

ASKER
Its weird, when I use the same method on my personal computer using Office 2016 it works as expected, on my works machine running 2010!  It plays up.
Rob Henson

I have found an instance where SUM does adjust.

See attached file with some random data.

I have grouped and subtotalled the data by Code in column A and then cell B56 has a SUM of the cells above.

When all rows are visible the SUM gives 151023 but when the filter is applied to column A for only one group (Q for example) it adjusts to 59565 which isn't even the sum of those visible, that should only be 13836.

Is this similar to your scenario?
SUM-issue.xlsx
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
MirageSF

ASKER
That's exactly it
Rob Henson

Don't fully understand your last comment.

So your data also has Subtotal groupings??? Is that what you're saying?
MirageSF

ASKER
Must be a bug as just uploaded work sheet to personal computer and opened and SUM works exactly as it should!.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
MirageSF

ASKER
No the SUM value gives the correct figure, then when you filter it gives a value that does not even corresepond with whats on display, when it should still have the same value as previous.
Rob Henson

I am using Excel 2013 and it doesn't work as expected, maybe it is something that MS fixed with Office 2016.

I have worked out how the SUM shows 59565 in the sample I uploaded but cannot explain why.

In the sample, the true total of all items (subtotalled) is 50341, the total of items in Q is 4612. The 59565 is the overall total plus the items showing plus the total of those items ie Q doubled up.
MirageSF

ASKER
I also wrote a function 2 methods to calculate the range, and both of them are effected by filtering when they shouldn't be.  Damn, without that got to reference a different sheet to get my required results
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Rob Henson

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
MirageSF

ASKER
The PLOT thickens,  if I opt out/in on the filter for any of the values for example unlick 0 to view all values except those with 0 then it works fine, as soon as I as the filters above that i.e. sort by Highest first etc, then the sum goes mad
Rob Henson

Removing 0 from any filter is not going to have any impact on the sum as it is just removing cells that didn't provide anything to the total in the first place.
MirageSF

ASKER
Was just an example, I can remove anything and the SUM remains the overall TOTAL regardless, but soon as I select either of the SORT options it breaks
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Rob Henson

To be of any further help I think we are going to need to see the workbook.