We are under construction!
You may experience downtime, errors or visual oddities, but we anticipate all will be resolved by the end of the day.
You may experience downtime, errors or visual oddities, but we anticipate all will be resolved by the end of the day.
The OneStream platform is based on the Microsoft .NET Framework, as is the OneStream Business Rules Engine. VB.NET has become the logical choice for Business Rule syntax, and is also a popular programming language in use today. It is also possible to write Business Rules in C# on OneStream Platform.
NOTE: Please write C# and or VB.NET Rules only when necessary.
OneStream projects should not be a contest to see who is better at writing complex rules.
OneStream consultants should write rules only when necessary, not because they can.
When should these types of calculations be used in rule writing?
Dynamic Calculations
“On-the-fly” calculation runs when opening a Form, Report, Cube Views, or Quick Views that refer to each data cell.
Stored Calculations
Dynamic Calculations vs Stored Formulas
Tip 2: Consultants should discuss rule types before rule writing.
Application performance depends largely on how they are designed.
To the table above, add that the results of Dynamic Calculations cannot be used as inputs to another calculation.
TIP 3: Consultants should consider using Data Buffers and Data Units before embarking on the build phase.
Get these rules wrong and cry (slow application)
, or get them correct and smile (good performing application).
Ensure you understand the customer's Data Units and Data Buffers? This is where the project Subject Matter Expert helps. A Data Buffer represents all the stored data cells in a Data Unit.
Data Buffer is the term used to refer to a collection of data cells within a Data Unit.
TIP 4: Data Units.
A data unit is used to load, clear, calculate, store, and lock data. OneStream provides the following Data Units. Understanding the Data Unit and how data is stored in the Cube is crucial to writing Calculations.
Members of the Level 1 Data Units or Cube Data Units are essential to remember.
TIP 5: Stored Calculations and Consolidations start with Data Units.
Data will be stored and generated dynamically from rules within your application. It is important to store only what is needed (e.g., Seeding Data).
TIP 6: We write and run rules to calculate critical statements such as:
Cashflow, seeding data, driver-based calculations, customer KPI calculations, etc.
Consultants should discuss Member Formulas and Finance Business Rules in report design meetings.
Finance Business Rules vs Member Formulas. Why do we choose one method over another?
Finance Business Rules |
Member Formulas |
|
|
The advantage of using Business Rules over Member Formulas is the ability to control behavior through Finance Function Types, which are unavailable in Member Formulas. E.g., Custom Calculate functions cannot be executed through Member Formulas.
Member Formulas provide a maintenance-friendly natural structure to your calculation code. If you want to edit the Calculation Script for the Receivable Account, you can quickly find it in the Dimension Library.
Which is Better – Business Rule or Member Formula? The bottom line is that – in a given implementation – you will have a mix of Business Rules and Member Formulas, and it is primarily up to the Consultants to decide which method is deployed.
TIP 7: Remember that calculations are run from a Cube View Grid, through a Workflow Process task, and a Data Management Sequence.
The Data Unit Calculation Sequence (DUCS) is a series of steps that occurs each time a Calculation or Consolidation is run.
DUCS Sequence:
TIP 8:
More Rules about Rules.
Stored Calculations – API.Data.Calculate
Here is an example of not being at the crime scene and going to jail all the same. If a UD1 member is not included in the rule formula, all members of the UD1 dimension will be processed. This is slowing down your application.
What are the Data Unit and Account-type Dimensions rules for rules?
If Api.POV.Account.Name = …
Types of API.Data.Calculate
Remember, using Stored Calculations is sometimes correct.
Some Store Calculations Benefits are:
TIP 9: Improve Cube View performance with Dynamic Calculations: API.Data.GetDataCell.
TIP 10: ALWAYS comment out BRAPI.ErrorLog.LogMessage(si, “Here”)!
Tip 11: Avoid embedding Decimal Variables inside a Calculate statement.
Nearly all of us have done something like this at some time in our career:
Dim dTaxRate As Decimal = 0.123
api.Data.Calculate("A#[Result] = A#[Source] * " & taxRate)
This will break when executed by a user with a non-English culture code setting.
Usually this will happen after go-live, when it is too late and the damage has already been done, because nobody tested the application with a non-English culture code setting.
Correct way to use decimals inside calculations:
Some consultants would point out that using XFToStringForFormula() would make your calculation culture-safe. However, this has the side effect of truncating your decimal amount to 9 decimal places, and the added overhead of converting decimals to strings.
For best results, use the FormulaVariables method, as in the following example:
Dim dTaxRate As Decimal = 0.123
api.Data.FormulaVariables.SetDecimalVariable("taxRate", dTaxRate)
api.Data.Calculate("A#[Result] = A#[Source] * $taxRate")
This way you ensure no culture issues, and no loss of accuracy since you don’t have to convert decimals to strings.
Tip 14: When working with solution tables with date columns (such as a People Planning Register), never assume a particular date format.
We have seen code that assumes dates are presented in the form ‘mm/dd/yyyy’ and extracts characters in a particular position, assuming that will always be the day or month. Many consultants were unaware that the user’s culture setting affects the interpretation of decimals and dates on the server too!
This is particularly common when embedding filter parameters into SQL queries.
This practice even has an industry-wide name: SQL Command Injection.
For example:
Instead, the offending lines should be changed , to separate the parameter values from the query string.
This way your business rule is not vulnerable to SQL Command Injection (security concern), and the added benefit is that your rules become globally safe for various users’ culture codes and regional settings.
Key Points to remember:
Pay particular attention to the correct interpretation of decimals, especially where you may have embedded decimal variables inside Calculate Statements (not recommended). Check also for correct interpretations of dates if using solution tables: Remember that most countries do not use mm/dd/yyy format.
We have seen many emergencies being raised on production applications that have worked fine until a user logs in from France or Germany for example. So we cannot stress this enough.
Conclusion
Understanding how data is stored and organized in the Cube is vital to writing efficient and effective Calculations and Business Rules. Mastering OneStream's Data Buffer Math: Where One Equation Rules the Financial Galaxy! Say Goodbye to Intersection Chaos and Hello to Data Wizardry with api.Data.Calculate. Because in the World of Corporate Finance, Performance is King and Precision Reigns Supreme!
For more information:
Blogs from Experts on OneStream
I've instructed L2 Finance Business Rules for the last 4 years, great cliff notes version!! Thanks for sharing!