I have a Drupal view set up to display the CiviCRM address(es) related to a given contact:

Full view settings

Drupal view full settings

Query options

As a note, I have enabled the Distinct and Pure Distinct settings on the Drupal query settings:

Drupal view query settings showing Distinct and Pure Distinct enabled

CiviCRM contact page

On the CiviCRM contact page, there are only, for example, two unique addresses: CiviCRM Contact page showing two unique addresses

Duplicate addresses on Drupal view (caching?)

For some reason, the addresses are appearing multiple times on the Drupal view:

Drupal CiviCRM contact view showing duplicate addresses

How can I ensure that only distinct addresses are shown for a given contact?

  • Do you have any Views Relationships set? Can you post a screenshot of the full View, or provide the export code? Jun 3, 2017 at 17:45
  • Upon closer inspection, I realized all of the addresses are unique. For some reason, the zip code has been changed over time, or other minor changes have been made. How can I show only the latest revision? Jun 6, 2017 at 9:10
  • I don't believe there are address revisions, something else happening here. Pls post screenshot of complete View or the View export code so I can dig deep. Jun 6, 2017 at 15:23
  • I have added a full screenshot to the original question. Might this be some kind of Drupal caching issue? Jun 7, 2017 at 17:55
  • If you will notice. The only differences between the two versions of the Mailing and Worship addresses are that the street abbreviation "st" has an added period "st.". I thought there might be a revision stored somewhere, as the repeated addresses seem to be related to changes to the Address records. This is similarly evident on the Drupal view display, where the Albuquerwue addresses have had several minor changes including to the zipcode. Jun 7, 2017 at 20:37

3 Answers 3


If you can't sort the above out by ensuring you specify Location type (ie have a field for Zip = Worship, as well as Zip = Mailing) then I would try the views_field_view module.

I would make one view that pulls together the address details for just Worship, and another one that pulls together just the address for Mailing. Both these need to be set to use Contextual Filter = contact id. And set them both to only show 1 result

Then pull those both in as a Field and obviously use the contact_id as the contextual filter (also needs using on the two views you have to create)

  • 1
    Thanks petednz. The individual view per address type worked. I am still not sure what the underlying problem was, but your suggestion helped me to go forward. Jun 19, 2017 at 15:56
  • I am trying this solution out, but loading a view within a view can't be great for performance? It would be great to update the views integration code to work with address revisions?
    – Zachary
    May 29, 2018 at 21:14
  • Agreed but you can use caches to reduce impact perhaps. And how many folk are likely to be hitting this concurrently? My colleague is also recommending always using the view Relationships to get the Address data rather than the in-built civi field.
    – petednz - fuzion
    May 29, 2018 at 21:21

Make sure you select only the address where is_primary = 1

  • 1
    OR filter by location type = home, billing, work etc . Jun 3, 2017 at 14:10
  • This seems related to address revisions. The addresses may have been updated over time, for example changing the zip code, and for some reason the view is showing all of the revisions. How can I configure it to show only the current revision? Jun 6, 2017 at 9:11
  • For what it's worth, we do want to display multiple address types on the view, but only the latest revision of each type. Jun 6, 2017 at 9:30
  • Has anyone figured out how to only show the most recent address revision?
    – Zachary
    May 29, 2018 at 21:07

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.