> For the complete documentation index, see [llms.txt](https://developer.collibra.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.collibra.com/api/guides/introduction/the-output-module-query-language/map-the-results-to-a-tabular-format/handling-to-many-results-in-a-tabular-format.md).

# Handling to-many results in a tabular format

You can select all assets from a domain together with their `Note` attributes. Each asset may have multiple notes. When there are multiple notes, the most recent note should be ordered at the top of the list.

The `TableViewConfig` may look similar to the example below.

{% tabs %}
{% tab title="JSON" %}

```json
{
  "TableViewConfig": {
    "Resources": {
      "Asset": {
        "Id": { "name": "assetId" },
        "Signifier": { "name": "assetName" },
        "StringAttribute": {
          "LongExpression": { "name": "note" },
          "CreatedOn": { "name": "noteCreatedOn" },
          "Order": [ { "Field": { "name": "noteCreatedOn", "order": "DESC" } } ]
        },
        "Domain": {
          "Id": { "name": "domainId" }
        },
        "Filter": { "Field": { "name": "domainId", "operator": "EQUALS", "value": "f342423f-54fd-4643-935b-adbd9e7f5e25" } },
        "Order": [ { "Field": { "name": "assetName" } } ]
      }
    },
    "Columns": [
      { "Column": { "fieldName": "assetId" } },
      { "Column": { "fieldName": "assetName" } },
      { "Column": { "fieldName": "note" } }
    ]
  }
}
```

{% endtab %}

{% tab title="YAML" %}

```yaml
---
TableViewConfig:
  Resources:
    Asset:
      Id:
        name: "assetId"
      Signifier:
        name: "assetName"
      StringAttribute:
        LongExpression:
          name: "note"
        CreatedOn:
          name: "noteCreatedOn"
        Order:
        -
          Field:
            name: "noteCreatedOn"
            order: "DESC"
      Domain:
        Id:
          name: "domainId"
      Filter:
        Field:
          name: "domainId"
          operator: "EQUALS"
          value: "f342423f-54fd-4643-935b-adbd9e7f5e25"
      Order:
      -
        Field:
          name: "assetName"
  Columns:
  -
    Column:
      fieldName: "assetId"
  -
    Column:
      fieldName: "assetName"
  -
    Column:
      fieldName: "note"
```

{% endtab %}
{% endtabs %}

Depending on the format requested, the results might be different. In Excel or CSV format, each asset is duplicated on a new row for each note value.

<img src="/files/jVJHzIbGBQFpxdK2Enyn" alt="Example of Collibra asset with multiple notes, with each note on a different row in Excel export" width="50%">

This is similar to using SQL queries to join two tables with a one-to-many relationship. Unlike SQL, if you select an asset with two notes and three responsibilities, the asset would use three lines of the Excel table, not six, and the third row in the note column would be empty.&#x20;

JSON format, on the other hand, does not add duplicate rows to the results. Instead, it returns the first note found and discards the other notes.

{% tabs %}
{% tab title="Example" icon="glasses-round" %}
"First note" is missing for "Business Asset 1"

```json
{
    "iTotalDisplayRecords": 3,
    "iTotalRecords": 3,
    "aaData": [
        {
            "assetId": "c20d5b39-6c5d-411b-adcb-82a1dd3851cc",
            "assetName": "Business Term 1",
            "note": "Second Note"
        },
        {
            "assetId": "1a6a8f73-43b0-4a29-84c3-baaa3467be70",
            "assetName": "Business Term 2",
            "note": "Single note on BT2"
        },
        {
            "assetId": "7329349e-0631-41a7-a740-738979d887c6",
            "assetName": "Business Term 3",
            "note": "Single Note on BT3"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

For tabular formats that do not duplicate rows, you can add the `Group` mapping construct to the `Columns` section.

{% tabs %}
{% tab title="JSON" %}

```json
{
  "TableViewConfig": {
    "Resources": {
      "Asset": {
        "Id": { "name": "assetId" },
        "Signifier": { "name": "assetName" },
        "StringAttribute": {
          "LongExpression": { "name": "note" },
          "CreatedOn": { "name": "noteCreatedOn" },
          "Order": [ { "Field": { "name": "noteCreatedOn", "order": "DESC" } } ]
        },
        "Domain": {
          "Id": { "name": "domainId" }
        },
        "Filter": { "Field": { "name": "domainId", "operator": "EQUALS", "value": "f342423f-54fd-4643-935b-adbd9e7f5e25" } },
        "Order": [ { "Field": { "name": "assetName" } } ]
      }
    },
    "Columns": [
      { "Column": { "fieldName": "assetId" } },
      { "Column": { "fieldName": "assetName" } },
      {
        "Group": {
          "name": "Notes",
          "Columns": [
            { "Column": { "fieldName": "note" } }
          ]
        }
      }
    ]
  }
}
```

{% endtab %}

{% tab title="YAML" %}

```yaml
---
TableViewConfig:
  Resources:
    Asset:
      Id:
        name: "assetId"
      Signifier:
        name: "assetName"
      StringAttribute:
        LongExpression:
          name: "note"
        CreatedOn:
          name: "noteCreatedOn"
        Order:
        -
          Field:
            name: "noteCreatedOn"
            order: "DESC"
      Domian:
        Id:
          name: "domainId"
      Filter:
        Field:
          name: "domainId"
          operator: "EQUALS"
          value: "f342423f-54fd-4643-935b-adbd9e7f5e25"
      Order:
      -
        Field:
          name: "assetName"
  Columns:
  -
    Column:
      fieldName: "assetId"
  -
    Column:
      fieldName: "assetName"
  -
    Group:
      name: "Notes"
      Columns:
      -
        Column:
          fieldName: "note"
```

{% endtab %}
{% endtabs %}

A `Group` mapping allows grouping multiple results for a single parent. A `Group` must receive a user-defined name that will be used when formatting the results.

```json
{
    "iTotalDisplayRecords": 3,
    "iTotalRecords": 3,
    "aaData": [
        {
            "assetId": "c20d5b39-6c5d-411b-adcb-82a1dd3851cc",
            "assetName": "Business Term 1",
            "Notes": [
                {
                    "note": "Second Note"
                },
                {
                    "note": "First note"
                }
            ]
        },
        {
            "assetId": "1a6a8f73-43b0-4a29-84c3-baaa3467be70",
            "assetName": "Business Term 2",
            "Notes": [
                {
                    "note": "Single note on BT2"
                }
            ]
        },
        {
            "assetId": "7329349e-0631-41a7-a740-738979d887c6",
            "assetName": "Business Term 3",
            "Notes": [
                {
                    "note": "Single Note on BT3"
                }
            ]
        }
    ]
}
```

{% hint style="info" %}
Here are some rules about `Group`:

* `Group` mappings cannot be nested, a `Group` defined within a `Group` is not supported.
* All columns within a group must be related to the same parent entity.
  {% endhint %}


---

# 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 dynamically by asking a question.

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

```
GET https://developer.collibra.com/api/guides/introduction/the-output-module-query-language/map-the-results-to-a-tabular-format/handling-to-many-results-in-a-tabular-format.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.
