Answers.Body: <p>The simplest way is to create a "filtered" array, containing the unique cables, and then loop through that.</p>
  
  <p>For example:</p>
  
  <pre><code>{# Build the "filtered" array of cables #}
  {% set filteredCables = [] %}
  
  {% for row in entry.tests %}
      {% for cable in row.cables %}
          {% if cable.title not in filteredCables %}
              {% set filteredCables = filteredCables|merge([cable.title]) %}
          {% endif %}
      {% endfor %}
  {% endfor %}
  
  {# Output the unique cables #}
  {% for cable in filteredCables %}
      {{ cable }}&lt;br /&gt;
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-21T16:34:21.937Z
Answers.Text: Thanks for this @StephenLewis - I had actually tried this as I picked it up from another stack exchange post. However, I keep hitting them same error; Variable "filteredCables" does not exist.
  
  I have tried to set the {% set filteredCables = [] %} before I then set it in the loop but it still seems to output all the cables (duplicates) and not a filtered list. Any ideas?
Answers.UserDisplayName: Terry Upton
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-21T16:37:06.503Z
Answers.Text: Regarding the variable does not exist error, you could do this: `{% set filteredCables = filteredCables|default([])merge([cable]) %}`. As for it not outputting a filtered list, have you tried just adding the titles? For example: `{% if cable.title not in filteredCables %}{% set filteredCables = filteredCables|default([])|merge([cable]) %}{% endif %}`
Answers.UserDisplayName: Stephen Lewis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-21T17:17:16.117Z
Answers.Text: Thanks Stephen - the problem was solved by setting cable.title. I had to add an empty variable at the start outside the loop too {% set filteredCables = [] %}. Thanks for putting me in the right direction.
Answers.UserDisplayName: Terry Upton
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-21T17:31:23.313Z
Answers.Text: Glad you got it sorted. I've updated the answer to use the cable title.
Answers.UserDisplayName: Stephen Lewis
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-21T16:26:49.293Z
Answers.LastActivityDate: 2017-03-21T17:30:55.120Z
Answers.LastEditDate: 2017-03-21T17:30:55.120Z
Answers.UserDisplayName: Stephen Lewis
Body: <p>Anyone able to assist me with removing duplicates in this example?
  So I have a related entries (cables) setup in a SuperTable. Some of these entries are duplicated across different rows. So a cable might be related to the first row in the SuperTable and also row3 and row4.</p>
  
  <p>I want to be able to run through all these cables in any SuperTable row and output the entries just once not duplicated.
  So as an example a basic SuperTable setup like this;</p>
  
  <pre><code>{% for row in entry.tests %}
      {% for cable in row.cables %}
          {{ cable.title }}&lt;br /&gt;
      {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p>would output this;<br>
  BS 7211<br>
  BS EN 50525<br>
  BS 6724<br>
  BS 8573<br>
  BS 7835<br>
  BS 7629-1<br>
  BS 8436<br>
  BS 5467<br>
  BS 6724<br>
  BS 7846<br>
  BS 6622<br>
  BS 7835  </p>
  
  <p>I want to essentially loop through and only display the related entry once. As you can see from the example some entries are duplicated (e.g BS 6724)</p>
  
Tags: <relations><array><plugin-supertable>
Title: Remove duplicated entries from SuperTable related entries
ThreadText: # Remove duplicated entries from SuperTable related entries
  
  (Asked by: username_0 on 2017-03-21)
  
  Anyone able to assist me with removing duplicates in this example?
  So I have a related entries (cables) setup in a SuperTable. Some of these entries are duplicated across different rows. So a cable might be related to the first row in the SuperTable and also row3 and row4.
  
  I want to be able to run through all these cables in any SuperTable row and output the entries just once not duplicated.
  So as an example a basic SuperTable setup like this;
  
  ```
  {% for row in entry.tests %}
      {% for cable in row.cables %}
          {{ cable.title }}<br />
      {% endfor %}
  {% endfor %}
  
  ```
  
  would output this;  
  BS 7211  
  BS EN 50525  
  BS 6724  
  BS 8573  
  BS 7835  
  BS 7629-1  
  BS 8436  
  BS 5467  
  BS 6724  
  BS 7846  
  BS 6622  
  BS 7835
  
  I want to essentially loop through and only display the related entry once. As you can see from the example some entries are duplicated (e.g BS 6724)
  
  **Tags:** relations, array, plugin-supertable
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-03-21. Score: 2 | Accepted answer
  
  The simplest way is to create a "filtered" array, containing the unique cables, and then loop through that.
  
  For example:
  
  ```
  {# Build the "filtered" array of cables #}
  {% set filteredCables = [] %}
  
  {% for row in entry.tests %}
      {% for cable in row.cables %}
          {% if cable.title not in filteredCables %}
              {% set filteredCables = filteredCables|merge([cable.title]) %}
          {% endif %}
      {% endfor %}
  {% endfor %}
  
  {# Output the unique cables #}
  {% for cable in filteredCables %}
      {{ cable }}<br />
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks for this @username_1 - I had actually tried this as I picked it up from another stack exchange post. However, I keep hitting them same error; Variable "filteredCables" does not exist.  I have tried to set the {% set filteredCables = [] %} before I then set it in the loop but it still seems to output all the cables (duplicates) and not a filtered list. Any ideas?  
  > **username_1**: Regarding the variable does not exist error, you could do this: `{% set filteredCables = filteredCables|default([])merge([cable]) %}`. As for it not outputting a filtered list, have you tried just adding the titles? For example: `{% if cable.title not in filteredCables %}{% set filteredCables = filteredCables|default([])|merge([cable]) %}{% endif %}`  
  > **username_0**: Thanks username_1 - the problem was solved by setting cable.title. I had to add an empty variable at the start outside the loop too {% set filteredCables = [] %}. Thanks for putting me in the right direction.  
  > **username_1**: Glad you got it sorted. I've updated the answer to use the cable title.  
  
  ---
  
  