> For the complete documentation index, see [llms.txt](https://developer.mediarithmics.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.mediarithmics.io/dashboards/filters.md).

# Filters

Dashboards can have filters in the top action bar.&#x20;

<figure><img src="https://4196284719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMuoqM-5hJ5JY0WnAKL%2Fuploads%2FHoK2WbUb2UGw8AbDtSAO%2Fimage.png?alt=media&amp;token=590069e0-4366-4acf-8f96-7efc72068a3e" alt=""><figcaption><p>Compartment and channel filter in the top action bar</p></figcaption></figure>

You can set up filters only in advanced mode using the `available_filters` property of your [DashboardContent](broken://spaces/-MVWpcWULC-ugQNay59s).

The user can select a value and all the queries in the dashboard adapt to the selected value.

{% code title="JSON representation" %}

```json5
{
    // Using technical names of compartments, segments or channels 
    // will result in IDs being automatically replaced by names in the UI
    "technical_name": String, 
    "title": String,
    "values_retrieve_method": 'Query', // Only available value at the moment
    // OTQL query to retrieve list of selectable values
    // Use a query string, not the ID of a query
    "values_query": String, 
    // How to adapt queries in the dashboard to the selected value(s)
    "query_fragments": [QueryFragment], 
    "multi_select": Boolean, // If the user can select multiple values
}
```

{% endcode %}

A query fragment tells the dashboard how to adapt each query to the value(s) selected by the user.

{% code title="JSON representation" %}

```json5
{
    // Any available data source such as 'activities_analytics' or 'OTQL'
    "type": String, 
    // Only for OTQL type, chooses which queries should be transformed
    // Select 'ActivityEvent' to transform queries FROM ActivityEvent
    "starting_object_type": String,
    // The query part to add 
    "fragment": String,
}
```

{% endcode %}

Here is a sample with a filter that enables the selection of compartments and an other for channels

```json5
{
    "available_filters": [
        {
            "values_retrieve_method": "query",
            "values_query": "SELECT {compartment_id @map} FROM UserProfile",
            "technical_name": "compartments",
            "query_fragments": [
                {
                    "type": "OTQL",
                    "starting_object_type": "UserPoint",
                    "fragment": "profiles {compartment_id IN $values}"
                },
                {
                    "type": "OTQL",
                    "starting_object_type": "UserProfile",
                    "fragment": "compartment_id IN $values"
                }
            ],
            "multi_select": true,
            "title": "Data provider"
        },
        {
            "values_retrieve_method": "query",
            "values_query": "SELECT {channel_id @map} FROM UserEvent",
            "technical_name": "channels",
            "query_fragments": [
                {
                    "type": "OTQL",
                    "starting_object_type": "UserPoint",
                    "fragment": "events {channel_id IN $values}"
                },
                {
                    "type": "OTQL",
                    "starting_object_type": "UserEvent",
                    "fragment": "channel_id IN $values"
                },
                 {
                    "type": "activities_analytics",
                    "fragment": [
                        {
                            "dimension_name": "channel_id",
                            "operator": "IN_LIST",
                            "not": false,
                            "expressions": "$values"
                        }
                    ]
                }
            ],
            "multi_select": true,
            "title": "Channels"
        }
    ],
    "sections": ...
}
```


---

# 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://developer.mediarithmics.io/dashboards/filters.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.
