Building Advanced Rules 
Advanced rules enable you to do calculations that only need to be performed on base-level cells (cells where all members have no children in any dimension). The results are aggregated up the dimensional hierarchy intact, without being recalculated at upper levels.
When to use advanced rules
An example of an advanced rule formula is: units times price calculations. Such calculations cannot be defined in dimension rules because they must only be performed on base-level cells. You can define units times price calculations in worksheets where the calculation is applied to values retrieved from the Planning and Consolidation database but maintaining and controlling the formulas is difficult.
Planning and Consolidation provides a library of MDX and SQL formulas. In addition to the sample formulas, the ApShell application set is preconfigured with many functions which are included in all application sets you create from ApShell.
About advanced rule files
The rules module relies on Advanced logic files which contain the formulas that are to be applied to the specified calculated members (data selection). The rules module does not perform the calculations directly, but uses MDX or SQL queries that it passes to the Analysis Server to retrieve the desired results. The formulas that it uses must be consequently written in the correct syntax.
The Advanced rules files are LGF (ASCII) files and contain the code for the formulas.
The compiled logic file - When the advanced formulas text file is saved it is actually converted into another file (with the extension LGX) that is an executable version of the LGF file.
The library file - Library files store a library of standard functions. (Currency translation and intercompany eliminations, for example.) A library file has the extension LGL. You can use the #INCLUDE function in your LGF file to call the library file at validation. The rules module scans the library file for the appropriate formulas to use based on the information in the LGF file.
The dimension constants file - This is a rules file but it behaves a little differently. It maps your dimension names for the application to the standard Planning and Consolidation dynamic logic. By updating the dimension constants file with your dimensions, you
avoid having to change or rewrite any of the standard functions that are included with the system. The dimension constants file is located in: <BPC>\Webfolders\<AppSet>\SystemLibrary\System_Constants.LGT
// application constants//------------------------------------------------------------
*FUNCTION CATEGORYDIM =%CATEGORY_DIM%
*FUNCTION TIMEDIM =%TIME_DIM%
*FUNCTION CURRENCYDIM =%CURRENCY_DIM%
*FUNCTION ENTITYDIM =%ENTITY_DIM%
*FUNCTION ACCOUNTDIM =%ACCOUNT_DIM%
*FUNCTION INTCODIM =%INTERCOMPANY_DIM%
// This part is needed when a RATE application
// is associated to the application
// (FX = single or multi currency) //------------------------------------------------------------
*FUNCTION RATEAPP =%RATE_APP%
*FUNCTION RATEENTITYDIM =%RATEENTITY_DIM%
*FUNCTION RATEACCOUNTDIM =%RATEACCOUNT_DIM%
*FUNCTION INPUTCURRENCYDIM =%RATECURRENCY_DIM%
*FUNCTION RATEENTITYMBR =%RATEENTITY_DEFAULTMBR%
*FUNCTION RATESRCCALCMBR =RATECALC
where is the drive where the Planning and Consolidation software is located and is the name of the application set.
Example
For example, if your category type dimension is named "MYCATEGORY", you would change:
*FUNCTION CATEGORYDIM =%CATEGORY_DIM%
to:
*FUNCTION MYCATEGORYDIM =%CATEGORY_DIM%
You can also include application constants and member constants in the dimension constants file. For example, you would do this if your advanced formulas reference another application where values to be used in the formula were stored.