Filtering widgets based on two user defined years via dropdown control

Estimated read time 3 min read

Hi SAP community!

I’d like to present a solution for a scenario which was necessary in my project. The customer wanted to see the comparison of data based on the two selected years provided as input in the dropdown. Though the same filtering can be achieved with a regular page/story filter, this solution was provided especially to cater the exact needs of the customer.

Problem Statement:

The user wants to input a primary year and a comparison year in two separate dropdowns. Based on the year selected, the comparison of data should take place in all the widgets of that page.

Solution:

In order to handle the requirement, I have created a simple solution with the help of 2 dropdowns, 2 variables, a button and a little bit of scripting.

comparison of data between the user selected years

 Let me walk you through the step-by-step process.

Step 1: Create 2 dropdowns with DataSource type as Script variables

Creation of dropdowns

 

Step 2: Populate the Dropdown with the Dimension members through script

 

 

 

 

 

 

 

 

 

var resultSet = Table_2.getDataSource().getMembers(“95209621-0288-4526-3125-344972696735”); //Replace with your required Dimension

//populating the dropdown
for ( var i = 0; i< resultSet.length; i++ ){
Dropdown_1.addItem(resultSet[i].id,resultSet[i].description);
Dropdown_2.addItem(resultSet[i].id,resultSet[i].description);
}

 Step 3: Create 2 variables to store the user input

 Step 4: Capture the dropdown input

This will store the user input to the variable whenever the user selects a year in the dropdown

Step 5: Create button and Setdimensionfilter() to perform the comparison

Perform set dimension filter to restrict only the two user inputted years

Step 6: Check in runtime

Select the year in dropdown and click button to compare

 Hope this article was helpful.😊

 

 

 

​ Hi SAP community!I’d like to present a solution for a scenario which was necessary in my project. The customer wanted to see the comparison of data based on the two selected years provided as input in the dropdown. Though the same filtering can be achieved with a regular page/story filter, this solution was provided especially to cater the exact needs of the customer.Problem Statement:The user wants to input a primary year and a comparison year in two separate dropdowns. Based on the year selected, the comparison of data should take place in all the widgets of that page.Solution:In order to handle the requirement, I have created a simple solution with the help of 2 dropdowns, 2 variables, a button and a little bit of scripting.comparison of data between the user selected years Let me walk you through the step-by-step process.Step 1: Create 2 dropdowns with DataSource type as Script variablesCreation of dropdowns Step 2: Populate the Dropdown with the Dimension members through script         var resultSet = Table_2.getDataSource().getMembers(“95209621-0288-4526-3125-344972696735”); //Replace with your required Dimension

//populating the dropdown
for ( var i = 0; i< resultSet.length; i++ ){
Dropdown_1.addItem(resultSet[i].id,resultSet[i].description);
Dropdown_2.addItem(resultSet[i].id,resultSet[i].description);
} Step 3: Create 2 variables to store the user input Step 4: Capture the dropdown inputThis will store the user input to the variable whenever the user selects a year in the dropdownStep 5: Create button and Setdimensionfilter() to perform the comparisonPerform set dimension filter to restrict only the two user inputted yearsStep 6: Check in runtimeSelect the year in dropdown and click button to compare Hope this article was helpful.😊     Read More Technology Blogs by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author