Google-sheets – use “countIFS” with a filter

google sheetsgoogle-sheets-query

https://docs.google.com/spreadsheets/d/1PlPmShZ4SnkxAqBTg5xY_LHaNokGaFli4Wc7MjV_Jqo/edit?usp=sharing

I want to count how many paid is for city MB and then how many paid is for city UB.

I tried to use COUNTIFS and =COUNTA((QUERY(C4:C42, "select D where D='paid' and C='MB'", 0))) but I cannot make it work.

Somebody got an idea?

enter image description here

Best Answer

Since you have already tried the query solution, please use these two formulas:

in cell B2:

=query(D6:E10, "select count(D) where D='paid' and E='MB' label count(D) ''")

in cell D2:

=query(D6:E10, "select count(D) where D='paid' and E='UB' label count(D) ''")

You can read more about how the QUERY function works in the help center.

Note: In the end of the formula we use label count(D) ''. That translates to "take the label of the results in column D and replace it with nothing. Try omitting that part of the formula and see what happens ".