# Group By

## Grouping Items

If you want to group your data by a specific column (like **Status**, **Priority**, or **Owner**), you can fully control how the grouped output appears in your document – directly from your Word template.

This is done by using **custom placeholders** in your template.

{% embed url="<https://youtu.be/TdBTKctKgMg?si=lcKplkjBZbL6224U&t=285>" %}

### The Logic

To group your output, simply wrap the section you want repeated inside two custom placeholders:

{{TableStart:GroupByColumnName}}\
\
{{TableEnd:GroupByColumnName}}

Replace `ColumnName` with the exact name of the column you want to group by.

### Examples

```
{{TableStart:GroupByShipping Method}}
[Your content/table here]
{{TableEnd:GroupByShipping Method}}
```

'Shipping Method' is the title of your status column. <br>

<figure><img src="/files/2y8WCONSDUCgZNQz9Z0k" alt=""><figcaption></figcaption></figure>

If you have a status column called 'Priority', it would be:

```
{{TableStart:GroupByPriority}}
[Your content/table here]
{{TableEnd:GroupByPriority}}
```

This will create one grouped section per priority (e.g., "High", "Medium", "Low").

## Grouping Subitems

You can also group **subitems** by any of their own columns — for example, by their Status, Priority, or Person column. This works just like grouping on the main item level, but uses a dedicated subitem group placeholder wrapped around a standard **`Subitems`** table.

### The Logic

Wrap your subitems table with a **`GroupBySubitem...`** placeholder pair, naming the subitem column you want to group by:

```
{{TableStart:GroupBySubitemColumnName}}
    {{TableStart:Subitems}}
    ---
    {{TableEnd:Subitems}}
{{TableEnd:GroupBySubitemColumnName}}
```

Replace **`ColumnName`** with the exact name of the **subitem** column you want to group by.

### Example

To group subitems by their Status column:

```
{{TableStart:GroupBySubitemStatus}}
    {{TableStart:Subitems}}
    ---
    {{TableEnd:Subitems}}
{{TableEnd:GroupBySubitemStatus}}
```

Each status value (e.g. *Done*, *Working on it*, *Stuck*) will produce its own section, containing only the subitems that match that status.

### Example docx template

Download: **Item-Level template** with grouped subitems table

{% file src="/files/xpalsP14C6SahDbVoA3q" %}

Download: **Board-Level template** with grouped items and subitems combined

{% file src="/files/SqNVtO0ZQCGoDXNDONrk" %}

{% hint style="info" %}
Tip: Subitem grouping can be combined with regular item-level grouping — place the GroupBySubitem... block inside your main item loop to group each item's subitems individually.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.docexport.com/template/advanced-options/group-by.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
