> 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/output-module/the-output-module-query-language/add-filtering.md).

# Add filtering

To discard irrelevant responsibility results, use filtering.

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

```json
{
  "ViewConfig": {
    "Resources": {
      "Community": {
        "Id": { "name": "communityId" },
        "Name": { "name": "communityName" },
        "Responsibility": [
          {
            "Id": { "name": "userResponsibilityId" },
            "User": {
              "Id": { "name": "userId" },
              "FirstName": { "name": "firstName" },
              "LastName": { "name": "lastName" }
            },
            "Role": {
              "Signifier": { "name": "userRoleName" }
            },
            "Filter": { "Field": { "name": "userId", "operator": "NOT_NULL" } }
          },
          {
            "Id": { "name": "groupResponsibilityId" },
            "Group": {
              "Id": { "name": "groupId" },
              "GroupName": { "name": "groupName" }
            },
            "Role": {
              "Signifier": { "name": "groupRoleName" }
            },
            "Filter": { "Field": { "name": "groupId", "operator": "NOT_NULL" } }
          }
        ]
      }
    }
  }
}
```

{% endtab %}

{% tab title="YAML" %}

```yaml
---
ViewConfig:
  Resources:
    Community:
      Id:
        name: "communityId"
      Name:
        name: "communityName"
      Responsibility:
      -
        Id:
          name: "userResponsibilityId"
        User:
          Id:
            name: "userId"
          FirstName:
            name: "firstName"
          LastName:
            name: "lastName"
        Role:
          Signifier:
            name: "userRoleName"
        Filter:
          Field:
            name: "userId"
            operator: "NOT_NULL"
      -
        Id:
          name: "groupResponsibilityId"
        Group:
          Id:
            name: "groupId"
          GroupName:
            name: "groupName"
        Role:
          Signifier:
            name: "groupRoleName"
        Filter:
          Field:
            name: "groupId"
            operator: "NOT_NULL"
```

{% endtab %}
{% endtabs %}

`Filter` is a reserved key. The example above first includes a "`userId` is not null" filtering clause to show responsibilities with a related user. Then, select the related responsibilities again, this time only keeping those with a related group.

```json
{
  "view": {
    "Community0": [
      {
        "communityId": "c87f166e-041f-4bea-8ff7-c1ffbab2ceeb",
        "communityName": "First Community"
      },
      {
        "communityId": "12345678-0020-0000-0000-000000000000",
        "communityName": "Second Community",
        "Responsibility1": [
          {
            "userResponsibilityId": "0ecb2fff-d5de-43d0-be60-f7f201c10d41",
            "User2": [
              {
                "userId": "00000000-0000-0000-0000-000000900002",
                "firstName": "Admin",
                "lastName": "Istrator"
              }
            ],
            "Role3": [
              {
                "roleName": "Admin"
              }
            ]
          },
          {
            "userResponsibilityId": "42b9d114-2c0c-4e96-a1ce-b645d5e92365",
            "User2": [
              {
                "userId": "00000000-0000-0000-0000-000000900002",
                "firstName": "Admin",
                "lastName": "Istrator"
              }
            ],
            "Role3": [
              {
                "roleName": "Steward"
              }
            ]
          }
        ],
        "Responsibility4": [
          {
            "groupResponsibilityId": "5fc0cc5f-e30e-488c-94bc-acdea171219d",
            "Group5": [
              {
                "groupId": "4eb1f4a9-14a3-4539-8afc-733925161179",
                "groupName": "admin"
              }
            ],
            "Role6": [
              {
                "groupRoleName": "Admin"
              }
            ]
          }
        ]
      }
    ]
  }
}
```

{% hint style="info" %}
In the result tree, `Responsibility1` shows all related users and `Responsibility4` only contains the groups.
{% endhint %}
