Google Sheets Pattern Matching/RegEx for COUNTIF

前端 未结 2 873
不知归路
不知归路 2021-02-12 15:26

The documentation for pattern matching for Google Sheets has not been helpful. I\'ve been reading and searching for a while now and can\'t find this particular issue. Maybe I\'m

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-12 16:12

    This is a really big hammer for a problem like yours, but you can use QUERY to do something like this:

    =QUERY(E9:E13, "select count(E) where E matches '50-03[123][012]' label count(E) ''")
    

    The label bit is to prevent QUERY from adding an automatic header to the count() column.

    The nice thing about this approach is that you can pull in other columns, too. Say that over in column H, you have a number of orders for each part. Then, you can take two cells and show both the count of parts and the sum of orders:

    =QUERY(E9:H13, "select count(E), sum(H) where E matches '50-03[123][012]' label count(E) '', sum(H) ''")
    

    I routinely find this question on $searchEngine and fail to notice that I linked another question with a similar problem and other relevant answers.

提交回复
热议问题