Filtering table data based on dynamic checkbox values of dimension members is a useful feature that can help you streamline your analysis and make better decisions. In this tutorial, we will demonstrate how to apply this feature to filter table data by country values SAP Analytics Cloud.
Step 1: Select Your Planning Model
First, select your Planning model from the left side bar, and select your model
Step 2: Create a Table for Your App
Create a table for your app using the "Table" component in the Canvas designer.
Step 3: Create a Fresh Blank Checkbox
Create a fresh blank checkbox using the "Checkbox" component in the Canvas designer.
Step 4: Initialize the Checkbox Values
Go to the "Canvas" menu and select "onInitialization()". Add the following code to initialize the checkbox values:
var country_list = PlanningModel_1.getMembers("Country");
CheckboxGroup_1.removeAllItems();
for(var i =0;i<country_list.length;i++){
CheckboxGroup_1.addItem(country_list[i].id, country_list[i].description);
}
This code retrieves all the country values from the "Country" dimension and adds them to the checkbox group.
Step 5: Create an Input Field to Search
Create an input field for the user to search for the desired country value. Add the following code to the "onChange()" method of the input field:
var country_list = PlanningModel_1.getMembers("Country");
CheckboxGroup_1.removeAllItems();
for (var i = 0; i < country_list.length; i++) {
CheckboxGroup_1.addItem(country_list[i].id, country_list[i].description);
}
This code retrieves the search text entered by the user and filters the checkbox values based on the text input.
Step 6: Apply the Filter to the Table Data
Finally, add the following code to the "onSelect()" method of the checkbox:
Table_1.getDataSource().setDimensionFilter("Country",this.getSelectedKeys());
This code retrieves the selected country values from the checkbox and applies the filter to the table data based on the "Country" dimension.
In conclusion, by following these simple steps, you can create a dynamic checkbox filter to efficiently filter your table data by dimension member values. This feature can be applied to any dimension and is a powerful tool to enhance your analysis.