Search code examples
google-sheets

Google Sheets - Count >0 in a table, with column and row matching/criteria


Maybe I am having a block, but is there any way to count the following:

I have a table with Fruits/Type and monthly sales.

Google Sheets Here:

I can SUM the sales for the criteria (dropdown) with:

=sumproduct( if( regexmatch( A2:A11, G1)* regexmatch( B2:B11,H1) * regexmatch( C1:E1,I1), C2:E11, "") )

Which will sum the number of Apples, Natural, in Jan.

Can I count how many times was sold? B17 should be 2 and B18 should be 4

I tried several ways, even with simpler formulas, but now I am confused.


Solution

  • You may test:

    =counta(ifna(filter(filter(C:E,if(I1="",C1:E1=C1:E1,C1:E1=I1)),if(G1="",1,A:A=G1)*(if(H1="",1,B:B=H1)))))
    

    enter image description here