You are on page 1of 22

Tools for rules

Tips and tricks for how to make your task as an HFM rule programmer just a little easier

Introduction to a compilation of useful tools

Dennis Jensen
Finance System Manager
Tools for rules

• Global engineering company supplying one source plants, systems and services
to the cement and minerals industries.
• 13,000 employees in more than 50 offices worldwide.
• Annual Revenue USD 3bn
• Founded in 1882

Dennis Jensen
• Finance background
• 9 years of HFM experience
Tools for rules
• Create your own powerpack for Notepad++, adding formatting capabilities such as expand/collapse blocks of
code, background colouring, etc.

• How to measure time for running your rules calculations

• How to use UD’s and member lists to create custom lists for your rules coding, and make your rules
maintenance more simple

• OpenDataUnit, your best friend for limiting data processed by your rules code

• Use variables ! (and comments)

• Create on/off switches that can be updated in a data form to enable activation/deactivation of validations,
etc., without changing rules

• Use WriteToFile for your debugging


Tools for rules
Notepad++ (I)
I highly recommend this tool for HFM rules editing

There is a free ”Compare” Plugin available.

If you download it, it will be possible for you to run comparisons against both previous file and last save, for
easy review of your changes.
Tools for rules
Notepad++ (II)

Install ”HFM RULES” language for all the familiar formatting.


”HFM RULES” is a free download.

Create your own language by adding extra features to


”HFM RULES”

The example to the right will allow collapse/expand of blocks


of code for each Sub or Function, or where I input the
comment ”SectionStart” or ”SectionMiddle”
Tools for rules
Notepad++ (III)

The example to the right will add some formatting to the


Keywords in groups 5 and 6.

The keywords in groups 1 – 4 is already defined in the


”HFM RULES” language.

I recommend keeping the ”HGM RULES” formatting, but


you can add f.ex. background color.
Tools for rules
Notepad++ (IIII)

The example below shows all blocks of code collapsed, you


can easily navigate to any block of code.
The example to the right shows a selected block of code
expanded, and also shows formatting of keywords ”If” and
”For” to have background colour.
Just save your own language when done setting up features.
Tools for rules
Measure time (I)

There are different ways of doing this.

No success in getting useful information from the built-in Rules Profiler in HFM.

But there are other options available for measuring time, using f.ex. date and time functions and WriteToFile.

Always comment out time measurement when not required, as it can have a large impact on performance.
Tools for rules
Measure time (II)

Example of rules code to provide output:

Matt Spencer, Finit, will give presentation about this solution in ”Campfire Stories”
Tools for rules
Measure time (III)

Output file: Put into Excel file


Apply filters, PivotTables, etc. for analysis
Tools for rules
Use UD’s and Member Lists for rules coding (I)

Can be used to build Member List for data selection, set destination in a rule, for Y/N triggers, etc.

This example shows how to use it to set destination on C4:


Tools for rules
Use UD’s and Member Lists for rules coding (II)

This example shows how to select Accounts for Cash-Flow calculations.


1. Enter value on UD on Account metadata
2. Create Member List based on UD value
3. Use Member List in OpenDataUnit

This way you do not need to update rules when new Accounts are created, new Accounts are added to your
rules through the UD value in Metadata
Tools for rules
OpenDataUnit (I)

Use it to limit the data processed in your rules.


Not only to optimize performance, but also to exclude calculations where not wanted.

Set up like below:


Tools for rules
OpenDataUnit (II)

Comparing performance of DataUnit with a range of Accounts (on previous page), compared to setting the
DataUnit to be just one of the Accounts in the range:

Range of Accounts: One Account only:


No. of Data records: 6,588 2,587
Time taken to complete calculation: 107.453 45.626

Performance gain: 57.5%

The above example with 6,588 records is only a small percentage of the data records available, so if the
comparison was made against all data records the difference would be much larger.

See also ”Data-Driven Rules in HFM” (Keith Berry, KScope16) for more details about OpenDataUnit
Tools for rules
WriteToFile (I)

WriteToFile creates a text file, and it can be used for multiple purposes.
• Output for time measurement
• Output for checking No. of data records
• Rule debugging
• Etc.

The below example selects content for the text file to be generated.
Tools for rules
WriteToFile (II)

This is an example of code that will generate


A text file.

Remember to always comment out


”WriteToFile” when not needed, as it has
a large impact on performance.

See also ”Where did that come from ?” (Chris Barbieri, KScope15) for more details about WriteToFile
Tools for rules
Use Variables and comments
Often stated, but important enough to justify repetition

Using variables in your rules code makes it much easier to maintain .


In a recent project where we expanded our HFM application to contain 8 Custom Dimensions it would have
saved many hours of work if we had used variables more extensively.

Using comments to provide explanations and guidance is also a very good idea
Tools for rules
Create on/off switches (I)

On/off switches can be used in your rules code, allowing f.ex. validations to be activated or deactivated just by
entering a number on a data form.

In the below example, an Account has been set up for each validation, and each month a value is input to
determine if the validation is active or not for the period.
Tools for rules
Create on/off switches (II)

Only if the value entered is ”0” (for active), and the validation Account gives a value, then a lock will be placed
on the validation.

Example of rule code:

On/off switches are particularly beneficial where you want to activate or deactivate rules code without having
to load updated rules.
Setting the switches to be values to be input in data forms also means that users can activate or deactivate.
Tools for rules

Questions