<p>You were close... </p>

<p>Chaning this:</p>

<pre><code>{% if row.url == 0 %}    
</code></pre>

<p>to this:</p>

<pre><code>{% if row.url|length %}
</code></pre>

<p>should do it for you.</p>

CC BY-SA 4.0
2020-04-22T10:31:44.130Z
Thanks Brad! Worked like a charm :)
Stig Melón-Bratvold
CC BY-SA 4.0
2020-04-22T03:26:33.093Z
2020-04-22T03:26:33.093Z
Brad Bell
<p>I am using a table field to display credits on a portfolio page.
The table field has three columns: <code>hva</code>, <code>hvem</code> and <code>url</code>.</p>

<p>The <code>url</code> should be optional and I want to set up an if statement showing it as a link if it has a value. Is this possible using the table field?</p>

<p>Also, the table field can have multiple rows.</p>

<p>I have tried to set up an if for <code>row.url</code> to see if has a value. And an else for when there is no URL.</p>

<pre><code>{% if entry.credits|length %}
    {% for row in entry.credits %}
        {% if row.url == 0 %}
            &lt;li&gt;&lt;span class="bold"&gt;{{ row.hva }}:&lt;/span&gt; &lt;a href="{{ row.url }}"&gt;{{ row.hvem }}&lt;/a&gt;&lt;/li&gt;
        {% else %}
            &lt;li&gt;&lt;span class="bold"&gt;{{ row.hva }}:&lt;/span&gt; {{ row.hvem }}&lt;/li&gt;
        {% endif %}
    {% endfor %}
{% endif %}
</code></pre>

<table-field>
Check if a table field’s column has a value
# Check if a table field’s column has a value

(Asked by: username_0 on 2020-04-21)

I am using a table field to display credits on a portfolio page.
The table field has three columns: hva, hvem and url.
The url should be optional and I want to set up an if statement showing it as a link if it has a value. Is this possible using the table field?
Also, the table field can have multiple rows.
I have tried to set up an if for row.url to see if has a value. And an else for when there is no URL.
{% if entry.credits|length %}
    {% for row in entry.credits %}
        {% if row.url == 0 %}
            {{ row.hva }}: {{ row.hvem }}
        {% else %}
            {{ row.hva }}: {{ row.hvem }}
        {% endif %}
    {% endfor %}
{% endif %}

**Tags:** table-field

---

## 1 answers

### Answer by username_1 on 2020-04-22. Score: 2 | Accepted answer

You were close... 
Chaning this:
{% if row.url == 0 %}    

to this:
{% if row.url|length %}

should do it for you.

> **Comments:**
> **username_0**: Thanks Brad! Worked like a charm :)  

---

