RRTW
RRTW

Reputation: 3190

MS Excel, G Sheet, count multiple condition with OR logic

Says I have some data, and I would like to count if it was "CC" or "DD". Here's what I did in Microsoft Excel and Google Sheet.

=sum(countifs(A2:A10, {"CC", "DD"}))

In MS Excel, it seems ok, but not in G Sheet.

I have to do this in G Sheet to get same result:

=countif(A2:A10, "CC") + =countif(A2:A10, "DD")

Any smarter way to do this in G Sheet ?

My sample :

enter image description here

Upvotes: 0

Views: 56

Answers (2)

player0
player0

Reputation: 1

use in Google Sheets:

=ARRAYFORMULA(SUM(IF(REGEXMATCH(A:A, "CC|DD"), 1, )))

Upvotes: 1

BigBen
BigBen

Reputation: 50008

This is an array formula.

In Google Sheets: =arrayformula(sum(countifs(A2:A10, {"CC", "DD"})))

enter image description here In older versions of Excel, you would have had to confirm this with Ctrl+Shift+Enter. It is also an array formula.

Upvotes: 1

Related Questions