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?
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.
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'
There is a work-around for this. Take the example of multiple phone numbers in a contact record.
- Include the Phone Number field once for each unique type of number (Home/Mobile, Home/Phone, Work/Phone etc)
- 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"
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],"
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
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.