Answers.Body: <p>I'd probably try to filter those out in your initial query, but if you've already got them, something like this should work:</p>
  
  <pre><code>{% set existingIds = [] %}
  
  {% for event in events %}
      {% if event.id not in existingIds %}
          {{ event.title }}
  
          {% set existingIds = existingIds|merge([event.id]) %}
      {% endif %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-09T02:17:05.237Z
Answers.Text: Of course that worked like a charm. Thanks. I tried to close that block on line 7, but the edit had to be 6 characters.
Answers.UserDisplayName: Ben Shoults
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-04-08T23:46:09.513Z
Answers.LastActivityDate: 2016-04-09T06:31:55.410Z
Answers.LastEditDate: 2016-04-09T06:31:55.410Z
Answers.UserDisplayName: Brad Bell
Body: <p>Is it possible to loop through the list of entries and filter out any that have the same ID as any of the other entries (duplicates)? I have a specific case where this is an issue. I want to keep the first entry, but filter out the rest of them. I'm thinking it might work something like this...</p>
  
  <pre><code>  {% for event in events %}
      {% IF FIRST INSTANCE OF ENTRY %}
        {{ event.title }}
      {% endif %}
    {% endfor %}
  </code></pre>
  
Tags: <forloop>
Title: Check and remove repeat entries from loop
ThreadText: # Check and remove repeat entries from loop
  
  (Asked by: username_0 on 2016-04-08)
  
  Is it possible to loop through the list of entries and filter out any that have the same ID as any of the other entries (duplicates)? I have a specific case where this is an issue. I want to keep the first entry, but filter out the rest of them. I'm thinking it might work something like this...
  
  ```
    {% for event in events %}
      {% IF FIRST INSTANCE OF ENTRY %}
        {{ event.title }}
      {% endif %}
    {% endfor %}
  
  ```
  
  **Tags:** forloop
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-04-08. Score: 6 | Accepted answer
  
  I'd probably try to filter those out in your initial query, but if you've already got them, something like this should work:
  
  ```
  {% set existingIds = [] %}
  
  {% for event in events %}
      {% if event.id not in existingIds %}
          {{ event.title }}
  
          {% set existingIds = existingIds|merge([event.id]) %}
      {% endif %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Of course that worked like a charm. Thanks. I tried to close that block on line 7, but the edit had to be 6 characters.  
  
  ---
  
  