case: I have 2 content types A & B and there is field in B which is entity reference of A and this field can hold multiple values from A "Multiple Values", so i created view to show records from B and i added some fields from A based on relation i made in the view "Entity Referenced", the problem is i get duplicated result if this field has multiple values even if i checked distinct in the view.

so is there direct way to solve it, or i have to fix it with custom code in custom module ?

3 Answers 3


I figured out good solution which is as follow: -A is the content type & B is the second content type
-A is field entity reference in the content type of A with multiple values.
-in the views in creating view of content type B just render the field of entity reverence A normally, by default it will render the title whether its 1 value or more.
-now the views for this field in formatter option choose Rendered Entity.
-and in view mode we can choose Tokens.
-now we got to the content type A and then go to manage display tab.
-at the bottom left in the menu click on Custom display settings and then check the option Tokens and click save.
-now in the top right tab "Tokens" display will appear, click on it. -now we choose which field we want to appear in the view & we can control the label, value, the format. for my case i just showed 1 field without the label and with plain text format and thats was great enough with out making relation and duplicate the content.

  • 1
    You have to delete the relationship to get rid of the duplicate rows. Commented Feb 8, 2018 at 11:12
  • This isn't a good solution if you want to use fields, and doesn't actually deal with the root of the problem.
    – colan
    Commented Jan 16, 2020 at 17:47

as my understanding this duplicated results are actually not duplicated :)

let's say we have two type:

  • content type is the cities (type B in your question)

  • content type is the employees (type A in your question

so, that means the view will look like

  • Jorge lives in Washington

  • Ali lives in Cairo

  • Hana lives in Washington

we can see here the Washington is not really duplicated because each one related the different employee

the general solution is the grouping like the following

Washington : Jorge + Hana
Cairo : Ali

if this is really your case,, i advice you to read this post

  • While insightful, this answer doesn't actually provide solutions.
    – colan
    Commented Jan 16, 2020 at 17:51

The problem is that the records actually are distinct from a database perspective as there are multiple records generated by different entity references.

The Drupal 8 core issue for this is Views relationships with multi-valued entity reference fields invalidate Distinct query option. There should be usable patches there.

For Drupal 7, use the Views Distinct module as it probably won't be fixed in Views.

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.