# Filters

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

<figure><img src="/files/Cyt4r5xrnGIqCrcRNeQa" 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: 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.mediarithmics.io/dashboards/filters.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.
