# Filter string based on multiple contains

**URL:** <https://discuss.google.dev/t/filter-string-based-on-multiple-contains/111328>\
**Category:** Looker\
**Tags:** filter\
**Created:** [July 27, 2022, 12:03pm UTC](https://discuss.google.dev/t/filter-string-based-on-multiple-contains/111328 "2022-07-27T12:03:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous8](https://avatars.discourse-cdn.com/v4/letter/a/7cd45c/32.png) [@anonymous8](https://discuss.google.dev/u/anonymous8)\
**Post date:** [July 27, 2022, 12:03pm UTC](https://discuss.google.dev/t/filter-string-based-on-multiple-contains/111328/1 "2022-07-27T12:03:24Z")

</div>

Hey,

I’m currently building a explore which contains a concatenated string as a key. I would like to be able to filter based on this string where I have 2-4 unique substrings that it must contain. This would equate to an AND contains while I can only seem to make OR contains filters.

The sql equivalent of what I was to achieve looks a little like this:

`WHERE (key_string LIKE ‘SUBSTRING_1’ AND key_String LIKE ‘SUBSTRING_2’)`

---

<div class="post-metadata">

**Author:** ![timogoosen](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/timogoosen/32/109433_2.png) [@timogoosen](https://discuss.google.dev/u/timogoosen)\
**Post date:** [March 11, 2024, 8:38am UTC](https://discuss.google.dev/t/filter-string-based-on-multiple-contains/111328/2 "2024-03-11T08:38:07Z")

</div>

I would also like to know. All I can think is use a regex instead of using contains substring and then in the regex to use something like

“match1|match2|match3”

my regex isn’t great but something like that.

---

<div class="post-metadata">

**Author:** ![dsimeonova](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/dsimeonova/32/4096_2.png) [@dsimeonova](https://discuss.google.dev/u/dsimeonova)\
**Post date:** [March 11, 2024, 10:37am UTC](https://discuss.google.dev/t/filter-string-based-on-multiple-contains/111328/3 "2024-03-11T10:37:02Z")

</div>

Hey @mganalyst and @timogoosen !

I am not sure if you tried to use the custom expression on the filter side.  
There is a function called “[contains]([Looker functions and operators &nbsp;|&nbsp; Google Cloud](https://cloud.google.com/looker/docs/functions-and-operators?version=24.2#:~:text=as%20one%20string.-,contains,-contains(string))” that can be used. And the AND/OR conditions can be used on your desire there. That’s why I asked if you considered using it.  
Here is an example:

 ![dsimeonova_0-1710153254827.png](https://d2yds90mtvelsl.cloudfront.net/original/2X/e/e418c29fc130750fc2d01de0ba035457fd76a1ad.png)

Here is the SQL behind:

 ![dsimeonova_1-1710153309438.png](https://d2yds90mtvelsl.cloudfront.net/original/3X/7/e/7e6adbfc084ba1622d0e5695a996e682878adf59.png)

Hope this helps!  
Please share if this workaround was proper solution 🙂
