How to filter using multiple keywords in google sheets or excel

点点圈 提交于 2021-02-07 10:41:12

问题


I'm using google sheets, and I've been trying to filter data based on if the B value contains any of multiple keywords. I'm trying to sort account data, and the names aren't consistent, so I can't just say =FILTER(C:C,(B:B="BK's Stuff")+(B:B="Book")). I need something that will take information out of a lot of text like a wild card. What works great for a single entry is:

=FILTER(C:C,SEARCH("BK",B:B))

But I can't figure out how to combine it so it will filter all values that contain EITHER "BK" or "Book."

Thanks in advance.


回答1:


You can do it replacing SEARCH through a combination of REGEXMATCH and ARRAYFORMULA

REGEXMATCH allows you to search for multiple keywords separated by |

Sample:

=FILTER(C:C,REGEXMATCH(B:B,"BK|book")=TRUE)

Note:

Regexp is case sensitive, so you need to specify separately REGEXMATCH(B:B,"BK|bk|Bk|bK|") etc.




回答2:


This is for Excel:

You can combine several SEARCH()s as follows:

=FILTER(C1:C20,ISNUMBER(SEARCH("Book",B1:B20,1))+ISNUMBER(SEARCH("BK",B1:B20,1)))

(should be similar for Google Sheets)



来源:https://stackoverflow.com/questions/61361953/how-to-filter-using-multiple-keywords-in-google-sheets-or-excel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!