Answers.Body: <p>Why this is happening depends very much on how your View is set up, providing an export of the View might help us investigate.</p>
  
  <p>One thing that might help is turning on the 'Distinct' option in the View, to force only one of each result appearing.</p>
  
  <p>This can be done whilst editing the View, under: Advanced > Other > Query settings > Tick 'Distinct'</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T13:13:56.833Z
Answers.Text: Thanks - I've tried the "Distinct" option and the results are the same. I think it may be because I'm using the website field.
Answers.UserDisplayName: Tim Vaughan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T13:15:01.013Z
Answers.Text: Here's an export of the view: http://pastebin.com/5efTMf4U
Answers.UserDisplayName: Tim Vaughan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-20T13:08:46.917Z
Answers.LastActivityDate: 2015-05-20T13:08:46.917Z
Answers.UserDisplayName: John
Answers.Body: <p>If you use adress fields and the contact has several addresses in CiviCRM the contact will be shown several times. In that case you could configure the address fields to only show the primary record.</p>
  
  <p><img src="https://i.sstatic.net/Qu0UB.png" alt="enter image description here"><img src="https://i.sstatic.net/s9XZY.png" alt="enter image description here"></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T05:36:07.670Z
Answers.Text: that is "add a filter" to select just the type of address you want to display
Answers.UserDisplayName: Eliot Mason
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T08:53:08.383Z
Answers.Text: I actually meant not a filter - it is a setting if you click on the CiviCRM field in the views - see screenshots.
Answers.UserDisplayName: Fabian
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-20T13:27:09.180Z
Answers.LastActivityDate: 2015-05-21T08:55:14.340Z
Answers.LastEditDate: 2015-05-21T08:55:14.340Z
Answers.UserDisplayName: Fabian
Answers.Body: <p>There is a work-around for this. Take the example of multiple phone numbers in a contact record. </p>
  
  <ol>
  <li>Include the Phone Number field once for each unique type of number (Home/Mobile, Home/Phone, Work/Phone etc)</li>
  </ol>
  
  <p><a href="https://i.sstatic.net/y2cnn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/y2cnn.png" alt="Screenshop"></a></p>
  
  <ol start="2">
  <li>In Civicrm Location Display Options for each field, select unique combinations (e.g. Location Type = Work &amp; Phone Type = Phone). Do NOT select "Show only Primary record"</li>
  </ol>
  
  <p><a href="https://i.sstatic.net/ubbYi.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ubbYi.png" alt="enter image description here"></a></p>
  
  <ol start="3">
  <li><p>Mark each of these fields as "Exclude from Display", and add a Rewrite Results for each one followed by a comma (e.g. Rewrite as "[phone],"</p></li>
  <li><p>Add a "dummy" field AFTER the Phone Number fields, using any <strong>unused</strong> CiviCRM field (e.g. PostCode Suffix) and in this change the Label to e.g. "Phone Number(s)" and the Rewrite Results to "[phone] [phone_1] [phone_2]" (or whatever the PN fields are called). </p></li>
  </ol>
  
  <p>The result should be one line in the output per contact, and the multiple phone numbers will be concatenated in the Phone Number(s) column.</p>
  
  <p>Hope this works for you. Tom C </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-08T14:53:38.270Z
Answers.LastActivityDate: 2015-12-08T14:53:38.270Z
Answers.UserDisplayName: Tom Crawshaw
Answers.Body: <p>Unfortunately, <em>I believe</em> in my case because I was using Household relationships and Addresses of Employers this caused a lot of duplicates.</p>
  
  <p>What did work for me was to set <strong>Aggregation on</strong>. Then setting Group by on your main element that you wish to not duplicate. Viola all is well!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-04-11T14:01:21.480Z
Answers.LastActivityDate: 2018-05-22T17:42:20.140Z
Answers.LastEditDate: 2018-05-22T17:42:20.140Z
Answers.UserDisplayName: shaneonabike
Answers.Body: <p>If you are still having trouble after setting DISTINCT as an option in the View, and specifying the Location Type hasn't helped -- then a RANDOM sort order may be the issue.  Because of the way Drupal views handles random as a column <em>as well as</em> a ORDER BY clause, it breaks the distinctness of the query.  </p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-23T17:24:59.877Z
Answers.LastActivityDate: 2020-04-23T17:24:59.877Z
Answers.UserDisplayName: CiviTeacher
Answers.Body: <p>The culprit is often the website field which has no filters that enable you to specify which of a number should show and hence they produce multiple rows. But like others say, it could be Address, Email or Phone if you haven't specified either the location type or Primary only. Or multiple relationships etc.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-22T20:14:41.310Z
Answers.Text: You should be able to use CiviCRM Entity and it will provide an explicit relationship between Contact and Website entities. Then you can provide a Website entity type or type_id or is_primary filter that uses that relationship, to limit it
Answers.UserDisplayName: jackrabbithanna
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T13:16:52.307Z
Answers.Text: I removed the website field and it appears you're right, that was what was causing the problem. Can I fix that without removing the other websites, do you know?
Answers.UserDisplayName: Tim Vaughan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T21:53:13.390Z
Answers.Text: There needs to be some addition to the Views-Civi code so that the web field can have settings as per the Address/Phone fields so it can be limited to a particular 'website type'
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T04:46:02.270Z
Answers.LastActivityDate: 2015-05-21T04:46:02.270Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>I'm using Views to display lists of CiviCRM contacts (4.5.2). I'm finding that several contacts appear in Views twice. Any ideas what might be going on here?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-20T12:23:45.147Z
Comments.Text: What are the views filters? Are you using relationships or contextual filters? Which ones?
Comments.UserDisplayName: Nicholai
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-21T13:12:46.937Z
Comments.Text: I'm filtering on contact type (Organisation) and whether or not the contact is deleted.
Comments.UserDisplayName: Tim Vaughan
Tags: <drupal-views><4.5>
Title: Duplicate entries in Views
ThreadText: # Duplicate entries in Views
  
  (Asked by: username_0 on 2015-05-20)
  
  I'm using Views to display lists of CiviCRM contacts (4.5.2). I'm finding that several contacts appear in Views twice. Any ideas what might be going on here?
  
  **Tags:** drupal-views, 4.5
  
  > **Comments:**
  > **username_1**: What are the views filters? Are you using relationships or contextual filters? Which ones?  
  > **username_0**: I'm filtering on contact type (Organisation) and whether or not the contact is deleted.  
  
  ---
  
  ## 6 answers
  
  ### Answer by username_8 on 2015-05-21. Score: 5 | Accepted answer
  
  The culprit is often the website field which has no filters that enable you to specify which of a number should show and hence they produce multiple rows. But like others say, it could be Address, Email or Phone if you haven't specified either the location type or Primary only. Or multiple relationships etc.
  
  > **Comments:**
  > **username_0**: I removed the website field and it appears you're right, that was what was causing the problem. Can I fix that without removing the other websites, do you know?  
  > **username_8**: There needs to be some addition to the Views-Civi code so that the web field can have settings as per the Address/Phone fields so it can be limited to a particular 'website type'  
  > **username_9**: You should be able to use CiviCRM Entity and it will provide an explicit relationship between Contact and Website entities. Then you can provide a Website entity type or type_id or is_primary filter that uses that relationship, to limit it  
  
  ---
  
  ### Answer by username_2 on 2015-05-20. Score: 4
  
  Why this is happening depends very much on how your View is set up, providing an export of the View might help us investigate.
  
  One thing that might help is turning on the 'Distinct' option in the View, to force only one of each result appearing.
  
  This can be done whilst editing the View, under: Advanced > Other > Query settings > Tick 'Distinct'
  
  > **Comments:**
  > **username_0**: Thanks - I've tried the "Distinct" option and the results are the same. I think it may be because I'm using the website field.  
  > **username_0**: Here's an export of the view: http://pastebin.com/5efTMf4U  
  
  ---
  
  ### Answer by username_3 on 2015-05-20. Score: 3
  
  If you use adress fields and the contact has several addresses in CiviCRM the contact will be shown several times. In that case you could configure the address fields to only show the primary record.
  
  ![enter image description here](https://i.sstatic.net/Qu0UB.png)![enter image description here](https://i.sstatic.net/s9XZY.png)
  
  > **Comments:**
  > **username_4**: that is "add a filter" to select just the type of address you want to display  
  > **username_3**: I actually meant not a filter - it is a setting if you click on the CiviCRM field in the views - see screenshots.  
  
  ---
  
  ### Answer by username_5 on 2015-12-08. Score: 1
  
  There is a work-around for this. Take the example of multiple phone numbers in a contact record.
  
  1. Include the Phone Number field once for each unique type of number (Home/Mobile, Home/Phone, Work/Phone etc)
  
  [![Screenshop](https://i.sstatic.net/y2cnn.png)](https://i.sstatic.net/y2cnn.png)
  
  2. In Civicrm Location Display Options for each field, select unique combinations (e.g. Location Type = Work & Phone Type = Phone). Do NOT select "Show only Primary record"
  
  [![enter image description here](https://i.sstatic.net/ubbYi.png)](https://i.sstatic.net/ubbYi.png)
  
  3. Mark each of these fields as "Exclude from Display", and add a Rewrite Results for each one followed by a comma (e.g. Rewrite as "[phone],"
  4. Add a "dummy" field AFTER the Phone Number fields, using any **unused** CiviCRM field (e.g. PostCode Suffix) and in this change the Label to e.g. "Phone Number(s)" and the Rewrite Results to "[phone] [phone\_1] [phone\_2]" (or whatever the PN fields are called).
  
  The result should be one line in the output per contact, and the multiple phone numbers will be concatenated in the Phone Number(s) column.
  
  Hope this works for you. Tom C
  
  
  ---
  
  ### Answer by username_6 on 2018-04-11. Score: 1
  
  Unfortunately, *I believe* in my case because I was using Household relationships and Addresses of Employers this caused a lot of duplicates.
  
  What did work for me was to set **Aggregation on**. Then setting Group by on your main element that you wish to not duplicate. Viola all is well!
  
  
  ---
  
  ### Answer by username_7 on 2020-04-23. Score: 0
  
  If you are still having trouble after setting DISTINCT as an option in the View, and specifying the Location Type hasn't helped -- then a RANDOM sort order may be the issue. Because of the way Drupal views handles random as a column *as well as* a ORDER BY clause, it breaks the distinctness of the query.
  
  
  ---
  
  