Reputation: 3190
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 :
Upvotes: 0
Views: 56
Reputation: 1
use in Google Sheets:
=ARRAYFORMULA(SUM(IF(REGEXMATCH(A:A, "CC|DD"), 1, )))
Upvotes: 1
Reputation: 50008
This is an array formula.
In Google Sheets: =arrayformula(sum(countifs(A2:A10, {"CC", "DD"})))
In older versions of Excel, you would have had to confirm this with Ctrl+Shift+Enter. It is also an array formula.
Upvotes: 1