Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-22T10:31:44.130Z
Answers.Text: Thanks Brad! Worked like a charm :)
Answers.UserDisplayName: Stig Melón-Bratvold
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-22T03:26:33.093Z
Answers.LastActivityDate: 2020-04-22T03:26:33.093Z
Answers.UserDisplayName: Brad Bell
Body: <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>
  
Tags: <table-field>
Title: Check if a table field’s column has a value
ThreadText: # 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 %}
              <li><span class="bold">{{ row.hva }}:</span> <a href="{{ row.url }}">{{ row.hvem }}</a></li>
          {% else %}
              <li><span class="bold">{{ row.hva }}:</span> {{ row.hvem }}</li>
          {% 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 username_1! Worked like a charm :)  
  
  ---
  
  