How to count only true values of a column when filter other columns

gm91

New Member
Joined
Dec 8, 2020
Messages
7
Office Version
  1. 2019
Platform
  1. MacOS
Hi all. I have an excel sheet with the following columns:

COLUMN ACOLUMN B
TRUEPREMIER LEAGUE
FALSECHAMPIONS LEAGUE
TRUELIGUE 1
FALSEPREMIER LEAGUE
FALSECHAMPIONS LEAGUE
FALSEPREMIER LEAGUE
TRUELIGA

I would to create a cell C1 with the percentage of true values for each filtered value of column B. So, if I filter with 'PREMIER LEAGUE' value in column B I want the percentage of true values for this occurrence. It is possible in excel?
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Does

Excel Formula:
=COUNTIF(A1:A7;TRUE())/COUNTA(A1:A7)

give you the result you expect?
 
Upvote 0
Try:
Excel Formula:
=COUNTIFS(A2:A8,"true",B2:B8,"premier league")/COUNTIF(B2:B8,"premier league")
 
Upvote 0
@hrayani Unfortunately, this formula doesn't work. Among other things, it must be dynamic (otherwise it filters only by 'PREMIER LEAGUE' value. So if filtering for example by 'LIGA' value no longer works)
 
Upvote 0
@eirikdaude I have used the recipe of the article in this way:

=SUMPRODUCT((SUBTOTAL(3,OFFSET(B2:B,ROW(B2:B)-MIN(ROW(B2:B)),,true)))*(A2:A=true))

but dosn't work very well (works well when the filter is not applied on column B. When the filter is applied it does not work). Where am i wrong?
 
Upvote 0
Tbh, it looked like an absolute pain to figure out and implement, so I was hoping you'd figure it out from the thread @gm91 but it looked like the OP in that post obtained their objective if you look at the end of the thread.

I'll have a closer look on it and see if I can figure it out, but it might take a little while :)
 
Upvote 0
VBA Code:
=SUMPRODUCT(SUBTOTAL(3;OFFSET(A2:A8;ROW(A2:A8)-MIN(ROW(A2:A8));;1))*((A2:A8)=TRUE()))
@gm91 Does this do the job as expected? You'll have to replace the semicolons with commas if that is your argument separator.
 
Upvote 0
VBA Code:
=SUMPRODUCT(SUBTOTAL(3;OFFSET(A2:A8;ROW(A2:A8)-MIN(ROW(A2:A8));;1))*((A2:A8)=TRUE()))
@gm91 Does this do the job as expected? You'll have to replace the semicolons with commas if that is your argument separator.
@eirikdaude The syntax is now correct but it continues to work only if I don't use filters on column B
 
Upvote 0
Try this to get the percentage of True Values:

=SUMPRODUCT(SUBTOTAL(3,OFFSET(A2:A8,ROW(A2:A8)-MIN(ROW(A2:A8)),,1))*((A2:A8)=TRUE()))/SUMPRODUCT(SUBTOTAL(3,OFFSET(A2:A8,ROW(A2:A8)-MIN(ROW(A2:A8)),,1)))
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,542
Members
449,169
Latest member
mm424

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