Best Practices for Designing Business Rules
Poorly written rules have a major impact on all aspects of an application. Below are some best practices when designing your business rules. Following best practices recommendations can lead to significant performance benefits.
Follow these key design guidelines for business rules.
- Top 10 Best Practices for Rules
- Add Business Logic Using Calculations
- Build Aggregations
- Set the Point of View
- Build Detailed Calculations
- Calculation Manager Diagnostics
- Example Rule Issues and Solutions
Top 10 Best Practices for Rules
Follow these best practice recommendations when designing your business rules. These guidelines can lead to significant performance benefits because poorly written rules have a major impact on all aspects of an application.
-
Follow these guidelines for SET commands:
- At the top of the rule, do not use
SET CREATEBLOCKONEQ ON
orSET CREATENONMISSINGBLK ON
. - Do not use administrative type commands like this in end-user rules, as
this requires a restructure:
SET CLEARBLOCK EMPTY
. - Avoid or test rules using
SET CALCTASKDIMS
. (Oracle Essbase typically does this automatically.) - The Data Copy rule should include the following to prevent copying empty
blocks within the Fix statement:
SET COPYMISSINGBLOCK OFF
- At the top of the rule, do not use
-
Block Creation should be done using either Datacopy or Sparse Member assignment. The functions
@createblockoneq
and@createblock
should be used as a last resort inside a limited Fix statement. -
Avoid missing dimension references in a Fix statement (for example, in Data Copy Rule). This can waste processing time and increase contention and create unnecessary blocks for all levels of the missing dimensions.
-
Remove parallel calculation in business rules associated with forms. Calc Parallel or Fix Parallel should be used only with administrative/batch rules.
-
Do not create unnecessary zeros, as this leads to block and data explosion. Carefully review business logic and add necessary If conditions to check for zeros. Convert zeros to
#missing
. After this, a dense restructure is required to remove the blocks. -
Eliminate multiple passes on the same blocks; instead, set a proper outer fix and move in and out as necessary. Combine If statements instead of using and re-using If on the same intersections.
-
Avoid using cross-dimensional references on the left side of an equation. This has a performance impact.
-
Aggregate dimensions in order of creation of the most blocks to the least blocks in the script, for example, Agg (1st Most Blocks Dimension, 2nd Most Blocks Dimension, 3rd Most Blocks Dimension). Agg is faster than Calc Dim and is a preferred mechanism for aggregation. Aggregation using
@ancestors
in end user rules all the way to the top of the dimension can lead to block contention. -
Use run-time prompts instead of creating multiple rules with the same underlying logic. More rules means more maintenance.
-
Use templates for breaking down and reusing business logic. However, templates should not be fully functioning rules with Fix, EndFix. The rule combining various templates should have a proper outer Fix and move in and out of smaller pieces as necessary.
Add Business Logic Using Calculations
To incorporate your business logic into your application, you can build calculations using Calculation Manager. This lets you create, validate, deploy, and administer sophisticated calculations that solve business problems.
You typically create business rules and rulesets to:
-
Perform revenue modeling
-
Perform expense modeling
-
Calculate KPIs
-
Perform allocations
Calculation Manager includes these objects:
-
Rules: Contain components and templates
-
Components: Assist you in building rules
-
Rulesets: Contain rules that can be calculated simultaneously or sequentially
-
Templates: Include system templates that perform calculations and custom templates that can be designed by administrators
To learn more about creating calculations, see the guidelines in Designing with Calculation Manager for Oracle Enterprise Performance Management Cloud.
Build Aggregations
Aggregations roll up your application to summary-level members in the dimension, such as Entity or any other sparse dimension.
Calculation Manager includes templates to help you build aggregations. Here are some suggestions on how to use templates.
Set the Point of View
When the point of view is set, the rule will run only for the selected members. Using a runtime prompt for the dimensions allows users to specify member values for these dimensions when launching the rule. This way, users can launch the rule several times for different years, scenarios, and versions without having to modify the rule in Calculation Manager.
Typical settings:
-
Full dense aggregation: Complete this section if parent values in your dense dimensions are not set to dynamic calc. Typically this tab is left empty.
-
Full sparse aggregation: Select the sparse dimension that needs to be aggregated. The order of the selected dimensions is not relevant.
-
Partial dimension aggregation, Dense: Complete this section if parent values in your dense dimensions are not set to dynamic calc. Typically this tab is left empty.
-
Aggregate the data up to the local currency: No
-
Aggregate the missing values in the Database: Yes
Be careful when using this option with a Target Version where data is entered at the parent members and descendants will be #Missing.
-
Optimize the Calculation on Sparse dimension: Off
-
Select a value for the calculator cache: Default
-
Do you want to activate the debug mode for this wizard?: Debug Wizard On or Debug Wizard Off. Select Debug Wizard On if you want to see a script generated to display selections for some of the Design Time Prompts in this template.
Best practices:
-
Leverage runtime prompts for members such as Entity, Scenario, and Version. This allows your rule to be dynamic and run based on user input.
-
Typically, dense dimensions such as Account and Period don't need to be aggregated. If this is the case, you can set parent members to dynamic calc. However, if you have member formulas on dense dimensions and they are not set to dynamic calc, a Calc Dim rule is required.
Build Detailed Calculations
You use Calculation Manager to create, validate, deploy, and administer calculations that solve business problems.
There are three types of objects that can be calculated in Calculation Manager:
-
Rulesets: Contain rules that can be calculated simultaneously or sequentially
-
Rules: Contain components and templates
-
Components: Contain formula components, script components, condition components, range components, and fixed loop components
Best practices:
-
As a first step in building your rules, ensure that you understand the business logic and which entities or departments the rule applies to. For example, know the accounts that are involved in the rule.
-
Be sure you know the source and destination accounts.
-
After you fully understand the drivers of the calculation, use the proper object component or template to build the rule. The components and templates facilitate member selection to help deploy the rules.
-
Leveraging runtime prompts for members such as Entity, Scenario, and Version allows your rules to be dynamic and run based on user input.
Calculation Manager Diagnostics
Run errors and warnings before deploying rules. This provides helpful information, including:
- The number of passes through the database
- Any necessary warnings
- Information on the number of blocks and if dimensions are missing
- Any rules that need to be optimized
- If any of the components of the right side of the equation contain a zero, the derived member will be 0. Then after aggregation there are many 0’s.
- To address this, the rule should include an if statement such as the following.
This way, zeros will not be so significant in the application.
if ("Earned Premium"<>0)
Example Rule Issues and Solutions
Example 1: Rule that Makes Multiple Passes Through the Database
The following rule makes 10 passes through the database for years and period, currency, and accounts.
Example 2: Rule that Makes Only One Pass through the Database
The following rule makes just one pass through the database. This is a major reduction in the total affected cells.
Example 3: Rule that Copies and Creates Zeros
In this rule, if any of the components of the right side of the equation contain a 0,
the derived member will be 0. After aggregation, there will be many zeros. To
address this, the rule should include an if statement saying if ("Earned
Premium"<>0)
. This way zeros would will not be so significant
in the application.
Example 4: Removing Zeros from BSO Cubes
The following formula results in the original value, or, if 0, will change to #missing.
"DenseMbr" = "DenseMbr" * "DenseMbr"/"DenseMbr";
"SparseMbr" = "SparseMbr" * "SparseMbr"/"SparseMbr";
To address this, create a rule leveraging the formula. Use a sparse dimension that has the fewest members (such as Year, Scenario, or Version) because the calculation needs to be done for each member.
Fix(idescendants(Entity),@levmbrs(Accounts,0),@levmbrs(Period,0),@idescendants(Custom dimensions),
@levmbrs(Years,0),@levmbrs(Versions))
Actual=Actual*Actual/Actual;
Fix("Actual")
CLEARBLOCK EMPTY:
Endfix
Endfix
Remember to do a restructure afterward. Otherwise, the empty blocks will not be deleted.