CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • How to search for contacts who appear in multiple smart groups
Pages: [1]

Author Topic: How to search for contacts who appear in multiple smart groups  (Read 367 times)

The Doctor

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 1
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
How to search for contacts who appear in multiple smart groups
October 30, 2014, 06:44:53 am
This is probably really obvious, but I am not seeing it.

I have a number of smart groups set up. I want to find the contacts who appear in two or more of these groups. In other words I want to search for contacts who appear in BOTH Group A AND Group B, for example.

One use for this is with smart groups based on membership status. I want to be able to find those contacts who have BOTH active memberships (Current or New status) AND inactive memberships (Expired status).

How can I do this?

Any help appreciated.
« Last Edit: October 30, 2014, 06:51:24 am by The Doctor »

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: How to search for contacts who appear in multiple smart groups
October 30, 2014, 07:33:22 am
The bad news is that this is a bit of a pain point in CiviCRM.  The good news is that there's a solution specifically to address your problem.  Go to Search menu > Custom Searches (it's the last option), and use the "Include/Exclude Groups" custom search.

All that said - in your specific use case, you could create a new smart group of folks who have active and inactive memberships.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

The Doctor

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 1
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
Re: How to search for contacts who appear in multiple smart groups
October 30, 2014, 08:04:54 am
Thanks for replying JonGold.

As far as I can tell, both of those suggestion allow me to find people who are in one or the other group.

The Include/Exclude search seems to be boolean A OR B. I need A AND B.  In other words, If I put two groups into the Include field, the result is a list of people who are in one or both of the groups. I only want to find the people who are in both of the groups.

The same is true of a membership search where I check off both Current and Expired status. I get people with either Current or Expired status.

Or am I missing something?

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: How to search for contacts who appear in multiple smart groups
October 30, 2014, 12:03:44 pm
Sorry, you're right.  My memory was incorrect about what the radio buttons on that custom search did.

Fortunately, there's a simpler answer, which is the Search Builder.  Note that searching for groups was a bit wonky pre-4.5, so if you have a problem, you may need an upgrade, but I just tested this on 4.5.2:
Search Builder:
Group = Group 1
Group = Group 2
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

The Doctor

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 1
  • CiviCRM version: 4.7.x
  • CMS version: Drupal 7.x
Re: How to search for contacts who appear in multiple smart groups
October 30, 2014, 12:08:23 pm
Aha! That works. Thank you so much!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • How to search for contacts who appear in multiple smart groups

This forum was archived on 2017-11-26.