# Segment filter 'contains' instead of 'including'

**URL:** <https://forum.mautic.org/t/segment-filter-contains-instead-of-including/22468>\
**Category:** Product Support\
**Created:** [January 24, 2022, 3:31pm UTC](https://forum.mautic.org/t/segment-filter-contains-instead-of-including/22468 "2022-01-24T15:31:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![donbowman](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/donbowman/32/5702_2.png) [@donbowman](https://forum.mautic.org/u/donbowman)\
**Post date:** [January 24, 2022, 3:31pm UTC](https://forum.mautic.org/t/segment-filter-contains-instead-of-including/22468/1 "2022-01-24T15:31:07Z")

</div>

**Your software**  
My Mautic version is: 4.1.1  
My PHP version is: 7.4  
My Database type and version is: tidb

**Your problem**

I have a custom field ‘industries’ on a company. It is multiselect. It has values like ‘Utilities’, ‘Consumer Goods’ etc.

I wish to create a segment that selects leads whose company.industries is in a list.  
I can select a single value ('company.industries including Utilities).  
But, if i set 2 values, it has the logic of “is all of the values”, and i would like to use “Is at least one of the values”.

Is there anyway to do this? the segment filter only has including/excluding.

> <https://github.com/mautic/mautic/issues/9633>
>
> \## Bug Description
> I have a custom field of type "multiple" select. Segment fil…ter options for this type of field are:
> 
> \- empty
> \- not empty
> \- excluding
> \- including
> 
> !\[image\](https://user-images.githubusercontent.com/1241376/106454735-7e78a680-648b-11eb-87b3-2f34b1e823a6.png)
> 
> In the screenshot I have 2 criteria selected. So contacts with either of them should enter the segment - if the contact has any of the SKUs, it should be in the segment. However, the filter only works when "including" contains one criteria.
> 
> Based on my understanding all of the three should be in the segment:
> 
> \- Client A who bought 1776
> \- Client B who bought 107 and
> \- Client C who bought both.
> 
> 
> | Q | A
> | --- | ---
> | Mautic version | 3.2.5
> | PHP version | 7.3.19 
> | Browser | any
> 
> \### Steps to reproduce
> 1. create a select - multiple field
> 2. create a dynamic segment based on that field
> 3. create contact with test data
>  
> \### Log errors
> none
> 
> \<bountysource-plugin\>
> 
> \---
> Want to back this issue? \*\*\[Post a bounty on it!\](https://www.bountysource.com/issues/96318658-segment-filter-broken-for-select-multiple-field?utm\_campaign=plugin&utm\_content=tracker%2F5355074&utm\_medium=issues&utm\_source=github)\*\* We accept bounties via \[Bountysource\](https://www.bountysource.com/?utm\_campaign=plugin&utm\_content=tracker%2F5355074&utm\_medium=issues&utm\_source=github).
> \</bountysource-plugin\>

talks of this. is there a method to do ‘contains’?

---

<div class="post-metadata">

**Author:** ![jorge73](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/jorge73/32/12645_2.png) [@jorge73](https://forum.mautic.org/u/jorge73)\
**Post date:** [February 14, 2025, 5:29pm UTC](https://forum.mautic.org/t/segment-filter-contains-instead-of-including/22468/2 "2025-02-14T17:29:15Z")

</div>

I had the same problem and I changed the code in these 3 points changing the previous expr()-\>and with expr()-\>or an the multiselect works as “is at least one of the values”:

```auto
<your_path>/app/bundles/LeadBundle/Entity/LeadFieldRepository.php (ROW=289): $expr = $expr->with($q->expr()->or(...$andExpr));
<your_path>/app/bundles/LeadBundle/Segment/Query/Filter/ComplexRelationValueFilterQueryBuilder.php (ROW=119): $expression = $queryBuilder->expr()->or(...$expressions);
<your_path>/app/bundles/LeadBundle/EventListener/SegmentOperatorQuerySubscriber.php (ROW=117): $event->addExpression($event->getQueryBuilder()->expr()->or(...$expressions));

```

Hope this could help.

PS: remember to delete the cache  
`rm -rf <your_path>/var/cache/prod`
