Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

We often get requests for dashboard requirements like switching the conditions of particular views such as TOP N , Bottom N , Less than X , Top % etc. Readers may recall that this was also recently asked in one of the SCN posts.In this blog, I am going to explain simple steps that will have great impact in performance of the application by reducing the number of Queries used.


Conditions in BEx

We generally define condition to show only a part of the entire dataset that satisfies the specified condition. There are different types of conditions in SAP BusinessObjects Design Studio.

You can learn more about Conditions in BEX here- Definition of condition , uses and example scenarios

.

Our Scenario  – Sales Dashboard

Let us consider a Sales dashboard that consists of list of customers and the revenue generated by them.  Sales Executives are typically interested in looking into their customers as different segments.  For instance, they would want to view them  as Top N customers, Bottom N customers, Top N% Customers, Bottom N% Customers, Customers for whom the revenue is Greater Than X,  and Customers for whom the revenue is Lesser Than X.

How this is generally done?

  • Create 6 Queries (one for each condition)
  • Add an input variable to the condition in all Query
  • Add all the queries to SAP BusinessObjects Design Studio and map it to the desired component like chart/crosstab
  • Provide an option to specify the condition like radio button or dropdown
  • Provide an option to get the input with a suitable component like input field or dropdown.

How this can be done effectively?

Although the above method solves the purpose, it is highly inefficient since it utilizes multiple queries. With the release of SAP BusinessObjects Design Studio 1.4, there is a way to deliver this requirement more easily and effective using only one query.

Here’s how:

Step 1

Create a Query in SAP Business Explorer (BEx) with the required dimensions in rows and columns.

Step 2

Create a condition for the keyfigure with an input variable –

Click on Condition Tab -> Right Click ->New Condition

Add a Description as Top N, then click on New button to define the condition in which you will be prompted to add the keyfigure, operator and the value for the condition.

After selecting the necessary keyfigure and operator, click on the icon adjacent to the ‘values’ input box to add input variable as a value. Now you can use an existing input variable or create a new one.

Step 3

Create an input Variable and provide a suitable Description and Technical Name for the variable. In the Global Setting section, select the option Manual Input / Default Value under Processing By option.

To set a value as default click on Default Values Tab and select a value for the variable.

Similarly follow Step 2 and 3 to create all other conditions.

Once all six conditions are created, activate the condition only for TOP N and deactivate all other conditions.

Step 4

Add this Query as a Data source and assign it to a chart in your SAP BusinessObjects Design Studio application.

Add a radio button as selector for switching the conditions.

Add an input field to specify the value to be passed to the input variable and an Apply Button to pass the value to the query and fetch the data that matches the selected condition.

Step 5

Give the following script in Apply Button:

/*Get all the ids of contions used in the Query */
var contion_ids=DS_1.getMeasureFilters();

/*Use a for Each Loop to dynammically activate and Deactivate the selected conditions */
contion_ids.forEach(function(element, index) {

/*if the index (order of the condtion) is equal to the getselectedvalue of the radiobutton Then activate the condtion */
if(RADIOBUTTONGROUP_1.getSelectedValue()==index+””)
{
DS_1.setMeasureFilterActive(element, true);
}
/*Deactiate all other condtions */
else
{
DS_1.setMeasureFilterActive(element, false);
}
});

/*Pass the value specified in the inputfield to the variable */
DS_1.setVariableValueExt(“ZVAR_INPUT_N”, INPUTFIELD_1.getValue());

Explanation

If the condition selected is Bottom N, then RadioButton.getselectedValue() will be 1.

For the first iteration, the condtion_id array will have index=0; the loop ignores the ‘if’ section and executes the ‘else’ section, thereby making Top N condition inactive.

For the second iteration, the condtion_id array will have index=1; so ‘if’ part gets executed, the Bottom N condition is made active.

From the next iterations, ‘else’ part is executed; all other the conditions are made inactive.

I hope this blog has helped you in understanding the powerful APIs of Datasource alias getMeasurefilterids() and  setMeasurefilter (id,activate/deactivate).

Through these easy steps, you will be able to use multiple conditions in single Query and activate them on demand from SAP BusinessObjects Design Studio. This method will have great impact on the performance of the application.

Labels in this area