Subtotal Function and Countif/Sumif

SpikeGiles

New Member
Joined
Oct 27, 2011
Messages
17
The subtotal function is great when working with data you want to filter several ways, but it lacks the functionality that would exist if it had a countif and a sumif code, unless I am missing something. Does this functionality exist within Excel? If not, is there a work-around?
 
Your edited code is still not working for me. It results in 0, whether I filter or not.

This is what I have in my formula cell

=SUMPRODUCT(SUBTOTAL(9,OFFSET($D$2:$D$10,ROW($D$2:$D$10)-ROW($D$2),0)),--($C$2:C$10=$C12))

My fault. While trying to change from the MIN form to the MIN-less form, I've made mistakes...

RecordTypeAmountFilter
1Tax1200A
1Fin5200B
2Tax4500C
2Fin3500B
3Tax4600B
3Fin5700B
SUMIF TOTALTax10300
Fin14400
SUBTOTAL SUMIFTax10300
Fin14400

<tbody>
</tbody>

D12, copied down:
Rich (BB code):
=SUMPRODUCT(
  SUBTOTAL(9,OFFSET($D$2,ROW($D$2:$D$7)-ROW($D$2),0)),
  --($C$2:$C$7=$C12))

Now try to filter on some item in E.
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Now it does sum okay, but when I filter the list to hide an item, it still considers it in the sum.

I also found the following in another post and same thing happens with this formula, it incorrectly includes the hidden row in the sum
If you want to sum for type "x" where types are in A1:A100 and numbers in B1:B100 you can use this formula to only sum for the visible rows
=SUMPRODUCT(SUBTOTAL(9,OFFSET(B1:B100,ROW(B1:B100)-ROW(B1),0,1,1)),--(A1:A100="x"))


<tbody>
</tbody><colgroup><col><col span="12"><col></colgroup>
 
Upvote 0
Now it does sum okay, but when I filter the list to hide an item, it still considers it in the sum.

I also found the following in another post and same thing happens with this formula, it incorrectly includes the hidden row in the sum
If you want to sum for type "x" where types are in A1:A100 and numbers in B1:B100 you can use this formula to only sum for the visible rows
=SUMPRODUCT(SUBTOTAL(9,OFFSET(B1:B100,ROW(B1:B100)-ROW(B1),0,1,1)),--(A1:A100="x"))

<tbody>
</tbody>

The formula (the last one I posted) is now correct.

The one above includes incorrectly the header row, It should be:

=SUMPRODUCT(SUBTOTAL(9,OFFSET(B2,ROW(B2:B100)-ROW(B2),0)),--(A2:A100="x"))

would be correct.

If you hide manually, use 109 instead of 9 in SUBTOTAL.
 
Upvote 0
Aladin, if you are saying that the last one in your reply #11 is the correct one, this is the one I had used for my reply #13 when I made my comment that it includes filtered hidden items in the total and it shouldn't. The other exampl (also in #13), I had adjusted for my data so I wasn't including the header rows, also includes filtered hidden items in the total. Is there a system setting or option that these formulas are including it in the sum even when hidden?
 
Upvote 0
Can you post a working formula that returns the desired result before rows are filtered/hidden?

And are rows hidden via the AutoFilter, or by right click - Hide ?
 
Upvote 0
Aladin, if you are saying that the last one in your reply #11 is the correct one, this is the one I had used for my reply #13 when I made my comment that it includes filtered hidden items in the total and it shouldn't. The other exampl (also in #13), I had adjusted for my data so I wasn't including the header rows, also includes filtered hidden items in the total. Is there a system setting or option that these formulas are including it in the sum even when hidden?

Post #11 includes a formula that effects a condtional sum. If you also apply autofilter, the formula will only pick up the visible cells.
 
Upvote 0
Sorry to resurrect such an old thread but I am having trouble adapting this information to my spreadsheet. I import data from an access DB and would like to do this same task but with two modifications.
I would like to be able to use the columns name for the range and count the number of 'FALSE' entries.
=SUBTOTAL(COUNTIF([Incident], FALSE)) is where I started and I am just now realizing how this wont work :P
I am using the 2013 suite. Do I have any chance of making this work.

-Thanks
 
Upvote 0
@_Wrok

Does this work for you?

=SUMPRODUCT(SUBTOTAL(3,OFFSET(B2,ROW(B2:B100)-ROW(B2),0)),--(A2:A100=FALSE))

where A2:A100 = Incident and B2:B100 a correlated range.
 
Upvote 0

Forum statistics

Threads
1,214,892
Messages
6,122,112
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top