When there is a need to implement conditions or set filters on key figures in SAP BusinessObjects Design Studio dashboards, it becomes a challenge to achieve this directly in the application. To implement this functionality in our SAP BusinessObjects Design Studio dashboards, we require the help of SAP Business Explorer (BEx). Setting filters on Key Figures can be achieved by defining Conditions in SAP Business Explorer (BEx).
This blog post gives an insight into manipulation of SAP Business Explorer (BEx) conditions in SAP BusinessObjects Design studio.
Two types of conditions in SAP Business Explorer (BEx) are:-
i) Conditions with variables
ii) Conditions with constant values
Conditions with variable
In this case, the condition works on the input value of the variable.
To toggle the state of a condition, we can pass null value to its variable. When null value is passed, the condition is temporarily inactive. So we can pass the values for the required condition variable and pass null value to rest of the variables.
//To set the value of the condition variable in BEx with null
Conditions without variable
In this case, we cannot pass a value to the condition in runtime i.e. from SAP BusinessObjects Design Studio.
So if we have more than one condition, we can use a variable to get all the conditions defined in the Query as an array, and set the state of the condition in SAP BusinessObjects Design Studio as active or inactive.
//Storing all the conditions on the data source to a variable
var condition = DS_1.getMeasureFilters();
//Setting the required condition as active
In the above example only the condition with name CONDITION1 is active and all other conditions are inactive.
*This approach can also be used in conditions with variables if necessary.
Consider a scenario when Top N and Bottom N are to be reported.
We can define 2 conditions; one for Top N and other for Bottom N in the same query. And in SAP BusinessObjects Design Studio, we can toggle the condition states to display the Top N and Bottom N as and when required.
To Display Top N use the following script:
To Display Bottom N use the following script:
This eliminates the need of 2 data sources with each of the conditions give separately.