We're trying to set up a search that includes contacts with one tag but excludes ones with another tag. Yet the "does not equal" operator does not appear to be functioning. Any ideas what the issue could be?

  • 1
    What version of CiviCRM, what platform, and what search mechanism? Are you using the Search Builder?
    – choster
    Jan 8 '16 at 16:16
  • CiviCRM 4.6, Joomla and yes, using the SEarch builder.
    – Matt
    Jan 8 '16 at 16:19

You have to watch out using the search builder when your search involves related entities. Searching for does not equal X on something doesn't exclude contacts with a related entity with a field's value as X, it searches for contacts who have that related entity so long as the value doesn't equal X.

In other words, searching for contacts where tag name does not equal Prospect doesn't exclude all prospects; it finds all contacts with tags so long as those tags aren't Prospect.

Although it seems foreign in the context of tags, groups, and some entities, it makes lots of sense regarding addresses: if you search for people where the state does not equal Alabama, it'll exclude people who only have an address in Alabama, but it'll include people who live in Alabama but have a work address in Georgia.

To reliably exclude contacts, you either need a specialized search like the include/exclude search, or you need to run a search with the criteria you want to include on, tag those contacts, run a search with the criteria you want to exclude on, and remove the tag from those contacts.

For example, to find everyone in Baltimore who has not attended an event in the past year, run a search (Advanced Search is easiest) for everyone in Baltimore, and use the "Actions" drop-down to tag all the results with a new tag called "Baltimore - no events". Then, run a search for participants at events in the past year, and use the "Actions" drop-down to untag all the results, removing the "Baltimore - no events" tag. (It doesn't matter that your second search will catch people in Glen Burnie or whatever who never had the tag in the first place.)


I got around the problem by using the Include/Exclude search eventually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.