<p>Assuming you can have multiple <code>person</code> blocks per entry (<code>group</code>), you could:</p>
<p>Fetch your entries and <a href="https://craftcms.com/docs/3.x/dev/eager-loading-elements.html#eager-loading-elements-related-to-matrix-blocks" rel="nofollow noreferrer">eager-load the blocks and their entry</a> to save some overheads</p>
<pre><code>{% set group = craft
    .entries()
    .id([100,200,300])
    .with(['people.person:entry'])
    .all() %}
</code></pre>
<p>Then build an array with each <code>person.entry</code></p>
<pre><code>{# The array to store your person.entry #}
{% set people = [] %}

{# Iterate over your group #}
{% for entry in group %}

    {# Iterate over each blocks and push the person.entry to your people array #}

    {% for person in entry.people %}
        {% set people = people | merge ([person.entry[0]]) %}
    {% endfor %}
{% endfor %}
</code></pre>
<p>Then use <code>unique</code> (<a href="https://craftcms.com/docs/3.x/dev/filters.html#unique" rel="nofollow noreferrer">docs</a>) to dedupe your <code>people</code> as you display:</p>
<pre><code>{% for person in people | unique %}
    {{ person.title }} &lt;br&gt;
{% endfor %}
</code></pre>

CC BY-SA 4.0
2020-11-06T16:05:41.840Z
Thank you, that worked perfectly.
triplethreat23
CC BY-SA 4.0
2020-11-06T14:58:46.477Z
2020-11-06T14:58:46.477Z
Oli
<p>I have a set of entries I am pulling ID. (group)
Each of those entries has a Matrix Block. (people)
That Matrix Block Type (person) has an entries field.
In some cases the same entry (person) is assigned to multiple entries in the group via the Matrix Block.
I want to show the matrix blocks from my group only once without duplicates.</p>
<p>Pseudo Code</p>
<pre><code>{% set group = craft.entries.id([100,200,300]) %}

{% for entry in group %}

    {% for person in entry.people %}

        {% if person not already displayed %}

            {% set person_entry = person.entry.one() %}

            {{ person_entry.title }}

        {% endif %}
    
    {% endfor %}

{% endfor %}
</code></pre>

<entries><matrix><blocks><block-types>
Pull Matrix Block from Multiple Entries without Showing Duplicates
# Pull Matrix Block from Multiple Entries without Showing Duplicates

(Asked by: username_0 on 2020-11-05)

I have a set of entries I am pulling ID. (group)
Each of those entries has a Matrix Block. (people)
That Matrix Block Type (person) has an entries field.
In some cases the same entry (person) is assigned to multiple entries in the group via the Matrix Block.
I want to show the matrix blocks from my group only once without duplicates.
Pseudo Code
{% set group = craft.entries.id([100,200,300]) %}

{% for entry in group %}

    {% for person in entry.people %}

        {% if person not already displayed %}

            {% set person_entry = person.entry.one() %}

            {{ person_entry.title }}

        {% endif %}
    
    {% endfor %}

{% endfor %}

**Tags:** entries, matrix, blocks, block-types


---

## 1 answers

### Answer by username_1 on 2020-11-06. Score: 2 | Accepted answer

Assuming you can have multiple person blocks per entry (group), you could:
Fetch your entries and eager-load the blocks and their entry to save some overheads
{% set group = craft
    .entries()
    .id([100,200,300])
    .with(['people.person:entry'])
    .all() %}

Then build an array with each person.entry
{# The array to store your person.entry #}
{% set people = [] %}

{# Iterate over your group #}
{% for entry in group %}

    {# Iterate over each blocks and push the person.entry to your people array #}

    {% for person in entry.people %}
        {% set people = people | merge ([person.entry[0]]) %}
    {% endfor %}
{% endfor %}

Then use unique (docs) to dedupe your people as you display:
{% for person in people | unique %}
    {{ person.title }} 
{% endfor %}

> **Comments:**
> **username_0**: Thank you, that worked perfectly.  

---

