Adding Dependent Filters in Platform Analytics Dashboard

vidhya_mouli
Tera Sage

How can I create a filter whose value is based on an other filter. I want Subcategory to be based on Category for Incident table. 

 

I already saw this video, but this will not help because the categories and subcategories are string field and not choice field.

Brief overview of adding multiple filters into a ServiceNow Platform Analytics Dashboard and adding dependency so one filter will limit the available selection of the second filter.
1 ACCEPTED SOLUTION

jeffrubinoff
ServiceNow Employee

You can filter only by Choice or Reference (Selection filters), Boolean, or Date, as per the documentation.
Selection filters also support String fields beginning in Australia.

View solution in original post

3 REPLIES 3

jeffrubinoff
ServiceNow Employee

You can filter only by Choice or Reference (Selection filters), Boolean, or Date, as per the documentation.
Selection filters also support String fields beginning in Australia.

Thank you. Will try this after Australia release. 

@vidhya_mouli  officially it's a feature gap compared to Interactive Filters in how Responsive Dashboards had it available, and what will be made available in the Australia release will most likely _not_ fix it (somebody update us here if there will be good news verifying and demonstrating that it actually does). And - even if you have fields configured in the Dictionary of type Choice, that doesn't make the In-line Editor more friendly in letting you select or choose the configurations you need. It wants relational data and reference fields. 

But - there are many ways to solve it and it works fine in Platform Analytics even with OOTB fields being String as well - and easiest approach by far, to solve it, is to just forcefully configure it.

Other ways (just to mention a few) could be setting up an Advanced Dashboard (which means using UI Builder) with a Custom Data Broker and scripts there, or a more replicating the data into a proper relational model (which means you would also want to add enough logic around it to auto-sync), or creating a new filter component (cloning the existing Filter component) and make some adjustments so that it allows configurations like Interactive Filters previously did via the UI.

The clue is to look at the underlying data of the PAR Dashboard Widget, and its Component Properties. 

To spare you the pain of exploring and implementing the other options, or waiting in vain for Australia, you can do this: 


1. Find your Filter Macroponents records in the [par_dashboard_widget] table, which are used in your PAR dashboard. Fastest way to do this would be to just make a configuration on the filter and save it, and sort by Updated. You will find the filterName key's value being the Label you set on it. 

2. Configure the records like this:

Category:

{
    "filterId": "<CATEGORY_FILTER_ID>",
    "filterName": "Category",
    "filterComponentType": "singleselect",
    "datasource": {
        "type": "table",
        "payload": {
            "table": "sys_choice",
            "primaryKey": "value"
        },
        "encodedQuery": "name=incident^element=category^inactive=false"
    },
    "targets": [
        {
            "type": "table",
            "payload": {
                "field": "dependent_value",
                "table": "sys_choice",
                "primaryKey": "value"
            }
        },
        {
            "type": "table",
            "payload": {
                "table": "incident",
                "primaryKey": "category"
            }
        }
    ],
    "defaultSelectedItems": {},
    "defaultSelectedDateRange": {
        "range": ""
    },
    "dateFilterView": "calendar-reldates",
    "sort": "ASC",
    "filterElementType": "pill",
    "isShowSelectedValueInPill": true,
    "filterElementLayout": "vertical",
    "enableClearFilter": true,
    "primaryActionLabel": "Apply",
    "maxElements": 500,
    "filterConfigurations": "@state.parFilters",
    "cascadeScope": "<KEEP_SYS_ID_AS_IS>",
    "isDashboard": true,
    "isGroup": false,
    "value": {}
}


Subcategory:

{
    "filterId": "<SUBCATEGORY_FILTER_ID>",
    "filterName": "Subcategory",
    "filterComponentType": "singleselect",
    "datasource": {
        "type": "table",
        "payload": {
            "table": "sys_choice",
            "primaryKey": "value"
        },
        "encodedQuery": "name=incident^element=subcategory^inactive=false"
    },
    "targets": [
        {
            "type": "table",
            "payload": {
                "table": "incident",
                "primaryKey": "subcategory"
            }
        }
    ],
    "defaultSelectedItems": [],
    "defaultSelectedDateRange": {
        "range": ""
    },
    "dateFilterView": "calendar-reldates",
    "sort": "ASC",
    "filterElementType": "pill",
    "isShowSelectedValueInPill": true,
    "filterElementLayout": "vertical",
    "enableClearFilter": true,
    "primaryActionLabel": "Apply",
    "maxElements": 500,
    "filterConfigurations": "@state.parFilters",
    "cascadeScope": "<KEEP_SYS_ID_AS_IS>",
    "isDashboard": true,
    "isGroup": false,
    "value": [],
    "cascadingConfig": {
        "filtersFollowing": [
            "<CATEGORY_FILTER_ID>"
        ]
    }
}


Note that the important parts of the config is the cascadingConfig, and the datasource and targets.

3. Validate that it works and give me a Helpful on this response and mark it as the answer.