[Last updated: 12th of April 2019, SAP Analytics Cloud Version 2019.7]

In the previous blog in this series, we learnt about Scripting APIs. In this blog, let us start with an interesting & custom implementation of Linked Analysis using scripting.

* * *

Linked Analysis

Linked Analysis enables SAP Analytics Cloud story widgets to dynamically interact with each other based on items selected in a widget. This feature is not enabled by default in Analytic Applications, where it must be implemented using scripting.

However, there is one upside to this: we can implement Linked Analysis the way we want in Analytic Applications. Note that the out-of-the-box Linked Analysis functionality provided for stories cannot do complex interactions, and it cannot be customized.

Our goal today is to achieve the chart interaction as shown below (as a side exercise, try to implement this in an SAP Analytics Cloud story, and figure out why it cannot be done).

SAP Analytics Cloud - Application Design Series: 9 - Linked Analysis using Scripting

Linked Analysis In Analytic Applications – An Example

There are three charts – Sales by Region, Sales by Category & Sales by Sub-Category.

  • Any selection in chart 1 (Region) must filter values in chart 2 & 3 (Category & Sub-Category).
  • Any Selection in chart 2 (Category) must only filter values in chart 3 (Sub-Category), without setting any filters for chart 1 (Region).


Following are the steps involved to implement custom Linked Analysis in Analytic Applications:

1. Create the widgets

Here we start with the analytic application shown below, which does not have any implementation yet for Linked Analysis or filtering.



2. Filter for Region Selection

Add the following script to the onSelect() event of the first chart. This adds the selected region as a filter to the Category & Sub-Category charts.

var region_sel = Chart_Region.getSelections();

if(region_sel.length > 0){

            var region_members = ArrayUtils.create(Type.string);

            for ( var i=0; i < region_sel.length; i++ ) {

                        for(var dimension in region_sel[i]){

                                    if ( dimension === “Region” ) {

                                                region_members[i] =  region_sel[i][dimension];




            Chart_Category.getDataSource().setDimensionFilter ( “Region”, region_members );

            Chart_SubCategory.getDataSource().setDimensionFilter ( “Region”, region_members );




3. Filter for Category Selection

Add the following script to the onSelect() event of the second chart to filter category in the third chart.

var category_sel = Chart_Category.getSelections();

if(category_sel.length > 0){

            var category_members = ArrayUtils.create(Type.string);

            for ( var i=0; i < category_sel.length; i++ ) {

                        for(var dimension in category_sel[i]){

                                    if ( dimension === “Category” ) {

                                                category_members[i] =  category_sel[i][dimension];




            Chart_SubCategory.getDataSource().setDimensionFilter ( “Category”, category_members );




Note that in this implementation, no filter is set for the first chart (Region). This flexibility allows us to implement Linked Analysis the way we want in Analytic Applications.


4. Add the Reset functionality

To help the user clear all the filters, add a button ‘Reset Filters’ on the top right.



Then in the onSelect() event of the button add the following script to clear the filter values.






* * *

In the subsequent blog, we will learn about Dynamically changing Measures and Dimensions in Analytic Application.

Reach out to our team here if you are interested in evaluating if SAP Analytics Cloud is right for you.

Subscribe to our Newsletter

5920 Windhaven Pkwy
Plano TX 75093.

+1 888-227-2794

+1 972-232-2233

+1 888-227-7192