Is there a way to emulate COUNTIF in a filtered table?

adambc

Active Member
Joined
Jan 13, 2020
Messages
373
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I’ve seen a number of SUMPRODUCT based workarounds, but they don’t seem to allow me to use TableName[ColumnName]?

I have a table that is the result of taking data from 3 source tables, which is then heavily filtered (multi column filtering, c. 2000 down to c. 750 records) to only display the records required (and before you ask, PowerQuery doesn’t do it because sometimes I need to unstack the filtering so cannot loose the filtered records) …

I have 2 columns (EmailAddress and TrainingCompleted) that I want to use to derive a % …

EmailAddress is easy because it’s email addresses so I can use =SUBTOTAL(103, Table1[EmailAddress]) …

But TrainingCompleted is a problem because it contains ONLY ”TRUE” or “FALSE” which are the result of an ISNUMBER based formula so =COUNTIF(Table1[TrainingCompleted], “TRUE”) picks up filtered AND non filtered rows …

Is there a way I can get a total of the number of rows with “TRUE” in TrainingCompleted, but only the filtered rows?

Thanks …
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Why not create a helper column using
Excel Formula:
=subtotal(103,[@TrainingCompleted])
then you can add that column as an extra criteria in your Countifs
 
Upvote 0
Solution
The Subtotal will work or you could use SumProduct.

T202303a.xlsm
ABC
14
2TRUE3
3Percentage75%
4EmailTrainingYear
11yyyTRUE2022
12yyyTRUE2023
13yyyTRUE2022
14yyyFALSE2022
15
1e
Cell Formulas
RangeFormula
B1B1=SUBTOTAL(103,Table2[Training])
B2B2=SUMPRODUCT(--(Table2[Email]="yyy"),--(Table2[Training]=TRUE))
B3B3=B2/B1
B14B14=C14=YEAR(TODAY())
 
Upvote 0
The Subtotal will work or you could use SumProduct.

T202303a.xlsm
ABC
14
2TRUE3
3Percentage75%
4EmailTrainingYear
11yyyTRUE2022
12yyyTRUE2023
13yyyTRUE2022
14yyyFALSE2022
15
1e
Cell Formulas
RangeFormula
B1B1=SUBTOTAL(103,Table2[Training])
B2B2=SUMPRODUCT(--(Table2[Email]="yyy"),--(Table2[Training]=TRUE))
B3B3=B2/B1
B14B14=C14=YEAR(TODAY())
@Dave Patton

My filtered list has unique email addresses in the Email column, so not sure this will work?

But thanks for trying to help me …
 
Upvote 0
Why not create a helper column using
Excel Formula:
=subtotal(103,[@TrainingCompleted])
then you can add that column as an extra criteria in your Countifs
@Fluff

Was hoping there was a solution without using a helper column - but always thought this would be the only answer!

Thanks for the reply …
 
Upvote 0
N.B. You did not provide any sample data or examples of your calculations.
You can post a concise version of your sheet with the forum's tool named XL2BB.

Instead of showing True or False, coerce the formulas that Yield True or False to show 1 or 0.
This is often done with double negative or +0
=--(formula xxx)

T202303a.xlsm
AB
18Completed50%
19
20EmailTraining
21xxx1
25xxx41
27yyy0
28yyy0
29yyy1
30yyy0
1e
Cell Formulas
RangeFormula
B18B18=SUBTOTAL(109,Table22[Training])/SUBTOTAL(103,Table22[Training])


T202303a.xlsm
AB
176
18TRUE is 13
19Percentage50%
20EmailTraining
21xxx1
25xxx41
27yyy0
28yyy0
29yyy1
30yyy0
31
1e
Cell Formulas
RangeFormula
B17B17=SUBTOTAL(103,Table22[Training])
B18B18=SUBTOTAL(109,Table22[Training])
B19B19=B18/B17
 
Upvote 0
N.B. You did not provide any sample data or examples of your calculations.
You can post a concise version of your sheet with the forum's tool named XL2BB.

Instead of showing True or False, coerce the formulas that Yield True or False to show 1 or 0.
This is often done with double negative or +0
=--(formula xxx)

T202303a.xlsm
AB
18Completed50%
19
20EmailTraining
21xxx1
25xxx41
27yyy0
28yyy0
29yyy1
30yyy0
1e
Cell Formulas
RangeFormula
B18B18=SUBTOTAL(109,Table22[Training])/SUBTOTAL(103,Table22[Training])


T202303a.xlsm
AB
176
18TRUE is 13
19Percentage50%
20EmailTraining
21xxx1
25xxx41
27yyy0
28yyy0
29yyy1
30yyy0
31
1e
Cell Formulas
RangeFormula
B17B17=SUBTOTAL(103,Table22[Training])
B18B18=SUBTOTAL(109,Table22[Training])
B19B19=B18/B17
@Dave Patton

That might just work, will let you know …

Many thanks …
 
Upvote 0
I intended to post the following

T202303a.xlsm
AB
1
2Completed50%
3
4EmailTraining
5xxx1
9xxx41
11yyy0
12yyy0
13yyy1
14yyy0
15
1e
Cell Formulas
RangeFormula
B2B2=SUBTOTAL(109,Table1[Training])/SUBTOTAL(103,Table1[Email])
 
Upvote 0

Forum statistics

Threads
1,215,091
Messages
6,123,062
Members
449,089
Latest member
ikke

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