Count the number of times a subject appears in a list created by the use of FILTER function

William53

New Member
Joined
Jul 8, 2017
Messages
37
Office Version
  1. 365
Platform
  1. Windows
HI All
I have created a list of rows of data when using the FILTER function to list from a table any entries that require further action.
In the further action column in the table the answer is yes or no.
I used the FILTER function to get a list of records where the further action column said "Yes"
Example here:

27-Jun-23​
TueJun23HousekeepingUnsafe ConditionYesSome areas required attention, Bailey Bridge area, under Piperack 1 at grade, 1st lift scaffold South of stack duct ISBL.Open
27-Jun-23​
TueJun23HousekeepingUnsafe ConditionYesWater bottles all over the site - picked up and disposed off in the bags and skipsClosed
28-Jun-23​
WedJun23Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
28-Jun-23​
WedJun23HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosed
28-Jun-23​
WedJun23Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosed
30-Jun-23​
FriJun23HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
01-Jul-23​
SatJul23HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
01-Jul-23​
SatJul23Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen

The above is the result from the FILTER function "=FILTER(AllObs1,AllObs1[Further Action]="Yes") I have tried to place this in a table but will not allow.
This formula expands each time there is a Yes placed in the main table (AllObs1) so no issue with the function working. I have done a countif formula to count the number of subjects in the list such as Housekeeping , Working at height etc but I cant seem to work out how to do it dynamically, e.g., as the list expands the count also expands, I have to go back and expand the range manually to include the new entries.
Any help will be greatly appreciated.
Many thanks
William
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Book3
ABCDEFGHIJKLM
1Column1Column2Column3Column4Column5Column6Column7Column8Column916Housekeeping1Condition
227-Jun-23TueJun23HousekeepingUnsafe ConditionYesSome areas required attention, Bailey Bridge area, under Piperack 1 at grade, 1st lift scaffold South of stack duct ISBL.Open7Work at Height2Condition Work at Height with Yes
327-Jun-23TueJun24HousekeepingUnsafe ConditionYesWater bottles all over the site - picked up and disposed off in the bags and skipsClosed18Housekeeping or work at height ( height that Closed)
428-Jun-23WedJun25Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
528-Jun-23WedJun26HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosedOr +
628-Jun-23WedJun27Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosedAnd *
730-Jun-23FriJun28HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
801-Jul-23SatJul29HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
901-Jul-23SatJul30Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
1028-Jun-23WedJun31Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
1128-Jun-23WedJun32HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosed
1228-Jun-23WedJun33Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosed
1330-Jun-23FriJun34HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
1401-Jul-23SatJul35HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
1501-Jul-23SatJul36Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
1627-Jun-23TueJun37HousekeepingUnsafe ConditionNOSome areas required attention, Bailey Bridge area, under Piperack 1 at grade, 1st lift scaffold South of stack duct ISBL.Open
1727-Jun-23TueJun38HousekeepingUnsafe ConditionNOWater bottles all over the site - picked up and disposed off in the bags and skipsClosed
1828-Jun-23WedJun39Work at HeightUnsafe ConditionNOLoose materials on scaffolds at height - removed in the shiftClosed
1928-Jun-23WedJun40HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosed
2028-Jun-23WedJun41Environmental HealthUnsafe ConditionNoFireproofing shed not sealed off causing dust issue - completed during the nightClosed
2130-Jun-23FriJun42HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
2201-Jul-23SatJul43HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
2301-Jul-23SatJul44Work at HeightUnsafe ConditionNoHousekeeping RequiredOpen
2428-Jun-23WedJun45Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
2528-Jun-23WedJun46HousekeepingUnsafe ConditionNoNeeded at height on scaffolds - undertaken during the nightClosed
2628-Jun-23WedJun47Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosed
2730-Jun-23FriJun48HousekeepingUnsafe ConditionNoSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
2801-Jul-23SatJul49HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
2901-Jul-23SatJul50Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
3001-Jul-23SatJul50Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
Sheet1
Cell Formulas
RangeFormula
K1K1=COUNT(FILTER(AllObs1,(AllObs1[Column5]="Housekeeping")))
K2K2=COUNT(FILTER(AllObs1,(AllObs1[Column5]=L2)*(AllObs1[Column7]="Yes")))
K3K3=COUNT(FILTER(AllObs1,((AllObs1[Column5]="Work at Height")+(AllObs1[Column5]="Housekeeping"))*(AllObs1[Column9]="Closed")))
Named Ranges
NameRefers ToCells
_FilterDatabase=Sheet1!$A$30:$I$30K1:K3


Is it what you're looking into? CMIIW

FYR
 
Upvote 0
How about
Excel Formula:
=LET(u,UNIQUE(INDEX(A2#,,5)),HSTACK(u,COUNTIFS(INDEX(A2#,,5),u)))
Change the A2# to the cell with the filter function.
 
Upvote 0
Book3
ABCDEFGHIJKLM
1Column1Column2Column3Column4Column5Column6Column7Column8Column916Housekeeping1Condition
227-Jun-23TueJun23HousekeepingUnsafe ConditionYesSome areas required attention, Bailey Bridge area, under Piperack 1 at grade, 1st lift scaffold South of stack duct ISBL.Open7Work at Height2Condition Work at Height with Yes
327-Jun-23TueJun24HousekeepingUnsafe ConditionYesWater bottles all over the site - picked up and disposed off in the bags and skipsClosed18Housekeeping or work at height ( height that Closed)
428-Jun-23WedJun25Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
528-Jun-23WedJun26HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosedOr +
628-Jun-23WedJun27Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosedAnd *
730-Jun-23FriJun28HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
801-Jul-23SatJul29HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
901-Jul-23SatJul30Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
1028-Jun-23WedJun31Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
1128-Jun-23WedJun32HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosed
1228-Jun-23WedJun33Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosed
1330-Jun-23FriJun34HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
1401-Jul-23SatJul35HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
1501-Jul-23SatJul36Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
1627-Jun-23TueJun37HousekeepingUnsafe ConditionNOSome areas required attention, Bailey Bridge area, under Piperack 1 at grade, 1st lift scaffold South of stack duct ISBL.Open
1727-Jun-23TueJun38HousekeepingUnsafe ConditionNOWater bottles all over the site - picked up and disposed off in the bags and skipsClosed
1828-Jun-23WedJun39Work at HeightUnsafe ConditionNOLoose materials on scaffolds at height - removed in the shiftClosed
1928-Jun-23WedJun40HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosed
2028-Jun-23WedJun41Environmental HealthUnsafe ConditionNoFireproofing shed not sealed off causing dust issue - completed during the nightClosed
2130-Jun-23FriJun42HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
2201-Jul-23SatJul43HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
2301-Jul-23SatJul44Work at HeightUnsafe ConditionNoHousekeeping RequiredOpen
2428-Jun-23WedJun45Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
2528-Jun-23WedJun46HousekeepingUnsafe ConditionNoNeeded at height on scaffolds - undertaken during the nightClosed
2628-Jun-23WedJun47Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosed
2730-Jun-23FriJun48HousekeepingUnsafe ConditionNoSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
2801-Jul-23SatJul49HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
2901-Jul-23SatJul50Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
3001-Jul-23SatJul50Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
Sheet1
Cell Formulas
RangeFormula
K1K1=COUNT(FILTER(AllObs1,(AllObs1[Column5]="Housekeeping")))
K2K2=COUNT(FILTER(AllObs1,(AllObs1[Column5]=L2)*(AllObs1[Column7]="Yes")))
K3K3=COUNT(FILTER(AllObs1,((AllObs1[Column5]="Work at Height")+(AllObs1[Column5]="Housekeeping"))*(AllObs1[Column9]="Closed")))
Named Ranges
NameRefers ToCells
_FilterDatabase=Sheet1!$A$30:$I$30K1:K3


Is it what you're looking into? CMIIW

FYR
Hi RudRud
Thanks for such a prompt reply appreciated.
The two formula in K1 and K2 work fine apart from the fact that it is counting the number of entries twice.
E.g., Housekeeping in the main table is 208 times and formula gives me 416, Working at height with a yes is 17 but formula gives me 34.
Can you help?
Thanks
William
 
Upvote 0
Hi RudRud
Thanks for such a prompt reply appreciated.
The two formula in K1 and K2 work fine apart from the fact that it is counting the number of entries twice.
E.g., Housekeeping in the main table is 208 times and formula gives me 416, Working at height with a yes is 17 but formula gives me 34.
Can you help?
Thanks
William

Book1
ABCDEFGHIJKL
1Column1Column2Column3Column4Column5Column6Column7Column8Column916Housekeeping
227-Jun-23TueJun23HousekeepingUnsafe ConditionYesSome areas required attention, Bailey Bridge area, under Piperack 1 at grade, 1st lift scaffold South of stack duct ISBL.Open7Work at Height
327-Jun-23TueJun24HousekeepingUnsafe ConditionYesWater bottles all over the site - picked up and disposed off in the bags and skipsClosed18
428-Jun-23WedJun25Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
528-Jun-23WedJun26HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosed
628-Jun-23WedJun27Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosed
730-Jun-23FriJun28HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
81-Jul-23SatJul29HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
91-Jul-23SatJul30Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
1028-Jun-23WedJun31Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
1128-Jun-23WedJun32HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosed
1228-Jun-23WedJun33Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosed
1330-Jun-23FriJun34HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
141-Jul-23SatJul35HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
151-Jul-23SatJul36Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
1627-Jun-23TueJun37HousekeepingUnsafe ConditionNOSome areas required attention, Bailey Bridge area, under Piperack 1 at grade, 1st lift scaffold South of stack duct ISBL.Open
1727-Jun-23TueJun38HousekeepingUnsafe ConditionNOWater bottles all over the site - picked up and disposed off in the bags and skipsClosed
1828-Jun-23WedJun39Work at HeightUnsafe ConditionNOLoose materials on scaffolds at height - removed in the shiftClosed
1928-Jun-23WedJun40HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosed
2028-Jun-23WedJun41Environmental HealthUnsafe ConditionNoFireproofing shed not sealed off causing dust issue - completed during the nightClosed
2130-Jun-23FriJun42HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
221-Jul-23SatJul43HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
231-Jul-23SatJul44Work at HeightUnsafe ConditionNoHousekeeping RequiredOpen
2428-Jun-23WedJun45Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
2528-Jun-23WedJun46HousekeepingUnsafe ConditionNoNeeded at height on scaffolds - undertaken during the nightClosed
2628-Jun-23WedJun47Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosed
2730-Jun-23FriJun48HousekeepingUnsafe ConditionNoSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
281-Jul-23SatJul49HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
291-Jul-23SatJul50Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
301-Jul-23SatJul50Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
Sheet1
Cell Formulas
RangeFormula
K1K1=ROWS(FILTER(AllObs1,(AllObs1[Column5]="Housekeeping")))
K2K2=ROWS(FILTER(AllObs1,(AllObs1[Column5]=L2)*(AllObs1[Column7]="Yes")))
K3K3=ROWS(FILTER(AllObs1,((AllObs1[Column5]="Work at Height")+(AllObs1[Column5]="Housekeeping"))*(AllObs1[Column9]="Closed")))


Hi @William53 , Please change COUNT into ROWS instead, Apologies for the confusion
 
Upvote 0
Solution
Book1
ABCDEFGHIJKL
1Column1Column2Column3Column4Column5Column6Column7Column8Column916Housekeeping
227-Jun-23TueJun23HousekeepingUnsafe ConditionYesSome areas required attention, Bailey Bridge area, under Piperack 1 at grade, 1st lift scaffold South of stack duct ISBL.Open7Work at Height
327-Jun-23TueJun24HousekeepingUnsafe ConditionYesWater bottles all over the site - picked up and disposed off in the bags and skipsClosed18
428-Jun-23WedJun25Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
528-Jun-23WedJun26HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosed
628-Jun-23WedJun27Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosed
730-Jun-23FriJun28HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
81-Jul-23SatJul29HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
91-Jul-23SatJul30Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
1028-Jun-23WedJun31Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
1128-Jun-23WedJun32HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosed
1228-Jun-23WedJun33Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosed
1330-Jun-23FriJun34HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
141-Jul-23SatJul35HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
151-Jul-23SatJul36Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
1627-Jun-23TueJun37HousekeepingUnsafe ConditionNOSome areas required attention, Bailey Bridge area, under Piperack 1 at grade, 1st lift scaffold South of stack duct ISBL.Open
1727-Jun-23TueJun38HousekeepingUnsafe ConditionNOWater bottles all over the site - picked up and disposed off in the bags and skipsClosed
1828-Jun-23WedJun39Work at HeightUnsafe ConditionNOLoose materials on scaffolds at height - removed in the shiftClosed
1928-Jun-23WedJun40HousekeepingUnsafe ConditionYesNeeded at height on scaffolds - undertaken during the nightClosed
2028-Jun-23WedJun41Environmental HealthUnsafe ConditionNoFireproofing shed not sealed off causing dust issue - completed during the nightClosed
2130-Jun-23FriJun42HousekeepingUnsafe ConditionYesSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
221-Jul-23SatJul43HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
231-Jul-23SatJul44Work at HeightUnsafe ConditionNoHousekeeping RequiredOpen
2428-Jun-23WedJun45Work at HeightUnsafe ConditionYesLoose materials on scaffolds at height - removed in the shiftClosed
2528-Jun-23WedJun46HousekeepingUnsafe ConditionNoNeeded at height on scaffolds - undertaken during the nightClosed
2628-Jun-23WedJun47Environmental HealthUnsafe ConditionYesFireproofing shed not sealed off causing dust issue - completed during the nightClosed
2730-Jun-23FriJun48HousekeepingUnsafe ConditionNoSkips and bags need removing from west of ISBL - all done and emptied and removedClosed
281-Jul-23SatJul49HousekeepingUnsafe ConditionYesHousekeeping on Pipe Rack 1 needs to be undertaken - full of clips and bandingsClosed
291-Jul-23SatJul50Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
301-Jul-23SatJul50Work at HeightUnsafe ConditionYesHousekeeping RequiredOpen
Sheet1
Cell Formulas
RangeFormula
K1K1=ROWS(FILTER(AllObs1,(AllObs1[Column5]="Housekeeping")))
K2K2=ROWS(FILTER(AllObs1,(AllObs1[Column5]=L2)*(AllObs1[Column7]="Yes")))
K3K3=ROWS(FILTER(AllObs1,((AllObs1[Column5]="Work at Height")+(AllObs1[Column5]="Housekeeping"))*(AllObs1[Column9]="Closed")))


Hi @William53 , Please change COUNT into ROWS instead, Apologies for the confusion
HI RudRud
Initially I just added "/2" to your formula and it got the result but the solution above works perfectly, thank you very much
Works fine now
 
Upvote 0
Did you try the formula I suggested?
 
Upvote 0
HI RudRud
Initially I just added "/2" to your formula and it got the result but the solution above works perfectly, thank you very much
Works fine now

Glad to assist, If you have any further questions, please don't hesitate to ask/share with us :)
 
Upvote 0
Did you try the formula I suggested?
Hi Fluff
My knowledge of the LET formula left me a bit nervous to follow it. So I read up on it and watched some videos and then applied it my Filtered formula and it works perfectly. Thank you for taking the time to enlighten me on the LET formula.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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