Exclude data of table based on the selection made in another table

Estimated read time 4 min read

Problem statement:

To display the Inverse of the data from first table in second table.

Solution:

This can be achieved via scripting by using getDataSelections() along with setDimensionFilter() and a property called exclude. This setting will let us display the excluded data made from the selection from table 1 in table 2.

Table 2 showing the inverse of data selected in table 1

Logic:

Step 1:

Create 2 table widgets in the SAC story. I am using the SAP sample dataset for this demo BestRunJuice_SampleModel.

Step 2:

Create necessary Page level filters (Input Controls) for affecting table 1 alone.
I have created 4 Input controls. (Sales manager, Date, Product and Store).

Step 3:

Apply linked Analysis to all 4 input controls by linking table 1 alone.

Step 4:

In the onResultChanged() event of table 1 create the following script.

The idea is to create an array of selection for capturing the data selections from Table 1 and to iterate the elements from the array of selection into an array of string. Then we need to set a dimension filter to selectively filter the table 2 based on the exclusion of members from the initial selection.

 

//getting the selection into an array of selection
var arr_table_selection = Tab1.getDataSource().getDataSelections();
var arr_value=ArrayUtils.create(Type.string);

//push elements from array of selection into an array of string
for(var i=0;i<arr_table_selection.length;i++)
{
arr_value.push(arr_table_selection[i][“Sales_Manager__5w3m5d06b5”]);
}

// Apply Exclusion to Table 2
Tab2.getDataSource().setDimensionFilter(“Sales_Manager__5w3m5d06b5”, {values: arr_value, exclude: true});

 

This script will be called every time there is a change to the result of table1. For example: any time you make a change to the table 1 with the input filters, the inverse of the available members shown in table1 will be displayed in Table 2.

Since I have selected Sales Manager as the dimension filter. This exclusion logic will be shown on the basis of Sales manager.

Refer the below documentation on how to better use the SetDimensionFilter on different parameters.

Use setDimensionFilter API on Range and Exclude Filters | SAP Help Portal

 

​ Problem statement:To display the Inverse of the data from first table in second table.Solution:This can be achieved via scripting by using getDataSelections() along with setDimensionFilter() and a property called exclude. This setting will let us display the excluded data made from the selection from table 1 in table 2.Table 2 showing the inverse of data selected in table 1Logic:Step 1:Create 2 table widgets in the SAC story. I am using the SAP sample dataset for this demo BestRunJuice_SampleModel.Step 2:Create necessary Page level filters (Input Controls) for affecting table 1 alone.I have created 4 Input controls. (Sales manager, Date, Product and Store).Step 3:Apply linked Analysis to all 4 input controls by linking table 1 alone.Step 4:In the onResultChanged() event of table 1 create the following script.The idea is to create an array of selection for capturing the data selections from Table 1 and to iterate the elements from the array of selection into an array of string. Then we need to set a dimension filter to selectively filter the table 2 based on the exclusion of members from the initial selection. //getting the selection into an array of selection
var arr_table_selection = Tab1.getDataSource().getDataSelections();
var arr_value=ArrayUtils.create(Type.string);

//push elements from array of selection into an array of string
for(var i=0;i<arr_table_selection.length;i++)
{
arr_value.push(arr_table_selection[i][“Sales_Manager__5w3m5d06b5”]);
}

// Apply Exclusion to Table 2
Tab2.getDataSource().setDimensionFilter(“Sales_Manager__5w3m5d06b5”, {values: arr_value, exclude: true}); This script will be called every time there is a change to the result of table1. For example: any time you make a change to the table 1 with the input filters, the inverse of the available members shown in table1 will be displayed in Table 2.Since I have selected Sales Manager as the dimension filter. This exclusion logic will be shown on the basis of Sales manager.Refer the below documentation on how to better use the SetDimensionFilter on different parameters.Use setDimensionFilter API on Range and Exclude Filters | SAP Help Portal   Read More Technology Blogs by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author