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) »
  • Searching for number of relationships
Pages: [1]

Author Topic: Searching for number of relationships  (Read 236 times)

groston

  • I post occasionally
  • **
  • Posts: 61
  • Karma: 0
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.5.34
  • PHP version: 5.3.27
Searching for number of relationships
February 07, 2015, 11:48:51 am
I would like to do some database cleanup and so doing would be greatly facilitated if I could search on the number of relationships. Example of desired searches include:
  • contact type: organization AND number of relationships: 0
  • contact type: individual AND number of relationships: >1
How can I do this?

Thank you.

ayduns

  • I post occasionally
  • **
  • Posts: 64
  • Karma: 6
    • Squiffle Consulting
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7
Re: Searching for number of relationships
February 09, 2015, 03:46:42 am
Not exactly what you're asking for since this does not give you a count of relationships, but if you just need to know 0 vs >=1 relationships then this might help:

In Advanced Search, select the contact type to Individual, then open the Relationships section.  Don't change anything and Search.  That gives you all individuals with an active and current relationship (of any sort).

You could put those in a group "Indiv with Rel" (maybe a smart group if you want to repeat the exercise in your cleanup process), and then a second group with all Individuals ("All Indiv") and use the Include/Exclude search under Custom Searches.  Include "All Indiv", exclude "Indiv with Rel" and you have those with no relationships.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Searching for number of relationships
February 09, 2015, 11:53:37 am
Have you tried using the Relationships report (under Contact Reports), filtering by contact type. You can export the results to CSV for more control.
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Searching for number of relationships

This forum was archived on 2017-11-26.