Best Practice: Use Filter Line for Filtering Table, Chart and R Visualization

Learn how to filter a Table, a Chart or an R Visualization using a Filter Line widget SAP Analytics Cloud, analytics designer.

Prerequisites

  • You've already added a table and a chart widget to your canvas and placed them on top of each other.

  • To follow all functions of this sample use case, you've completed the exercise Best Practice: Switch between Chart and Table and can now enhance your analytic application.

Context

Instead of loading all the dimensions in your data set into a checkbox group or a dropdown widget, you select specific dimensions to load into a filter line. Unlike other data bound widgets (such as table or chart), R visualization can add multiple input data models. To support R visualization in filter line, one dropdown list is added to select the connected input data.

Procedure

  1. Click Start of the navigation path (Add...) Next navigation step FilterlineEnd of the navigation path and place this widget above your table.
  2. Change the name of the filter line to FilterLine. You do this on the Styling panel under Analytics Designer Properties or on the Layout panel under Start of the navigation pathCanvas Next navigation step FilterLine_1 Next navigation step  More Next navigation step RenameEnd of the navigation path.
  3. Select the filter line in your canvas and click Designer.
    1. Go to the Builder panel, and under source widget select Table.
    2. Under Dimension Selection click on Add Dimension and select Location, Product, Sales Manager and Store in the checklist.
  4. To enable the option to toggle between table and chart you need to click on the fx next to the table in the Layout and choose onResultChanged.
    1. Enter this script in the script editor:
      Sample Code
      console.log('OnResultChanged');
      Chart.getDataSource().copyDimensionFilterFrom(
      Table.getDataSource(), "Location_4nm2e04531");
      Chart.getDataSource().copyDimensionFilterFrom(
      Table.getDataSource(), "Product_3e315003an");
      Chart.getDataSource().copyDimensionFilterFrom(
      Table.getDataSource(),
      "Sales_Manager__5w3m5d06b5");
      Chart.getDataSource().copyDimensionFilterFrom(
      Table.getDataSource(),
      "Store_3z2g5g06m4.Store_GEOID");
      
       

      This script makes that the filter you chose stay the same while toggling between table and chart. It is copied four times, one for each of the dimensions added in the filter line.

  5. Save the application and click Run Analytic Application.

Results

When you run the application it looks like this:

When you click on the filter line the 4 measures you added appear.

By clicking on one of the measures (in this example Location) a window pops up and lets you choose which members of that measure (in this example San Francisco, Las Vegas, and Portland) you want to include in the table or chart.

Table and chart will be updated and you can switch between them by using the table and chart images as in the best practice chapter before.