How to count cells in range, with multiple criteria OR how to filter range for countif/counta/subtotal etc

StackOverflow https://stackoverflow.com/questions/20084750

  •  02-08-2022
  •  | 
  •  

Question

I am trying to count the number of non-empty cells in a range (H5 to J13), where another cell (in column G) also matches a text string from a different cell. I am using a spreadsheet on Google Docs so unfortunately COUNTIFS is not available.

All of these formulas work fine to count non-empty cells in the range:

  • =COUNTIF(H5:J13, "<>"&"")
  • =SUBTOTAL(3, H5:J13)
  • =COUNTA(H5:J13)

However, it seems none of those allow me to filter the range H5:J13 before it counts the cells. Can anyone help with this, or propose a different solution?

The practical application is like this...

THE DATA

Column G shows the staff member rostered, columns H through J show if someone else taught that class instead, on particular dates.

COLUMN G --- COLUMN H  --- COLUMN I --- COLUMN J
________________________________________________
ROSTERED --- CLASS 1  ---- CLASS 2 ---- CLASS 3
________________________________________________
Sally ------ [blank] ----- Sue --------- [blank]
Bob -------- Sally ------- Sue --------- [blank]
Sue -------- [blank] ----- [blank] ----- [blank]

WHAT I WANT TO CALCULATE

I want to count the number of times that each staff member (Column G) has someone else teach their class (evident by non-empty cells in H through J of that row). For example:

COLUMN P --- COLUMN Q  
_____________________
STAFF ------ MISSED  
_____________________
Sally --------- 1 ---
Bob ----------- 2 ---
Sue ----------- 0 ---

I thought I could put FILTER(H5:J13, G:G=P4) as the range in the COUNTA or COUNTIF formulas, but I get errors doing this. As mentioned, I cannot used COUNTIFS (which sounds like it would be perfect) as it's not yet supported by Google Docs.

Thanks in advance for your help!

Was it helpful?

Solution

I'm not sure if Google Docs accepts array formulas but if it does this formula should work, enter by pressing ctrl+shift+enter. (in excel)

=sum(if(H5:J13<>"",if(G5:G13=P4,1,0),0))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top