Working with BEx conditions in SAP BusinessObjects Design Studio
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 given separately.
A very helpful and clear write-up indeed, Noel. It's probably worth noting that there may also be scenarios in which multiple conditions are required to be activated simultaneously when needed, which should be fine as long as they don't clash with each other (although there are rules of priority that are applied in such cases anyway).
Mustafa Bensan said everything. - It took me quite some time to find it though. Good one!
We have set a condition "Condition 1" in our planning BeX Query. It is a condition with constant value.
When I add the bex query in my Lumira 2.2 dashboard, we get an error message saying " Invalid terms in condition "Condition 1" have been removed". Why this error might be coming up and how to avoid this? Attaching screenshots for your reference.
Please help and thanks in advance.
as of your query screenshot, you already have an error within your query. Your Condition Description is showing the error sign behind the description.