How to tell whether a SuperTable column has data or is empty? I have a "contact table" SuperTable with columns for Name, Phone, Email, and Website. In the template, I'm displaying the data as a table.

I only want to generate table columns if a column has data. For example, if there are no Phone Numbers included, I don't want a Phone column. If even one row has a phone number, I do want to include that column.

How do I create a conditional to check whether a SuperTable column has data in it?

This might be related to Querying a supertable field.
I forget who solved this for me! I think it was Michael van Dorth.

&lt;div class="table-overflow content-row"&gt;
    &lt;table class="table {{ table_class }}"&gt;

      {# Caption #}
      {% if block.caption %}
        &lt;caption class="caption"&gt;{{ block.caption }}&lt;/caption&gt;
      {% endif %}

      {# Setup #}
      {% set rows = block.contactTable.all() %}
      {% set phoneRows = 0 %}
      {% set emailRows = 0 %}
      {% set websiteRows = 0 %}

      {% for row in rows %}
        {% if row.phone != '' %}
          {% set phoneRows = phoneRows + 1 %}
        {% endif %}
        {% if row.email != '' %}
          {% set emailRows = emailRows + 1 %}
        {% endif %}
        {% if row.website != '' %}
          {% set websiteRows = websiteRows + 1 %}
        {% endif %}
      {% endfor %}

      {# Headings #}
      &lt;thead class="thead_class"&gt;
        &lt;tr&gt;
          &lt;th scope="col"&gt;Name&lt;/th&gt;
          {% if phoneRows &gt; 0 %}&lt;th scope="col"&gt;Phone&lt;/th&gt;{% endif %}
          {% if emailRows &gt; 0 %}&lt;th scope="col"&gt;Email&lt;/th&gt;{% endif %}
          {% if websiteRows &gt; 0 %}&lt;th scope="col"&gt;Website&lt;/th&gt;{% endif %}
        &lt;/tr&gt;
      &lt;/thead&gt;

      {# Body #}
      &lt;tbody class="tbody_class"&gt;
        {% for row in block.contactTable.all() %}

          &lt;tr&gt;

            &lt;th scope="row"&gt;{{ row.contactName }}&lt;/th&gt;

            {% if phoneRows &gt; 0 %}
              &lt;td&gt;{% if row.phone|length %}{{ row.phone.link }}{% endif %}&lt;/td&gt;
            {% endif %}

            {% if emailRows &gt; 0 %}
              &lt;td&gt;{% if row.email|length %}
                &lt;a class="btn" href="{{ row.email.url }}" aria-label="{{ row.contactName ~ ' email' }}"&gt;Email&lt;/a&gt;
              {% endif %}&lt;/td&gt;
            {% endif %}

            {% if websiteRows &gt; 0 %}
              &lt;td&gt;{% if row.website|length %}
                &lt;a class="btn" href="{{ row.website.url }}" aria-label="{{ row.contactName ~ ' website' }}"&gt;Website&lt;/a&gt;
              {% endif %}&lt;/td&gt;
            {% endif %}

          &lt;/tr&gt;

        {% endfor %}
      &lt;/tbody&gt;

    &lt;/table&gt;
  &lt;/div&gt;