Calculate Filtered Values (with Criteria)

wasteland

New Member
Joined
Jun 12, 2008
Messages
4
Hello-

I have found a lot of answers on boards like these, but not a lot of time to give back. Hopefully this will benefit someone...

Seems that the concensus for calculating filtered rows AND to be able to apply criteria is to use SumProduct like this:
SUMPRODUCT(--(C3:C9=C14),--(G3:G9=B15),SUBTOTAL(9, OFFSET(H3:H9,ROW(H3:H9)-ROW(H3),0,1)))
I tried that and tried UDFs (like IsHidden) and everything seemed convoluted and/or slow.


This has worked well for me...


In the table or range of data, enter a new column named "Filtered" and add the following formula:
= - - SUBTOTAL(2,A2)
This will give a count of the row in which the formula resides. If the row is hidden (filtered), it will return 0. If not hidden, it will return 1.

The double unary ( - -) is used to change the TRUE/FALSE to 1/0 values.
It is also necessary because at the end of a table or range, Excel apparently determines that certain Subtotal rows should not be counted.

So now that there is a Filtered flag, it can be used in any criteria.

Can still use SumProduct- just don't need the SubTotal and Offset part.

In Excel 2007, with structured naming and SumIFS, formulas are a lot cleaner:
=SUMIFS(Sales[Cost],Sales[Filtered],1,Sales[Month Sold],CurrentMonth)
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,225,399
Messages
6,184,748
Members
453,254
Latest member
topeb

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