<p>OK, one possible way is the use the value of the colour field in an <em>if statement</em>, something this:</p>

<pre><code>{# list rows that have "blue" in the colour field #}
{% for row in table.fieldName %}
{% if row.colour == 'blue' %} // probably best to make "blue" a variable
    &lt;li&gt;{{ row.age }} - {{ row.provider }} - etc.&lt;/li&gt;
{% endif %}
</code></pre>

<p>In order to sort the table by a field value you will have to create a new array with the table data, then order by the name value. Will work that up for you in a bit</p>

<p>You could also do it with JavaScript, but that is nasty. </p>

<p>Here is the complete code using an Array to sort by the age field:</p>

<pre><code>{% set tableBlock = [] %}
{% set tableRow = [] %} 

{% for row in entry.myTableField %} 
    {% if row.colour == "blue" %}

    {% set tableRow = {
        'age' : row.age,
        'colour' : row.colour,
        'provider' : row.provider
    } %}
{% set tableBlock = tableBlock|merge([tableRow]) %} 
    {% endif %}

{% endfor %}

{% for row in tableBlock|sort %}
    <li>{{row.age}} {{row.colour}} {{row.provider}}</li>
{% endfor %}</code></pre>

<p>For some reason the code block formatting is not working...</p>

CC BY-SA 4.0
2019-01-01T20:44:12.373Z
Glad to be of help!
Roi Agneta
CC BY-SA 4.0
2018-12-31T20:53:59.567Z
2018-12-31T21:33:24.750Z
2018-12-31T21:33:24.750Z
Roi Agneta
<p>I have an entry called "reviews" and within reviews I have a table field with several values. I would like to use the field values to display entry listings in a particular way.</p>

<p>First: I would like to be able to display entry listings so that if the field value is = x to display a particular set of entries.</p>

<p>Second: I would like to be able to display these values so that they are in an ascending order.</p>

CC BY-SA 4.0
2018-12-31T20:20:38.703Z
I think you will need to be more specific, perhaps give a code example?
Roi Agneta
CC BY-SA 4.0
2018-12-31T20:32:45.153Z
@RoiAgenta

My entry type name is "reviews" and I have created a table field with the handle "reviewData". Within this table are a few columns columns with the handle names "age, provider, colour, style".  

As per my first question I would like to display all review entries with the colour = "blue" in one listing.  

For the second question I would like to display all review entires in ascending order according to their age value.
Aleks P
<craft3>
Is it possible to filter entries based on entry table field values?
# Is it possible to filter entries based on entry table field values?

(Asked by: username_0 on 2018-12-31)

I have an entry called "reviews" and within reviews I have a table field with several values. I would like to use the field values to display entry listings in a particular way.

First: I would like to be able to display entry listings so that if the field value is = x to display a particular set of entries.

Second: I would like to be able to display these values so that they are in an ascending order.

**Tags:** craft3
> **Comments:**
> **username_1**: I think you will need to be more specific, perhaps give a code example?  
> **username_0**: @RoiAgenta  My entry type name is "reviews" and I have created a table field with the handle "reviewData". Within this table are a few columns columns with the handle names "age, provider, colour, style".    As per my first question I would like to display all review entries with the colour = "blue" in one listing.    For the second question I would like to display all review entires in ascending order according to their age value.  

---

## 1 answers

### Answer by username_1 on 2018-12-31. Score: 2 | Accepted answer

OK, one possible way is the use the value of the colour field in an if statement, something this:
{# list rows that have "blue" in the colour field #}
{% for row in table.fieldName %}
{% if row.colour == 'blue' %} // probably best to make "blue" a variable
    {{ row.age }} - {{ row.provider }} - etc.
{% endif %}

In order to sort the table by a field value you will have to create a new array with the table data, then order by the name value. Will work that up for you in a bit
You could also do it with JavaScript, but that is nasty. 
Here is the complete code using an Array to sort by the age field:
{% set tableBlock = [] %}
{% set tableRow = [] %} 

{% for row in entry.myTableField %} 
    {% if row.colour == "blue" %}

    {% set tableRow = {
        'age' : row.age,
        'colour' : row.colour,
        'provider' : row.provider
    } %}
{% set tableBlock = tableBlock|merge([tableRow]) %} 
    {% endif %}

{% endfor %}

{% for row in tableBlock|sort %}
    {{row.age}} {{row.colour}} {{row.provider}}
{% endfor %}
For some reason the code block formatting is not working...

> **Comments:**
> **username_1**: Glad to be of help!  

---

