Answers.Body: <p>I'm not sure about proper Stack Exchange protocol here, but I just posted an answer for a <a href="https://civicrm.stackexchange.com/q/5185/105">different question</a> about how to create a view that includes both guardians with their child all on the same line (if I should write out the same answer or modify it, I certainly can).  Perhaps you would find it useful.  I would think the same concept would apply to showing all members of a given household: <a href="https://civicrm.stackexchange.com/a/5227/105">https://civicrm.stackexchange.com/a/5227/105</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-05T04:26:48.373Z
Answers.Text: That is a good workaround, but your solution involves installing another module and nesting one view in another view. That would work, but this feels like something that should be built into CiviCRM with relationships and views.
Answers.UserDisplayName: Jeff Mikels
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-05T05:45:49.033Z
Answers.Text: Point granted.  In CiviCRM, the Relationship report (under Contact Reports), with Contact B specified as Household, yields the data you're looking for.  I'll think more on the Drupal Views front.
Answers.UserDisplayName: Allen Hutchison
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-05T05:57:08.160Z
Answers.Text: Thinking through your question, the only reason we used the extra module to embed the view was to get everything on one line for each child.  If that does not matter for your use case, then there is definitely a Views way to do it.  I'll post an answer for that scenario.
Answers.UserDisplayName: Allen Hutchison
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-04T03:20:52.737Z
Answers.LastActivityDate: 2015-09-04T05:24:53.133Z
Answers.LastEditDate: 2017-04-13T12:53:13.207Z
Answers.UserDisplayName: Allen Hutchison
Answers.Body: <p>If getting the list of Household members on the same line is not a concern, then creating the View is doable with two relationships, a filter and a couple of fields.</p>
  
  <p><strong><em>Create a CiviCRM Contacts View</em></strong></p>
  
  <p><strong>Relationships</strong></p>
  
  <ol>
  <li>CiviCRM Relationship (starting from contact A); relationship type > Household Member of | Household Member is</li>
  <li>CiviCRM Relationships: Contact ID B; in this relationship, reference relationship #1</li>
  </ol>
  
  <p><strong>Filter Criteria</strong></p>
  
  <p>Contact Type = Household; in this filter, reference relationship #2 (Contact ID B)</p>
  
  <p><strong>Fields</strong></p>
  
  <ul>
  <li>Whatever info you need for Contact A (the individuals in the household)</li>
  <li>Whatever info you need for the Household (say, sort name); in this field, reference relationship #2 (Contact ID B)</li>
  </ul>
  
  <p>If you add a sort for the Household name (or whatever field you use for the Household), referencing relationship #2 (Contact ID B), you ensure all of your household members are grouped together.</p>
  
  <p>I just verified with our own Civi install that this yields each household member, not just one.</p>
  
  <p>Hope this helps!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-09T03:40:00.740Z
Answers.Text: Thanks for your input @Allen. Your suggestion appears to generate a list of all contacts filtered to show only contacts who are members of a household and then finally group those contacts by household.
  
  Although, it somewhat meets my original criteria, it doesn't meet my goals. I need the view to get a contact id, and if that id is a household, show all members. If that id is for an individual, show the household name. Additionally, having the names on one line is a major plus for usability,
  
  However, I think I will have to use your technique and just generate two views.
Answers.UserDisplayName: Jeff Mikels
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-09T03:48:00.803Z
Answers.Text: @Jeff, how are you wanting to get the contact into the view? You could use an exposed filter (or two) to dictate the individual Contact A (to thus show the household) or the household Contact B (to thus show the individuals).
Answers.UserDisplayName: Allen Hutchison
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-05T06:12:32.247Z
Answers.LastActivityDate: 2015-09-05T06:12:32.247Z
Answers.UserDisplayName: Allen Hutchison
Body: <p>I have read the answers to this question:</p>
  
  <p><a href="https://civicrm.stackexchange.com/questions/739/how-to-create-a-drupal-view-with-multiple-civicrm-relationships">How to create a Drupal View with multiple CiviCRM relationships?</a></p>
  
  <p>and it has helped me to create a Drupal view that links an individual to a household, but when I want to go in the other direction, the relationship only shows me ONE of the individuals in the household and not all of them.</p>
  
  <p>How do I create a view that pulls ALL of the individuals associated with a household?</p>
  
  <p>That is, how do I tell the view to pull all of the related entities and not just the first one?</p>
  
  <p>EDIT: Here is the export for my view code:</p>
  
  <pre><code>$view = new view();
  $view-&gt;name = 'household_members';
  $view-&gt;description = '';
  $view-&gt;tag = 'default';
  $view-&gt;base_table = 'civicrm_contact';
  $view-&gt;human_name = 'Household Members';
  $view-&gt;core = 7;
  $view-&gt;api_version = '3.0';
  $view-&gt;disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  
  /* Display: Master */
  $handler = $view-&gt;new_display('default', 'Master', 'default');
  $handler-&gt;display-&gt;display_options['title'] = 'Household Members';
  $handler-&gt;display-&gt;display_options['use_more_always'] = FALSE;
  $handler-&gt;display-&gt;display_options['access']['type'] = 'none';
  $handler-&gt;display-&gt;display_options['cache']['type'] = 'none';
  $handler-&gt;display-&gt;display_options['query']['type'] = 'views_query';
  $handler-&gt;display-&gt;display_options['exposed_form']['type'] = 'basic';
  $handler-&gt;display-&gt;display_options['pager']['type'] = 'full';
  $handler-&gt;display-&gt;display_options['pager']['options']['items_per_page'] = '10';
  $handler-&gt;display-&gt;display_options['style_plugin'] = 'default';
  $handler-&gt;display-&gt;display_options['row_plugin'] = 'fields';
  /* Relationship: CiviCRM Contacts: CiviCRM Relationship (starting from Contact B) */
  $handler-&gt;display-&gt;display_options['relationships']['relationship_id_b']['id'] = 'relationship_id_b';
  $handler-&gt;display-&gt;display_options['relationships']['relationship_id_b']['table'] = 'civicrm_contact';
  $handler-&gt;display-&gt;display_options['relationships']['relationship_id_b']['field'] = 'relationship_id_b';
  $handler-&gt;display-&gt;display_options['relationships']['relationship_id_b']['label'] = 'Household Members';
  $handler-&gt;display-&gt;display_options['relationships']['relationship_id_b']['relationship_type'] = '7';
  /* Relationship: CiviCRM Relationships: Contact ID A */
  $handler-&gt;display-&gt;display_options['relationships']['contact_id_a_']['id'] = 'contact_id_a_';
  $handler-&gt;display-&gt;display_options['relationships']['contact_id_a_']['table'] = 'civicrm_relationship';
  $handler-&gt;display-&gt;display_options['relationships']['contact_id_a_']['field'] = 'contact_id_a_';
  $handler-&gt;display-&gt;display_options['relationships']['contact_id_a_']['relationship'] = 'relationship_id_b';
  $handler-&gt;display-&gt;display_options['relationships']['contact_id_a_']['label'] = 'Members';
  /* Relationship: CiviCRM Contacts: CiviCRM Relationship (starting from contact A) */
  $handler-&gt;display-&gt;display_options['relationships']['relationship_id_a']['id'] = 'relationship_id_a';
  $handler-&gt;display-&gt;display_options['relationships']['relationship_id_a']['table'] = 'civicrm_contact';
  $handler-&gt;display-&gt;display_options['relationships']['relationship_id_a']['field'] = 'relationship_id_a';
  $handler-&gt;display-&gt;display_options['relationships']['relationship_id_a']['label'] = 'Individual to Household';
  $handler-&gt;display-&gt;display_options['relationships']['relationship_id_a']['relationship_type'] = '7';
  /* Relationship: CiviCRM Relationships: Contact ID B */
  $handler-&gt;display-&gt;display_options['relationships']['contact_id_b_']['id'] = 'contact_id_b_';
  $handler-&gt;display-&gt;display_options['relationships']['contact_id_b_']['table'] = 'civicrm_relationship';
  $handler-&gt;display-&gt;display_options['relationships']['contact_id_b_']['field'] = 'contact_id_b_';
  $handler-&gt;display-&gt;display_options['relationships']['contact_id_b_']['relationship'] = 'relationship_id_a';
  $handler-&gt;display-&gt;display_options['relationships']['contact_id_b_']['label'] = 'Household';
  /* Field: CiviCRM Contacts: Contact ID */
  $handler-&gt;display-&gt;display_options['fields']['id']['id'] = 'id';
  $handler-&gt;display-&gt;display_options['fields']['id']['table'] = 'civicrm_contact';
  $handler-&gt;display-&gt;display_options['fields']['id']['field'] = 'id';
  $handler-&gt;display-&gt;display_options['fields']['id']['separator'] = '';
  /* Field: CiviCRM Contacts: Contact Type */
  $handler-&gt;display-&gt;display_options['fields']['contact_type']['id'] = 'contact_type';
  $handler-&gt;display-&gt;display_options['fields']['contact_type']['table'] = 'civicrm_contact';
  $handler-&gt;display-&gt;display_options['fields']['contact_type']['field'] = 'contact_type';
  /* Field: CiviCRM Contacts: Display Name */
  $handler-&gt;display-&gt;display_options['fields']['display_name']['id'] = 'display_name';
  $handler-&gt;display-&gt;display_options['fields']['display_name']['table'] = 'civicrm_contact';
  $handler-&gt;display-&gt;display_options['fields']['display_name']['field'] = 'display_name';
  $handler-&gt;display-&gt;display_options['fields']['display_name']['relationship'] = 'contact_id_a_';
  $handler-&gt;display-&gt;display_options['fields']['display_name']['label'] = 'Household Members';
  $handler-&gt;display-&gt;display_options['fields']['display_name']['link_to_civicrm_contact'] = 0;
  /* Field: CiviCRM Contacts: Display Name */
  $handler-&gt;display-&gt;display_options['fields']['display_name_1']['id'] = 'display_name_1';
  $handler-&gt;display-&gt;display_options['fields']['display_name_1']['table'] = 'civicrm_contact';
  $handler-&gt;display-&gt;display_options['fields']['display_name_1']['field'] = 'display_name';
  $handler-&gt;display-&gt;display_options['fields']['display_name_1']['relationship'] = 'contact_id_b_';
  $handler-&gt;display-&gt;display_options['fields']['display_name_1']['label'] = 'Household Name';
  $handler-&gt;display-&gt;display_options['fields']['display_name_1']['link_to_civicrm_contact'] = 0;
  /* Contextual filter: CiviCRM Contacts: Contact ID */
  $handler-&gt;display-&gt;display_options['arguments']['id']['id'] = 'id';
  $handler-&gt;display-&gt;display_options['arguments']['id']['table'] = 'civicrm_contact';
  $handler-&gt;display-&gt;display_options['arguments']['id']['field'] = 'id';
  $handler-&gt;display-&gt;display_options['arguments']['id']['default_argument_type'] = 'fixed';
  $handler-&gt;display-&gt;display_options['arguments']['id']['summary']['number_of_records'] = '0';
  $handler-&gt;display-&gt;display_options['arguments']['id']['summary']['format'] = 'default_summary';
  $handler-&gt;display-&gt;display_options['arguments']['id']['summary_options']['items_per_page'] = '25';
  
  /* Display: Page */
  $handler = $view-&gt;new_display('page', 'Page', 'page');
  $handler-&gt;display-&gt;display_options['path'] = 'household-members';
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-03T12:31:53.940Z
Comments.Text: It would help if you can post the SQL generated by the view you created.  My guess is that the view is constructed to only pull the first relationship it found.
Comments.UserDisplayName: pkeogan - BackOffice Thinking
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-03T16:28:22.857Z
Comments.Text: I am thinking so too... I have added a view export to the main question.
Comments.UserDisplayName: Jeff Mikels
Tags: <drupal><drupal-views><relationships>
Title: Create a Drupal View with MULTIPLE CiviCRM relationships?
ThreadText: # Create a Drupal View with MULTIPLE CiviCRM relationships?
  
  (Asked by: username_0 on 2015-09-02)
  
  I have read the answers to this question:
  
  [How to create a Drupal View with multiple CiviCRM relationships?](https://civicrm.stackexchange.com/questions/739/how-to-create-a-drupal-view-with-multiple-civicrm-relationships)
  
  and it has helped me to create a Drupal view that links an individual to a household, but when I want to go in the other direction, the relationship only shows me ONE of the individuals in the household and not all of them.
  
  How do I create a view that pulls ALL of the individuals associated with a household?
  
  That is, how do I tell the view to pull all of the related entities and not just the first one?
  
  EDIT: Here is the export for my view code:
  
  ```
  $view = new view();
  $view->name = 'household_members';
  $view->description = '';
  $view->tag = 'default';
  $view->base_table = 'civicrm_contact';
  $view->human_name = 'Household Members';
  $view->core = 7;
  $view->api_version = '3.0';
  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
  
  /* Display: Master */
  $handler = $view->new_display('default', 'Master', 'default');
  $handler->display->display_options['title'] = 'Household Members';
  $handler->display->display_options['use_more_always'] = FALSE;
  $handler->display->display_options['access']['type'] = 'none';
  $handler->display->display_options['cache']['type'] = 'none';
  $handler->display->display_options['query']['type'] = 'views_query';
  $handler->display->display_options['exposed_form']['type'] = 'basic';
  $handler->display->display_options['pager']['type'] = 'full';
  $handler->display->display_options['pager']['options']['items_per_page'] = '10';
  $handler->display->display_options['style_plugin'] = 'default';
  $handler->display->display_options['row_plugin'] = 'fields';
  /* Relationship: CiviCRM Contacts: CiviCRM Relationship (starting from Contact B) */
  $handler->display->display_options['relationships']['relationship_id_b']['id'] = 'relationship_id_b';
  $handler->display->display_options['relationships']['relationship_id_b']['table'] = 'civicrm_contact';
  $handler->display->display_options['relationships']['relationship_id_b']['field'] = 'relationship_id_b';
  $handler->display->display_options['relationships']['relationship_id_b']['label'] = 'Household Members';
  $handler->display->display_options['relationships']['relationship_id_b']['relationship_type'] = '7';
  /* Relationship: CiviCRM Relationships: Contact ID A */
  $handler->display->display_options['relationships']['contact_id_a_']['id'] = 'contact_id_a_';
  $handler->display->display_options['relationships']['contact_id_a_']['table'] = 'civicrm_relationship';
  $handler->display->display_options['relationships']['contact_id_a_']['field'] = 'contact_id_a_';
  $handler->display->display_options['relationships']['contact_id_a_']['relationship'] = 'relationship_id_b';
  $handler->display->display_options['relationships']['contact_id_a_']['label'] = 'Members';
  /* Relationship: CiviCRM Contacts: CiviCRM Relationship (starting from contact A) */
  $handler->display->display_options['relationships']['relationship_id_a']['id'] = 'relationship_id_a';
  $handler->display->display_options['relationships']['relationship_id_a']['table'] = 'civicrm_contact';
  $handler->display->display_options['relationships']['relationship_id_a']['field'] = 'relationship_id_a';
  $handler->display->display_options['relationships']['relationship_id_a']['label'] = 'Individual to Household';
  $handler->display->display_options['relationships']['relationship_id_a']['relationship_type'] = '7';
  /* Relationship: CiviCRM Relationships: Contact ID B */
  $handler->display->display_options['relationships']['contact_id_b_']['id'] = 'contact_id_b_';
  $handler->display->display_options['relationships']['contact_id_b_']['table'] = 'civicrm_relationship';
  $handler->display->display_options['relationships']['contact_id_b_']['field'] = 'contact_id_b_';
  $handler->display->display_options['relationships']['contact_id_b_']['relationship'] = 'relationship_id_a';
  $handler->display->display_options['relationships']['contact_id_b_']['label'] = 'Household';
  /* Field: CiviCRM Contacts: Contact ID */
  $handler->display->display_options['fields']['id']['id'] = 'id';
  $handler->display->display_options['fields']['id']['table'] = 'civicrm_contact';
  $handler->display->display_options['fields']['id']['field'] = 'id';
  $handler->display->display_options['fields']['id']['separator'] = '';
  /* Field: CiviCRM Contacts: Contact Type */
  $handler->display->display_options['fields']['contact_type']['id'] = 'contact_type';
  $handler->display->display_options['fields']['contact_type']['table'] = 'civicrm_contact';
  $handler->display->display_options['fields']['contact_type']['field'] = 'contact_type';
  /* Field: CiviCRM Contacts: Display Name */
  $handler->display->display_options['fields']['display_name']['id'] = 'display_name';
  $handler->display->display_options['fields']['display_name']['table'] = 'civicrm_contact';
  $handler->display->display_options['fields']['display_name']['field'] = 'display_name';
  $handler->display->display_options['fields']['display_name']['relationship'] = 'contact_id_a_';
  $handler->display->display_options['fields']['display_name']['label'] = 'Household Members';
  $handler->display->display_options['fields']['display_name']['link_to_civicrm_contact'] = 0;
  /* Field: CiviCRM Contacts: Display Name */
  $handler->display->display_options['fields']['display_name_1']['id'] = 'display_name_1';
  $handler->display->display_options['fields']['display_name_1']['table'] = 'civicrm_contact';
  $handler->display->display_options['fields']['display_name_1']['field'] = 'display_name';
  $handler->display->display_options['fields']['display_name_1']['relationship'] = 'contact_id_b_';
  $handler->display->display_options['fields']['display_name_1']['label'] = 'Household Name';
  $handler->display->display_options['fields']['display_name_1']['link_to_civicrm_contact'] = 0;
  /* Contextual filter: CiviCRM Contacts: Contact ID */
  $handler->display->display_options['arguments']['id']['id'] = 'id';
  $handler->display->display_options['arguments']['id']['table'] = 'civicrm_contact';
  $handler->display->display_options['arguments']['id']['field'] = 'id';
  $handler->display->display_options['arguments']['id']['default_argument_type'] = 'fixed';
  $handler->display->display_options['arguments']['id']['summary']['number_of_records'] = '0';
  $handler->display->display_options['arguments']['id']['summary']['format'] = 'default_summary';
  $handler->display->display_options['arguments']['id']['summary_options']['items_per_page'] = '25';
  
  /* Display: Page */
  $handler = $view->new_display('page', 'Page', 'page');
  $handler->display->display_options['path'] = 'household-members';
  
  ```
  
  **Tags:** drupal, drupal-views, relationships
  
  > **Comments:**
  > **username_1**: It would help if you can post the SQL generated by the view you created.  My guess is that the view is constructed to only pull the first relationship it found.  
  > **username_0**: I am username_1 so too... I have added a view export to the main question.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-09-04. Score: 1
  
  I'm not sure about proper Stack Exchange protocol here, but I just posted an answer for a [different question](https://civicrm.stackexchange.com/q/5185/105) about how to create a view that includes both guardians with their child all on the same line (if I should write out the same answer or modify it, I certainly can). Perhaps you would find it useful. I would think the same concept would apply to showing all members of a given household: <https://civicrm.stackexchange.com/a/5227/105>
  
  > **Comments:**
  > **username_0**: That is a good workaround, but your solution involves installing another module and nesting one view in another view. That would work, but this feels like something that should be built into CiviCRM with relationships and views.  
  > **username_2**: Point granted.  In CiviCRM, the Relationship report (under Contact Reports), with Contact B specified as Household, yields the data you're looking for.  I'll think more on the Drupal Views front.  
  > **username_2**: username_1 through your question, the only reason we used the extra module to embed the view was to get everything on one line for each child.  If that does not matter for your use case, then there is definitely a Views way to do it.  I'll post an answer for that scenario.  
  
  ---
  
  ### Answer by username_2 on 2015-09-05. Score: 0
  
  If getting the list of Household members on the same line is not a concern, then creating the View is doable with two relationships, a filter and a couple of fields.
  
  ***Create a CiviCRM Contacts View***
  
  **Relationships**
  
  1. CiviCRM Relationship (starting from contact A); relationship type > Household Member of | Household Member is
  2. CiviCRM Relationships: Contact ID B; in this relationship, reference relationship #1
  
  **Filter Criteria**
  
  Contact Type = Household; in this filter, reference relationship #2 (Contact ID B)
  
  **Fields**
  
  * Whatever info you need for Contact A (the individuals in the household)
  * Whatever info you need for the Household (say, sort name); in this field, reference relationship #2 (Contact ID B)
  
  If you add a sort for the Household name (or whatever field you use for the Household), referencing relationship #2 (Contact ID B), you ensure all of your household members are grouped together.
  
  I just verified with our own Civi install that this yields each household member, not just one.
  
  Hope this helps!
  
  > **Comments:**
  > **username_0**: Thanks for your input @username_2. Your suggestion appears to generate a list of all contacts filtered to show only contacts who are members of a household and then finally group those contacts by household.  Although, it somewhat meets my original criteria, it doesn't meet my goals. I need the view to get a contact id, and if that id is a household, show all members. If that id is for an individual, show the household name. Additionally, having the names on one line is a major plus for usability,  However, I think I will have to use your technique and just generate two views.  
  > **username_2**: @username_0, how are you wanting to get the contact into the view? You could use an exposed filter (or two) to dictate the individual Contact A (to thus show the household) or the household Contact B (to thus show the individuals).  
  
  ---
  
  