<p>If I understand correctly, you want to show a list of entries that only match the entry type of "My Type" and group them together by date. A simplified list might look something like this:</p>

<pre><code>Jan 1, 2017
  entry 1
  entry 5
  entry 8

Jan 4, 2017
  entry 2
  entry 4
  entry 11

Jan 11, 2017
  entry 6
</code></pre>

<p>First, you'll have to specify the entry type with it's handle (camel case) like "myType" not "My Type."</p>

<p>Following the example from Craft's docs on the <a href="https://craftcms.com/docs/templating/filters#group" rel="nofollow noreferrer">group filter</a>, you would probably do something like this:</p>

<pre class="lang-twig prettyprint-override"><code>{# Get attempts entries matching entry type 'myType' #}
{% set attempts = craft.entries.section('attempts').type('myType').find() %}

{# Group attempts by date #}
{% for date, attemptsByDate in attempts|group('attemptDate.day') %}

  &lt;h2&gt;{{ date|date('M j, Y') }}&lt;/h2&gt;

  {# loop thru the attempts grouped by date  #}
  &lt;ul&gt;
    {% for entry in attemptsByDate %}
      &lt;li&gt;{{ entry.title }}&lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
{% endfor %}
</code></pre>

<p>If there were other entries that didn't match type 'myType' on another day, say Jan 3rd, you won't see Jan 3rd in the list at all.</p>

<p>I'm not totally sure what you need to do with <code>{{ count }}</code> and <code>{{ total }}</code>, but hopefully this gets you on the right track.</p>

CC BY-SA 3.0
2017-03-02T05:32:52.097Z
2017-03-03T01:26:53.853Z
2017-03-03T01:26:53.853Z
Alex Roper
<p>This should work:</p>

<pre><code>{% for date, attempt in attempts|group('attemptDate') %}
    &lt;tr&gt;
      &lt;td&gt;{{ date|date('M j, Y') }}&lt;/td&gt;
      {% for entry in attempt %}
        {% if entry.type == 'My Type' %}
          &lt;td&gt;{{ entry.title }}&lt;/td&gt;
        {% endif %}
      {% endfor %}
    &lt;/tr&gt;
  {% endfor %}
</code></pre>

<p>I don't know what you want to do with the 'type' of the entries?
But if you want to limit the amount of entries according to type, you could fill "attempts" with all entries of a certain type first and then loop through them. Than you could remove the if statement which would be cleaner and faster I think.</p>

<p>So something like: </p>

<pre><code>{% set attempts = craft.entries.section("something").type("My Type").find() %}
</code></pre>

CC BY-SA 3.0
2017-01-29T14:28:32.957Z
2017-01-29T14:35:11.823Z
2017-01-29T14:35:11.823Z
Tom De Smet
<p>I am grouping entries that have the same date together so that I only get a single date. Works great.</p>

<p>I would like to loop through each entry that has that date and I'm not having much luck. I want to show </p>

<p>Here is what I have so far:</p>

<pre><code>{% for date, attempt in attempts|group('attemptDate') %}
    &lt;tr&gt;
        &lt;td&gt;{{ date|date('M j, Y') }}&lt;/td&gt;
        {% if type == 'My Type' %}
            {# Get all entries where type = My Type &amp; entry.attemptDate = date. #}
            {% set total = 0 %}
            {% count = 0 %}
            {% for ?? in ?? %} {# 
                {% total = loop.index %}
                {% count = {# if value in myField is true #} %}
                &lt;td&gt;{{ count }}/{{ total }}&lt;/td&gt;
            {% endfor %}
        {% endif %}
    &lt;/tr&gt;
{% endfor %}
</code></pre>

<p>Thank you for any suggestions!</p>

CC BY-SA 3.0
2017-01-29T09:31:06.543Z
{% for entry in attempt not working? %}
Jan_dh
<templating>
How can I use a where statement with grouped results?
# How can I use a where statement with grouped results?

(Asked by: username_0 on 2017-01-29)

I am grouping entries that have the same date together so that I only get a single date. Works great.
I would like to loop through each entry that has that date and I'm not having much luck. I want to show 
Here is what I have so far:
{% for date, attempt in attempts|group('attemptDate') %}
    
        {{ date|date('M j, Y') }}
        {% if type == 'My Type' %}
            {# Get all entries where type = My Type & entry.attemptDate = date. #}
            {% set total = 0 %}
            {% count = 0 %}
            {% for ?? in ?? %} {# 
                {% total = loop.index %}
                {% count = {# if value in myField is true #} %}
                {{ count }}/{{ total }}
            {% endfor %}
        {% endif %}
    
{% endfor %}

Thank you for any suggestions!

**Tags:** templating
> **Comments:**
> **username_1**: {% for entry in attempt not working? %}  

---

## 2 answers

### Answer by username_2 on 2017-03-02. Score: 1

If I understand correctly, you want to show a list of entries that only match the entry type of "My Type" and group them together by date. A simplified list might look something like this:
Jan 1, 2017
  entry 1
  entry 5
  entry 8

Jan 4, 2017
  entry 2
  entry 4
  entry 11

Jan 11, 2017
  entry 6

First, you'll have to specify the entry type with it's handle (camel case) like "myType" not "My Type."
Following the example from Craft's docs on the group filter, you would probably do something like this:
{# Get attempts entries matching entry type 'myType' #}
{% set attempts = craft.entries.section('attempts').type('myType').find() %}

{# Group attempts by date #}
{% for date, attemptsByDate in attempts|group('attemptDate.day') %}

  {{ date|date('M j, Y') }}

  {# loop thru the attempts grouped by date  #}
  
    {% for entry in attemptsByDate %}
      {{ entry.title }}
    {% endfor %}
  
{% endfor %}

If there were other entries that didn't match type 'myType' on another day, say Jan 3rd, you won't see Jan 3rd in the list at all.
I'm not totally sure what you need to do with {{ count }} and {{ total }}, but hopefully this gets you on the right track.


---

### Answer by username_3 on 2017-01-29. Score: 1

This should work:
{% for date, attempt in attempts|group('attemptDate') %}
    
      {{ date|date('M j, Y') }}
      {% for entry in attempt %}
        {% if entry.type == 'My Type' %}
          {{ entry.title }}
        {% endif %}
      {% endfor %}
    
  {% endfor %}

I don't know what you want to do with the 'type' of the entries?
But if you want to limit the amount of entries according to type, you could fill "attempts" with all entries of a certain type first and then loop through them. Than you could remove the if statement which would be cleaner and faster I think.
So something like: 
{% set attempts = craft.entries.section("something").type("My Type").find() %}


---

