Filters

Dashboards can have filters in the top action bar.

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

JSON representation
{
    // 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
}

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

JSON representation
{
    // 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,
}

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

{
    "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": ...
}

Last updated