> For the complete documentation index, see [llms.txt](https://docs.feathery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.feathery.io/platform/document-autofill-and-signatures/autofill-document-templates/word-doc-autofill/dynamic-tables.md).

# Dynamic Tables

This snippet lets you create tables that automatically adjust to match the length of your field values. The generated table will have one column per field.

### Table Configuration

1. **Add each field to the setup line** which determines the number of table rows:

   ```django
   {% set max_length = [<field_1>|length, <field_2>|length, <field_3>|length]|max %}
   ```

   \
   For each field you want in the table, add `<field>|length` in between the  `[` and `]`, and separate with commas
2. **Create the table structure** with dynamic content:

<table data-header-hidden><thead><tr><th></th><th width="249.265625"></th><th></th></tr></thead><tbody><tr><td>Header one</td><td>Header two</td><td>Header three</td></tr><tr><td>{%tr for i in range(max_length) %}</td><td></td><td></td></tr><tr><td>{{ &#x3C;field>[i] if i &#x3C; &#x3C;field>|length else "" }}</td><td>{{ &#x3C;field>[i] if i &#x3C; &#x3C;field>|length else "" }}</td><td>{{ &#x3C;field>[i] if i &#x3C; &#x3C;field>|length else "" }}</td></tr><tr><td>{%tr endfor %}</td><td></td><td></td></tr></tbody></table>

3. **Add header columns** to match your table structure. These can be plain text, or make use of a field value using `{{ <field> }}` .
4. **Add columns in between the table template rows (third row)** to match your desired table and fill with field values:

   ```django
   {{ <field>[i] if i < <field>|length else "" }}
   ```

{% hint style="info" %}
Make sure you replace every `<field>` with your own field names!
{% endhint %}

### Finished Table

<figure><img src="https://640450274-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHAVngDAEk3s8Bw7P6Ntz%2Fuploads%2F3NHhYbOBDNPAaqgfFU5n%2Fimage.png?alt=media&amp;token=e64a1ae4-3deb-4ef9-b8fa-26efb97702ba" alt="" width="563"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.feathery.io/platform/document-autofill-and-signatures/autofill-document-templates/word-doc-autofill/dynamic-tables.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
