Академический Документы
Профессиональный Документы
Культура Документы
Craig Bodington
Product Support
April 21, 2008
Agenda
Logic Syntax
Troubleshooting Logic
Topics
Spreadsheet Logic
Formulas
Formula
Created
Can
Dimension Logic
Parameters
Parameters
Two forms of the language (SQL and MDX) that perform the same function
Spreadsheet
Logic
Dimension
Logic
Business
Rules
Modeling
Logic
Reporting Values
Yes
Yes
Yes
Yes
Creating Records
Yes
No
Yes
Yes
Moving Data
Yes
No
Yes
Yes
Calculations on base
records
Yes
Yes(1)
Yes
Yes
Calculations on
parent levels
Yes
Yes(1)
Yes(2)
Yes(3)
Uses
Only used when same formula applies at all levels of the application. This is for
performance reasons not an Analysis Services limitation.
(2) Calculations involving aggregated values are derived within the logic not referenced
from the cube.
(3) You can reference aggregations from the cube using the MDX form of the syntax but it
should NOT be done for performance reasons. There are alternate methods to derive
the values.
(1)
Spreadsheet logic
Reporting
For
Best
practice is to define the calculations in the database if you repeatedly use the same data on lots
of reports.
Budgeting/Forecasting
Limit
to templates that contain all the required values as inputs on that template.
If
the values the formula depends on can be changed in multiple templates, then its best to use logic
that calculates on the database.
Dimension logic
Do not use if the values calculated need to be available for exporting out of the application.
Be careful of recursive calculations. Incorrect solve order can cause problems. Remember
EVERY number that is displayed in the application is a calculated value
Business Rules
Use
when calculations MUST occur on base level members and then aggregate.
Application
of logic is limited to the business rules (stored procedures) that have been
written:
RunSummarize Performs addition and subtraction on accounts based on a formula property in the dimension
RUNCopyOpening Summarizes a group of activity accounts and copies the value into an opening balance account
Script
logic
Use
when calculations MUST occur on base level members and then aggregate.
Use
when underlying data can be changed by multiple users and/or from multiple
templates.
Use
Use
for calculations that need to occur during scheduled or batch process without user
interaction.
Use
when calculations should automatically occur when values in the database are
changed.
Spreadsheet Logic
Executes
If
the workbook is an input template, the calculated values will only update the database
when the user performs a send to the database
Dimension
Logic
Executes
when the user queries the application through a template or schedule. If a user
has access to the SQL Server management studio, the value can be seen directly in the
cube.
Calculated
Values
Business
are always based on the data in the cube when the query is executed by AS
Rules
Executed
logic file.
Business
Scripting
Logic
Can be executed whenever data is changed by including the script in Default.lgf system
script file.
It
It
will NOT occur if data is directly manipulated in the fact tables by SQL queries or direct
SQL imports.
Default
logic executes based on the commands in the script file NOT based on the user
security profile.
Can be executed on demand by running a Data Manager package that is setup to reference
the script file. The code executes based on the script not user security but the user must
have a task profile that allows them to execute DM packages.
Can be executed through custom DTS/SSIS packages by including a step to run the scripts
files.
Script logic files can include (*INCLUDE) references to other logic files. If this is used, then
the included file is executed when the script file that contains the include is executed. The
included code is executed at the point that it is included relative to other code in the main
script file.
Spreadsheet Logic
Pros
Simple.its
Only
Cons
Formulas
Can
Logic
Excel
Dimension formulas
Pros
Uses
standard MS-MDX
Executes
Formulas
Cons
Can
Can
If
formula is over 255 characters long, the code must be written in a separate file and included in the
dimension on the OPTIONS tab of the member sheet.
Business Rules
Pros
Code
Execution
Typically
fastest execution because it works in the relational database using SQL Server memory
Cons
If
Stored
Rules
Script Logic
Pros
SQL
Code
Scripts
Code
Permission
profiles.
Can
Cons
MDX
Proprietary
language so skills are not generally available without specific BPC training.
Code
that executes as part of default logic does impact input template send times so use with
caution.
No
interface for editing system libraries. You have to directly access the files on the file server
modify with a text editor.
Spreadsheet logic
Implementation
During
Dimension
Implementation
Typically
change.
Business
Rules
Implementation
Typically
Script
Logic
Implementation
Typically
Logic Syntax
Topics
Logic overview
Dimension Logic
Scope of Execution
Business Rules
RunAllocation
RunSummarize
RunCalcAccount
Scripting Logic
Logic Overview
Spreadsheet logic
SIMPLE..its
Uses
Excel.
Calculated
Dimension Logic
SIMPLE
Standard
Calculation
Value
Logic Overview
Business Rules
Underlying
The
Logic Overview
Scripting Logic
NOT
Proprietary
Two
MDX
names refers to where the calculation engine gets the initial record
set for processing
MDX
Logic Overview
When
specifying a solve order, you use the parameter and give it a positive
integer value (e.g. Solve_Order = 4).
If
The
value itself is not important in a of itself. Its the value on a particual formula
relative to all other formulas. For example, Solve_Order = 5 and Solve_Order =
500 have no intrinsic meaning other than any formula with a lower solve order
will be processed by AS first.
So,
MDX
Calculated
Dimension
Calculated
measures are put into the relational store (tblFormula) and create the
formulas in AS when the application is built.
If
Measures
Parent
Periodic
MTD,
QTD, and YTD all reference Periodic and perform the appropriate time summation
based upon the levels in the time dimension. They all have a solve order of 4 because
they have to calculate after Periodic.
Scope of Execution
script logic (and some business rules) most problems are scope
problems.
Scope
There
The
actual logic itself can contain scoping statements that can alter
(increase, decrease, completely change) the scope from the default.
Execution
In order to build the correct data selection, the logic module will rely on
all occurrences of ALL different combinations of dimension members
that are found in the posted data, including the currency dimension,
but not including the [A]ccount dimension
Scope of Execution
Execution
The
Any
The
logic module will then run the selected logic only for the selected
members of the selected dimensions.
The
The
Scope of Execution
For example, lets assume that the user has entered data for six cells in the cube.
The corresponding records could be the following:
CATEGORY
TIME
ENTITY
CURRENCY
ACCOUNT
PRODUCT
PERIODIC
ACTUAL
2007.JAN
SALESITALY
LC
UNITS
PRODUCTA1
12,345
ACTUAL
2007.JAN
SALESITALY
LC
INPUTPRICE
PRODUCTA1
100
ACTUAL
2007.FEB
SALESITALY
LC
UNITS
PRODUCTA1
54,321
ACTUAL
2007.FEB
SALESITALY
LC
INPUTPRICE
PRODUCTA1
200
ACTUAL
2007.FEB
SALESITALY
LC
UNITS
PRODUCTA2
6,789
ACTUAL
2007.FEB
SALESITALY
LC
INPUTPRICE
PRODUCTA2
300
In this case, BPC for Excel will pass a selection containing the category ACTUAL, the time
periods 2007.JAN and 2007.FEB, the products PRODUCTA1 and PRODUCTA2,
the currency LC, and the entity SALESITALY.
Scope of Execution
*XDIM_MEMBERSET
*XDIM_MEMBERSET
*XDIM_ADDMEMBERSET
*XDIM_FILTER
Does not alter the scope but filters the record set to members that
satisfy the filter criteria
*XDIM_FILTER
Scope of Execution
*GET_MEMBERSET is used to create a dynamic member list based upon real data in the
cube.
Scope of Execution
Example:
*XDIM_GETMEMBERSET EMPLOYEE=[EMPLOYEE].[CY_NEWHIRES].Children
*XDIM_MEMBERSET HRCOSTELEMENT=NO_ELEMENT
*XDIM_MEMBERSET TIME=2008.INP
*CRITERIA [COSTCAT].[LOGIC_FLAG]<>1
*ENDXDIM
Explanation
We will search the children of CY_Newhires in the employee dimension
Where HRCOSTELEMENT is equal to NO_ELEMENT
And TIME is equal to 2008.INP
To find which CY_Newhire children have a value <> 1 in account Logic Flag.
*Note CostCat is a TYPE A account dimension
Scope of Execution
A simple
*XDIM_Memberset COSTCAT =
PTO_DAYS,FLOAT_HOLIDAYS,STAN_DAYS,FIXED_HOLIDAYS
Expand
Scope of Execution
How
MDX
*MEMBERSET(%Months2%, "Descendants([TIME].[2008.Total],999,leaves))
SQL approach
WHERE=<<<;
WHAT=2008.INP; WHERE=BAS(2008.TOTAL);
*ENDALLOCATION
*COMMIT
WHAT=SALES;
WHERE=<<<;
WHAT=2008.INP; WHERE=BAS(2008.TOTAL);
*ENDALLOCATION
*COMMIT
WHAT=SALES;
Calculation
NOTE:
The name you enter in this field is referenced in the subroutine and stored
procedure. For example, if you name the rule N, your subroutine call would be:
RunCalcAccount(ThisApp,%Category_Set%,N). This assumes that you want to run this
calculation on LC only.
The
name can be anything you want. Customers have used numbering schemes so that
they know what piece to run at each point.
Calculation
Source
Month
Blank:
Non-blank:
Source
Year
Blank:
Non-blank:
amount
the year where to read the value to process. It can be an absolute or a relative
commands
Body/Code
*WHEN Statements
*REC statements
*GET statements
*FOR loops
Writing
*COMMIT
Performance
commands
*XDIM_NOSCAN
*XDIM_MAXMEMBERS
Special
purpose commands
*LOOKUP
# memory variables
*Calc_DummyOrg
*WHEN All SQL logic requires a when statement. If you do not see one,
the you are dealing with MDX logic.
*WHEN {criteria}
*IS {valid condition1}[,{valid condition2},] *REC[([FACTOR|EXPRESSION={Expression}[,
{dim1}={member},{dim2}=])]
[*ELSE]
*REC[([FACTOR|EXPRESSION={Expression}[,{dim1}={member},{dim2}=])]
*ENDWHEN
{criteria}
Example:
is what to test. Typically, its a property of the current member of a dimension. DimensionName.Property
*WHEN ACCOUNT.RATETYPE
{ValidCondition}
Example 1: *IS "AVG","END
Example 2: *IS 10,20,30
If no operator is specified, the *IS clause assumes the presence of an equal sign (*IS = AVG, END).
*IS > 2,
*IS <= 7
*IS <>ABC
If any operator is used, only one value can be passed. (This syntax is invalid: *IS >2,3,4)
*REC The heart of SQL logic. Produces a new RECord in the fact table
*REC({FACTOR|EXPRESSION},[Dimension=member])
The first part of the command is the calculations rule. This produces the
numeric value of the new record.
The second part of the statement provides the destination of where to send
the data. If a dimension is omitted from the list, the value of the current
record is used for the dimension.
Factor means to multiply the value of the current record by some value.
*REC(FACTOR=1)
*REC(FACTOR=-1)
*REC(FACTOR=1/12)
*REC(FACTOR=(2+3))
Signeddata x1
Signeddata x -1
Signeddata/12
Signeddata x5
*REC(EXPRESSION=1) All posted records will equal 1. Ignores the signeddata amount
*REC(EXPRESSION=%VALUE%) %Value% is signedata, so this is equivalent to Factor=1
*REC(EXPRESSION=%VALUE%*10)
*REC(EXPRESSION=%VALUE%+10)
Signeddata +10
GET({dimension}={member}[, {dimension}={member}])
Where:
{dimension} is a valid dimension name
{member} is a valid dimension member. This can be an explicit member name like ABC (in which case it
should be enclosed between double quotes), or it can be derived reading the property of the current
member of any dimension.
GET(ACCOUNT=ABC)
GET(ACCOUNT=ACCOUNT.MYPROPERTY)
GET(ACCOUNT=ACCOUNT.ELIMACC,ENTITY=INTCO.ENTITY
*NEXT
*WHEN TIME
*IS <>TOT.INP
*WHEN ACCOUNT
*IS PERCENT_ALLOC
*FOR %YEAR%=2003,2004,2005
*FOR %MONTH%=JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC
*REC(FACTOR=GET(ACCOUNT="TOT.OVRHEAD",TIME="TOT.INP")/100,TIME="%YEAR%.%MONTH%")
*NEXT
*NEXT
*ENDWHEN
*ENDWHEN
*COMMIT takes the produced records out of memory and writes them as
difference records to the writeback fact table.
*XDIM_NOSCAN
*XDIM_NOSCAN
Example:
*XDIM_NOSCAN DATASRC=PRICE
Used in cases where records are needed in memory for calculation purposes but
the do not need to be processed through the main code.
*XDIM_MAXMEMBERS Entity = 50
This instruction, in case the entities to process exceed the limit of 50 members, will
break the query into multiple queries of no more than 50 entities each.
Important: the maximum number of members can be specified for up to TWO
dimensions
LOOKUP Used to query for a value that is not currently in memory. Can
be used to query across applications.
*LOOKUP {App}
*DIM [{LookupID}:] {DimensionName}="Value" | {CallingDimensionName}[.{Property}]
[*DIM ]
*ENDLOOKUP
Where:
{App} is the name of the application from which the amounts are searched
{DimensionName} is a dimension in the lookup app
{CallingDimensionName} is a dimension in the current application
{LookupID} is an optional identifier of the looked-up amount. This is only required when multiple values
must be retrieved
*LOOKUP RATE
*DIM ENTITY2="DEFAULT"
*DIM SOURCECURR:INPUTCURRENCY=ENTITY.CURR
*DIM DESTCURR1:INPUTCURRENCY="USD"
*DIM DESTCURR2:INPUTCURRENCY="EURO"
*DIM RATE=ACCOUNT.RATETYPE
*ENDLOOKUP
In the above example, three different values are retrieved from the INPUTCURRENCY
dimension (the rate of the currency of the current entity, the rate of the currency EURO and
the rate of the currency USD). Each of these values has been assigned a specific identifier
(SOURCECURR, DESTCURR1 and DESTCURR2) that will be used somewhere in the
WHEN/ENDWHEN structure.
*DESTINATION_APP is used to designate the application where records will be moved to.
*SKIP_DIM is used to skip over dimensions that do not exist in the destination application.
*ADD_DIM is used to add destination dimension that does not exist in the source
application.
Troubleshooting Logic
Topics
Typically
Be
careful of range names that are using in the BPC add-in (e.g.
Application)
Be
If
they are using formulas in the worksheets that are used to derive
member names for use in the row or column keys, you can have cases
where the formulas do not resolve before the request gets passed to the
server. Typical symptom is the first refresh doesnt work but the second
refresh does.
Clients
that use comments and are migrating from 4.x to 5.x may run into
issues if they are using VBA to refresh data and comments. The comment
macros no longer exist. Also, comments refresh after data in 5.x
Its
If
there are multiple hierarchies in the dimension (5.x specific) then there is
a change where there has to be a FormulaHx property for each hierarchy
and formulas must fully qualify out each hierarchy case.
You might see cases where logic directly calls the stored procedure
(*RUN_STORED_PROCEDURE) directly rather than using the wrapper
function. The SP name can change so the best practice is to always call
the wrapper which stays the same.
Because the procedures are encrypted, there isnt anything you can do to
check for code errors.
code works some times especially if it doesnt work from input screens
but does if you run from DM.
Data
4.2
If
you are dealing with a 4.2 client, then you have the logic debugger available in
the product to help make code testing easier.
Be
careful with the debugger if there are multiple commits. The debugger does
not simulate posting records for subsequent commit blocks so values will not be
available unless you actually post the.
you see properties being used in the code, make sure they have values and
are correct for the current scenario.
User
Check
If
records are generated in the log make sure they are looking for data in the
correct locations
Get
the SQL from the log if youre seeing not records found and remove
restrictions from the WHERE clause to see where the data resides.
If
the client is looking at data directly in the writeback table and see records
but the values are wrong, make sure theyre looking at all the data (think
difference records).
If
the values in the cube are wrong but correct in the fact table, make sure
theyre not running SQL process to clear data without processing the cube.
Additional References
The on-line help document provided with BPC is available from the
Administration client.
Select Using script logic > Rules keyword reference
Questions