SUBTOTAL with COUNTIFS

SFCChase

Board Regular
Joined
Jun 25, 2013
Messages
114
Office Version
  1. 2016
Platform
  1. Windows
Is it possible to combine SUBTOTAL and COUNTIFS?

I have a data set that will change depending on filtering various columns. Currently I'm using the following formulas:

Cell E2: =COUNTIFS($B$5:$B$160, "<>",E5:E160,">="&TODAY())+COUNTIFS($B$5:$B$160, "<>",E5:E160,"N/A") Counts # of trainings that are not expired as of today
Cell E3: =COUNTIF($B$5:$B$160,"") Counts # of personnel assigned
Cell E4: =IF(E2=0,"",E2/E3) Calculates overall completion percentage (# of non-expired trainings/# of assigned personnel)

I would like the value of Cell H8 to change based on the # of assigned personnel shown when I filter Column A.

I have figured out a SUBTOTAL formula that will work for Cell E3 (=SUBTOTAL(3,$B$5:$B$160), but I can't figure out a SUBTOTAL for Cell E2 and therefore end up with % over 100% when I filter.

TRAINING 1
# TRAINED
# REQUIRED
UNITLASTFIRST% TRAINED
DCNADAMSAARON5/20/25
DCNJONESJOHN2/1/25
IPSLMICHAELSMICHAEL5/20/25
IPSLJULESJULIEN/A
IPSL
MSUSNUFFYJOE3/25/25
MSUBAKERBARNEY3/24/25
MSULEWISLOU2/1/25
MSUJUAREZJUANN/A
MSUSMITHSAM3/21/25

Given the data above....if I leave unfiltered:
E2=7
E3=9
E4=77.78%

If I filter Column A to only calculate "DCN" numbers I would like to result:
E2=1
E3=2
E4=50.00%

If I filter Column A to only calculate "MSU" numbers I would like to result:
E2=4
E3=5
E4=80.00%

Any suggestions would be appreciated!
 
I'm struggling somewhat with that. How does counting blanks equate to the number of personnel assigned?
So, I am assuming that E3 should count the names in column B & have adjusted the E3 formula to do that.
For the filtering I have suggested some formulas in F2:F4. If the only choices in column E are Date, "N/A" or blank (& the col E values are not the result of formulas) then the F2 formula could be simplified to
Excel Formula:
=SUMPRODUCT(--(B6:B161<>""),--(E6:E161>=TODAY()),SUBTOTAL(103,OFFSET(B6,ROW(B6:B161)-ROW(B6),1,1)))

25 03 08.xlsm
ABCDEF
1TRAINING 1
2# TRAINED77
3# REQUIRED99
4UNITLASTFIRST% TRAINED77.78%77.78%
5DCNADAMSAARON20/05/2025
6DCNJONESJOHN1/02/2025
7IPSLMICHAELSMICHAEL20/05/2025
8IPSLJULESJULIEN/A
9IPSL
10MSUSNUFFYJOE25/03/2025
11MSUBAKERBARNEY24/03/2025
12MSULEWISLOU1/02/2025
13MSUJUAREZJUANN/A
14MSUSMITHSAM21/03/2025
15
ST
Cell Formulas
RangeFormula
E2E2=COUNTIFS($B$5:$B$160, "<>",E5:E160,">="&TODAY())+COUNTIFS($B$5:$B$160, "<>",E5:E160,"N/A")
F2F2=SUMPRODUCT(--(B5:B160<>""),--((E5:E160>=TODAY())+(E5:E160="N/A")>0),SUBTOTAL(103,OFFSET(B5,ROW(B5:B160)-ROW(B5),1,1)))
E3E3=COUNTA($B$5:$B$160)
F3F3=SUBTOTAL(103,B5:B160)
E4:F4E4=IF(E2=0,"",E2/E3)


After filtering ..

25 03 08.xlsm
ABCDEF
1TRAINING 1
2# TRAINED71
3# REQUIRED92
4UNITLASTFIRST% TRAINED77.78%50.00%
5DCNADAMSAARON20/05/2025
6DCNJONESJOHN1/02/2025
161
ST
Cell Formulas
RangeFormula
E2E2=COUNTIFS($B$5:$B$160, "<>",E5:E160,">="&TODAY())+COUNTIFS($B$5:$B$160, "<>",E5:E160,"N/A")
F2F2=SUMPRODUCT(--(B5:B160<>""),--((E5:E160>=TODAY())+(E5:E160="N/A")>0),SUBTOTAL(103,OFFSET(B5,ROW(B5:B160)-ROW(B5),1,1)))
E3E3=COUNTA($B$5:$B$160)
F3F3=SUBTOTAL(103,B5:B160)
E4:F4E4=IF(E2=0,"",E2/E3)
 
Upvote 0

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