Making the Cube Actually Calculate

 

Forms Were Only Half the Story

In Blog #7 we built data forms and dashboards for NEXUSFPA. Planners could open FPAOPX_Form_001, key their opex numbers, and hit save. Job done, right?

Not quite. Because the moment a planner saves a number, somebody expects something to happen. The department total should update. The EBITDA line on the review form should move. The allocation from corporate should redistribute. The variance column should recalculate. None of that happens by itself.

This is what business rules do. A form is where data goes in. A business rule is what makes the cube mean something afterwards. And in my experience this is the single area where EPM projects either feel fast and responsive, or feel like garden snail (too slow to move).

I will say something slightly unpopular up front. Most performance complaints I have been called in to fix were not Essbase problems. They were badly scoped calculation problems. Someone wrote a rule that aggregates the entire cube when it only needed to aggregate one cost centre, attached it to On Save, and then wondered why saving a single cell takes forty seconds.

NOTE: This blog assumes you are comfortable with dimensions, sparse/dense (Blog #3), member hierarchies (Blog #6) and forms (Blog #7). Calculation is where all three of those come together, so if any of them feel shaky, go back to the respective blogs first. Calc performance is mostly a consequence of your outline design, not of your calc syntax.

What Is a Business Rule?

A business rule is a set of instructions that tells the cube to calculate something. In Oracle EPM Cloud you build and manage these in Calculation Manager, which you reach from the Navigator menu under Create and Manage, or from Rules on the home page depending on which navigation flow you are in.

Calculation Manager holds four object types, and beginners routinely mix them up:

Object

What It Is

When You Use It

NEXUSFPA Example

Rule

A single executable calculation. The workhorse object.

Almost always. This is your default.

FPAOPX_031 - allocate BAU costs to FPAPLN

Ruleset

An ordered container that runs several rules in sequence.

When a business process needs multiple rules in a guaranteed order.

FPAOPX_RS_MonthEnd - runs 211, 215 and 251 in that order

Template

A reusable, parameterised calculation block.

When the same logic repeats across many rules and you are tired of copy-paste.

A trend template reused across opex line items

Formula Component

A named fragment of logic used inside graphical rules.

Rarely, in my view. Adds indirection without much payoff.

Not used in NEXUSFPA

 

Graphical vs Script Mode

Every rule can be authored two ways. Graphical mode gives you a flow diagram where you drag components to a canvas. Script mode gives you a text editor where you write the calculation directly.

Note: You can switch an existing graphical rule to script mode to see the script it generates. This is genuinely one of the better ways to learn calc syntax - build it graphically, then read what came out the other end.

Anatomy of a Calculation

Let us look at a real, if simplified, calculation. This is the shape of the opex trend calc in FPAOPX - it takes prior year actuals and applies a growth percentage to produce the plan for the remaining months:

SET UPDATECALC OFF;

SET AGGMISSG ON;

 FIX (@RELATIVE("Total Cost Centre", 0),

     "NexusFood_SG",

     &PlanYear,

     @RELATIVE("YearTotal",0),

     "AOP")

   FIX (@RELATIVE("Total Opex", 0))

    "Working" (

      "Plan_Amount" = "Actual_Amount”->”Actual”->&PriorYr * (1 + "Growth_Pct"->”BegBalance”);

    )

  ENDFIX

ENDFIX

AGG("Cost Centre", "Account");

Small block, but almost everything that matters is in there. Let us take it apart.

FIX / ENDFIX - The Most Important Two Words

FIX restricts the calculation to a slice of the cube. Everything between FIX and ENDFIX runs only against the members you named. Everything outside that slice is left alone.

This is the single biggest performance lever you have. A calculation without a FIX runs against every block in the cube. In FPAOPX that is the difference between a rule finishing in four seconds and a rule finishing in six minutes. Same logic, same result, wildly different runtime.

Notice what is in that FIX: the cost centres being calculated, the entity, the year, the version, the scenario. Sparse dimensions, mostly. That is deliberate - see the performance section below.

The Cross-Dimensional Operator

You will see the arrow syntax constantly. It means "the value at the intersection of these members":

"Plan_Amount" = "Actual_Amount"->"FY24"->"Actual";

Read it right to left as an address. The value of Actual_Amount, at year FY24, at Actual Scenario. Any dimension you do not name is inherited from the current calculation context.

AGG vs CALC DIM

Both aggregate data up hierarchies, and beginners use them interchangeably. They are not the same:

 

AGG

CALC DIM

What it does

Aggregates sparse dimensions using the outline consolidation operators

Calculates a dimension including any member formulas on it

Member formulas

Ignores them

Executes them

Typical use

Rolling up sparse dimensions like Cost Centre, Entity

Dense dimensions, or any dimension carrying formulas

Speed

Generally faster for pure sparse aggregation

Slower, because it evaluates formulas

 

Note -: If your account dimension carries member formulas and you use AGG on it, those formulas will not fire and your totals will look wrong in a way that is genuinely hard to spot. The numbers are not blank, they are just stale. Use CALC DIM where formulas exist.

SET Commands

The SET commands at the top of the script tune how the calculation behaves. The ones actually worth knowing:

Command

What It Does

Why It Matters

SET UPDATECALC OFF

Disables intelligent calculation

Intelligent calc skips blocks it thinks are already clean, and it is frequently wrong about that. Turning it off is standard practice on almost every project I have worked on.

SET AGGMISSG ON

Aggregates #Missing values instead of skipping them

Without it, a parent can retain an old value after its children are cleared. This causes the classic 'I deleted the data but the total is still there' support ticket.

SET CREATENONMISSINGBLK ON

Creates blocks even where the result is #Missing

Needed when writing to intersections that do not yet exist. Use it sparingly - it can inflate the cube badly.

SET EMPTYMEMBERSETS ON

Skips a FIX whose member set resolves to nothing

Prevents a rule failing outright when a filter returns no members. Useful in Groovy-driven dynamic FIX blocks.

SET FRMLBOTTOMUP

Optimizes the calculation of complex formulas on sparse dimensions in large database outlines

Tells Essbase to perform a bottom-up calculation on formulas that would otherwise require a top-down calculation.

Where and How Rules Get Triggered

Writing the rule is half the job. Deciding when it runs is the other half, and this is where user experience is won or lost.

Trigger

How It Works

Good For

Watch Out For

On Save

Runs automatically after the planner saves the form

Small, tightly scoped calcs the planner needs to see immediately

Every second here is felt by the user. Keep it under a few seconds.

On Load

Runs when the form opens

Preparing driver values or seeding defaults

Slows form open. Use rarely.

On Demand

Planner launches it from the Rules card or the form's action menu

Heavier calculations the user consciously chooses to run

Users forget to run it. Put it in the task list.

Job Scheduler

Runs on a schedule, unattended

Full aggregations, nightly rollups, dashboard prep

Failures are silent unless somebody watches the job console.

EPM Automate

Triggered externally by script

Orchestration around data loads and integrations

Needs credential management and error handling.

Smart Push

Moves data to another cube after save

Keeping a reporting cube current

Can be slow if the push grid is wide. Scope it.

In NEXUSFPA we settled on a split that has held up well. FPAOPX_211, which calculates opex out-months for the cost centre on the form, runs On Save because the planner needs to see the effect immediately and it is scoped tightly enough to finish quickly. FPAOPX_031, which allocates BAU costs across to FPAPLN using prior year actuals as the allocation key, runs On Demand - it touches far too much of the cube to sit on a save action.

Note -: A rule attached to On Save should be scoped to what the planner just changed - their cost centre, their entity, their year. Not the whole cube. If you cannot scope it that tightly, it does not belong on On Save.

Runtime Prompts and Variables

Hardcoding a year into a rule means editing the rule every January considering we are following calendar year. Nobody wants that. There are three mechanisms to avoid it, and they serve different purposes.

Substitution Variables

Global placeholders maintained by the administrator, referenced with an ampersand “&”. Update the value in one place and every rule, form and report that references it follows.

FIX (&PlanYear, &CurrentMonth)

  /* calculation here */

ENDFIX

In NEXUSFPA we keep &PlanYear, &CurrentMonth, &PriorYear and &Scenario. Changing the planning year is a five-minute admin task rather than a rule-editing exercise across thirty objects.

Note: - Substitution variable values come back as text, and if the value was entered with quotes in the variable definition, those quotes come along too. In Groovy this is what you can use

String vScenario = '"' + operation.application.getSubstitutionVariable("StratFinScenario").value + '"'

to get a substitution variable. Check and validate the value before you trust it.

Runtime Prompts

An RTP asks the user for a value when they launch the rule. Useful when the calculation genuinely varies by user choice - which entity, which scenario, which months to recalculate.

/* Rule declares the prompt */

FIX ({rtp_CostCentre})

  /* calculation here */

ENDFIX

Two practical notes. Give RTPs sensible defaults, because a planner faced with an empty prompt will either guess or give up. And when a rule runs On Save from a form, Planning can supply RTP values automatically from the form context - which is how you scope a save-triggered rule to exactly what the planner was looking at.

User Variables

A per-user saved selection, usually used to filter forms to the user's own area of responsibility. Less about calculation, more about making one form serve forty planners without forty page selections.

Groovy Rules - When Calc Script Is Not Enough

Groovy business rules are, for me, the most significant thing to arrive in EPM Planning in years. But they are also the most over-applied. Let me be blunt: if a calc script can do the job, use the calc script.

A Groovy rule earns its place when you need one of the following, and not otherwise:

●      Edited-cell-only calculation. Calculate just the cells the planner actually changed, rather than the whole form scope. On a wide form this is the difference between a two-second save and a two-minute save, and there is no calc script equivalent.

●      Validation before save, with a message back to the user. Reject a save and explain why. Calc scripts cannot talk to the user.

●      Dynamic scope decided at runtime. Build the member set from a query, a UDA filter, or the data itself rather than from a hardcoded list.

●      Cross-cube work in a single user action. Read from one cube, write to another, without a separate data map step.

●      REST calls and job orchestration. Trigger jobs, chain operations, integrate with other services.

The Bit Nobody Warns You About

Oracle EPM Groovy is not full Groovy. It is a restricted subset, and the restrictions are not always documented where you would look for them.

Reading and Writing Data in Groovy

The core pattern is a data grid - you define a grid, read it, do something with the values, and save it back:

Cube cube = operation.application.getCube("FPAOPX")

DataGridDefinitionBuilder builder = cube.dataGridDefinitionBuilder()

builder.addPov(["Years","Scenario","Version"],

               [["FY26"],["AOP"],["Working"]])

builder.addColumn(["Period"], [["Jan","Feb","Mar"]])

builder.addRow(["Account"], [["Plan_Amount"]])

DataGrid grid = cube.loadGrid(builder.build(), false)

 grid.dataCellIterator("Plan_Amount").each { cell ->

  if (cell.data > 0) {

    /* do something with the value */

  }

}

This is a randomly written script, let me know if I missed anything.

Note -: For edited-cell-only logic, use the grid iterator's edited-cell filter rather than looping every cell and checking. It is both faster and clearer about intent.

Performance

If you remember one section from this blog, make it this one. Almost every calculation performance problem I have been asked to look at came down to one of five things.

No FIX, or a FIX that is too loose

Covered above, and it is the number one cause by a distance. A rule that calculates all cost centres when the planner changed one is doing hundreds of times more work than necessary.

FIXing on dense dimensions instead of sparse

FIX works by restricting which blocks get processed, and blocks are defined by the sparse dimensions. FIXing on a dense dimension does not reduce the number of blocks touched - it just filters within each block. Put your sparse restrictions in the FIX and handle dense members inside it.

Calculating at upper levels

Writing a formula result to a parent member, then aggregating over it, produces either a wrong number or an argument about whose number is right. Calculate at level zero and let the hierarchy do the aggregating. This connects directly to the parent-member trap from Blog #6 - if a parent is set to Store rather than Dynamic Calc, you will get a stale value sitting there looking entirely plausible.

Block creation problems

You cannot write to a block that does not exist. If a calculation appears to run cleanly but the target cells are still #Missing, this is usually why. SET CREATENONMISSINGBLK ON fixes it, but use it deliberately - it creates blocks whether or not there is anything useful in them, and an inflated cube is slow forever, not just during the calc. We can also use data copy command too which is highly favourable.

 

Calculation order

Dependent calculations must run in dependency order, and this is not automatic. If your allocation rule runs before the revenue rule that produces its allocation basis, the allocation divides by zero or by a stale figure. Rulesets exist precisely to make this order explicit. Use them rather than relying on the sequence somebody happens to click.

Debugging - Finding Out What Actually Happened

Rules fail. The question is how quickly you can find out why.

Tool

Where

What It Gives You

Job Console

Application - Jobs

Run status, duration, and the error message. Always the first place to look.

Rule log

Downloadable from the job details

The actual calc output, including how many blocks were touched and how long each pass took

Validate button

Calculation Manager, before deploying

Catches syntax errors and unknown members. Cheap, so do it every time.

println

Inside a Groovy rule

Writes to the job output. The most useful debugging tool available to you in Groovy.

Smart View retrieval

Excel, against the target intersection

Confirms whether the number actually landed where you intended

 

The technique I use most often is unglamorous and works nearly every time: cut the rule down. Comment out everything, run it, then add blocks back one at a time until it breaks or the number goes wrong. Reasoning about a two-hundred-line calc in your head is vastly slower than bisecting it.

Note: Before you debug the calculation, verify the data. Retrieve the source intersections in Smart View and confirm they hold what you think they hold. A surprising share of 'the rule is broken' turns out to be 'the source data is #Missing because the load failed' or no data entered.

Naming and Governance

Thirty rules in, an application with no naming convention becomes unmaintainable. You will not remember what Copy_Data_New_v2_FINAL does, and neither will the person who inherits it from you.

The convention we use across NEXUSFPA is cube prefix, then a numeric band by purpose:

Pattern

Band Meaning

Example

FPAOPX_0xx

Allocations and data movement

FPAOPX_031 - BAU allocation to FPAPLN

FPAOPX_1xx

Trend and seeding calculations

FPAOPX_130 - BAU trend methods

FPAOPX_21x

Core planning calculations

FPAOPX_211 - opex out-months

FPAOPX_215

Statistical and KPI calculations

FPAOPX_215 - stats KPI trending

FPAOPX_25x

Revenue-driven and percentage calculations

FPAOPX_251 - marketing as percentage of revenue

FPAOPX_00x

Cross-cube data movement

FPAOPX_00x - actuals from FPAPLN to FPAOND

FPAOPX_RS_*

Rulesets

FPAOPX_RS_MonthEnd

 

Two habits worth building alongside the naming. Comment the intent, not the syntax - anyone can see that a line is a FIX, what they cannot see is why you chose that scope. And keep a rule inventory somewhere outside the application listing what each rule does, what triggers it, and what it depends on. When something breaks at month end, that document is worth more than the rules themselves.

Pre-UAT Checklist for Business Rules

This is the list I actually work through before handing rules to users.

●      Every rule validates cleanly in Calculation Manager.

●      Every rule is deployed to the correct cube - and yes, this gets missed.

●      Every On Save rule completes in a few seconds against a realistic data volume, not against an empty test cube.

●      Every FIX is scoped to sparse dimensions and to the smallest slice that gives a correct answer.

●      No calculation writes to an upper-level member.

●      Dependent rules are wrapped in a ruleset with an explicit order.

●      Allocation rules handle a zero or #Missing basis without failing.

●      Substitution variables are used instead of hardcoded years and months.

●      Runtime prompts have sensible defaults.

●      Security is set so planners can launch the rules they need, and only those.

●      Every rule has been run twice in succession - a rule that gives a different answer the second time has a block creation or clearing problem.

●     Results have been tied back to a source outside EPM, in Smart View or a report, by somebody other than the person who wrote the rule.

Note: This is something I generally follow but I am open for any suggestion.

Quick Reference

If you need to...

Use

Why

Roll up sparse dimensions with no formulas

AGG

Fastest option for pure aggregation

Calculate a dimension that carries member formulas

CALC DIM

AGG will skip the formulas entirely

Restrict a calculation to part of the cube

FIX / ENDFIX on sparse members

The primary performance control you have

Copy data between scenarios or versions

DATACOPY

Purpose-built and efficient

Reference a value at another intersection

Cross-dim operator

Reads as an address, right to left

Avoid hardcoding the planning year

Substitution variable

One admin change, applies everywhere

Ask the user which slice to calculate

Runtime prompt

Keeps one rule serving many cases

Calculate only the cells the user edited

Groovy rule

No calc script equivalent exists

Validate a save and tell the user why it failed

Groovy rule

Calc scripts cannot message users

Run several rules in a guaranteed order

Ruleset

Makes calculation order explicit

Move data to a reporting cube

Data map, or Smart Push for immediacy

Built for the job; a rule is the wrong tool

Closing Thoughts

Business rules are where EPM Planning stops being a data entry tool and starts being a planning system. They are also where the difference between a developer who has read the documentation and one who has supported an application at month end becomes very obvious.

If you take three things from this blog, take these. Scope every calculation with FIX, and scope it on sparse dimensions. Calculate at level zero and let the hierarchy aggregate. And reach for Groovy only when calc script genuinely cannot do the job, because somebody has to maintain this after you move on (#MyThought).

In Blog #9 we will look at getting data into the application in the first place - data loads, Data Integration, mapping, and the validation failures that will teach you more about your dimensions than any design document. If you have ever had a load fail on every single row because one dimension had no source column mapped, that blog is for you.

 

!!Happy Learning!!

Comments

Popular posts from this blog

Oracle EPM Planning - Planning, Budgeting, Forecasting, and Long-Range Planning

Oracle EPM Planning Account Dimension: Complete Guide to Member Properties with Examples

Creating your first EPM Application