> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/sdocs/advanced-template-logic/related-lists.md).

# Insert Data Tables

Build dynamic S-Docs data tables with related lists and direct SOQL. Start here for task guides, Microsoft template patterns, and troubleshooting.

Use this section when you need repeating data tables in an S-Docs template.

In S-Docs, most tables are built with **related lists** powered by **direct SOQL**.

Use this section to choose the right path for row selection, output formatting, Microsoft template layout, and troubleshooting.

{% hint style="info" %}
The query logic stays the same across formats. Microsoft templates use a different table wrapper around the same related list pattern.
{% endhint %}

### Start with the path that fits your goal

If you need to return the right rows, start with filtering and sorting.

If the query already works, move to formatting, summaries, and cleaner output.

If you are building DOCX, or PPTX output, use the [Microsoft template guide](/sdocs/advanced-template-logic/related-lists/how-to-create-a-table-in-microsoft-templates-docx-pptx.md).

<table data-column-title-hidden data-view="cards"><thead><tr><th>Title</th><th>Description</th><th data-card-target data-type="content-ref">Target</th></tr></thead><tbody><tr><td><strong>Getting Started with Related Lists</strong></td><td>Learn the core related list pattern, then build your first repeating table.</td><td><a href="/quick-start/template-building/adding-tables-like-products-or-contacts-to-your-document.md">Adding Tables (Like Products or Contacts) to Your Document</a></td></tr><tr><td><strong>Filter and Sort a Related List</strong></td><td>Use WHERE, ORDER BY, LIMIT, and relationship fields to return the right rows.</td><td><a href="/sdocs/advanced-template-logic/related-lists/how-to-filter-and-sort-a-related-list.md">How to: Filter and Sort a Related List</a></td></tr><tr><td><strong>Related List Reference</strong></td><td>Use the reference when you need structure, syntax, and deeper examples.</td><td><a href="/developer-hub/template-configuration-and-styling/related-list-references.md">Related List References</a></td></tr></tbody></table>

### What you can do with data tables

* Extract child records into repeated rows.
* Filter, sort, and limit records using direct SOQL.
* Format dates, currency, and handle blank values in table output.
* Create grouped summaries and calculate aggregate totals.
* Render repeating tables in PDF and Microsoft templates.

### Browse by topic

* [Related List How-To Guides](/sdocs/advanced-template-logic/related-lists/how-to-filter-and-sort-a-related-list.md)
* [How to: Filter and Sort a Related List](/sdocs/advanced-template-logic/related-lists/how-to-filter-and-sort-a-related-list.md)
* [How to: Format and Summarize a Related List](/sdocs/advanced-template-logic/related-lists/how-to-format-and-summarize-a-related-list.md)
* [How to: Create a Table In Microsoft Templates (DOCX, PPTX, XLSX)](/sdocs/advanced-template-logic/related-lists/how-to-create-a-table-in-microsoft-templates-docx-pptx.md)
* [Additional Troubleshooting](/sdocs/advanced-template-logic/related-lists/additional-troubleshooting.md)

### Related note

Use [Retrieve and Reuse Data](/sdocs/advanced-template-logic/named-query.md) when you need query results in a sentence, header, footer, or calculation instead of a table.


---

# 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://help.sdocs.com/sdocs/advanced-template-logic/related-lists.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.
