Searching for what is "not"

Searching in CiviCRM is very powerful and allows you to find pretty much any kind of existing data using the Advanced Search functionality.

What about searching for data that is not ?

Thanks to the Search Builder feature, you can search for empty fields, such as "all the contacts who don't have an email address". But it becomes more difficult when you want to search for records (membership, contribution, activity, event registration...) that do not exist on a contact, especially when you want to look at a specific time period. For instance, finding all the contacts who did not donate last month or all the contacts who came to your fundraiser last year but did not come this year. These searches are not available in CiviCRM with a simple click and and require a custom development.

But there is a simple way to get around this limitation and search for data that is not in CiviCRM.

In order to perform such a search, say for instance "All the contacts who did not donate last month" you can use the Custom Search "Include / Exclude Contacts in a Group / Tag". This custom search lets you find all the contacts that are in a group or several groups but NOT in another group. 

But to use this Custom Search for your purpose you need to think about your query differently. As you can't search for data that don't exist you need to search for all data and exclude the data you don't want, i.e. contacts who did NOT donate last month.

That means in our example we will search for all individual contacts that are in your CRM and exclude the ones who donated last month. 

How to do that in CiviCRM

  1. Create a group of all individual contacts 
  2. Create another group of all contacts who made a contribution last month (this can be done easily through an advanced search)
  3. Use the custom search "Include / Exclude" (Search > Custom Searches), including the group created at step 1 and excluding the group created at step 2

Include-Exclude Search.png

And if you want to recall this search on a regular basis, you can simply use smart groups and add the results of the final search to a smart group as well.

The same logic can be applied to all searches of this type: you are looking for a subset of contacts who do not have a certain set of data, so you first create a group of the contacts who have that specific set of data, then exclude that group from the broader set of contacts.

As long as you can express clearly what your criteria are, the search should be easy.

Questions about performing searches in CiviCRM? Contact your support team at Cividesk and we'll be happy to assist you.