DefineCalc
User-defined calculations (UDC) are supported through the DefineCalc
function. You can use this function to register or unregister a calculation definition in IBM
Planning Analytics for Microsoft Excel.
Users can use DefineCalc()
to create synthetic members that can be incorporated
into their reporting. MDX lets you create new named synthetic members that correspond to MDX
expressions. With DefineCalc()
, you can instruct Planning Analytics for Excel on
how to rewrite MDX expressions that are sent to the data source when your report references the
synthetic members.
Syntax
=DefineCalc(string sDatasource, string sServerName, string sCalcMun, string sExpression, [Optional] bool bOutputMun, [Optional] bool bDisableScramble)
Argument |
Description |
---|---|
|
Name of the datasource subject to injection. Use * if you want to apply the new calculation to all data sources. |
sServerName |
Name of the server subject to injection. Use * if you want to apply the new calculation to all databases. |
sCalcMun |
Member unique name (MUN) of the new expression that you want to register. Use valid MDX notation for the virtual member name. |
sExpression |
The expression that registers as a runtime calculation injection. The expression is injected
directly into MDX queries and must be a valid MDX. If the |
bOutputMun |
By default, |
bDisableScramble |
By default, When
bDisableScramble is set to true , the calculation disables
anti-collision MUN scrambling. Do not disable this parameter if you are injecting subset aggregates
as a calculation of the same name.Important: When
bDisableScramble is
not set to true , MUN matching is white space sensitive.If a calculation refers to another calculation as part of its definition, disable scramble (set
|
The definitions are runtime scoped, relative to unique combinations of datasource, server name,
and calculation MUN. You cannot have multiple active definitions for the same name and
server-connection pairing; the most recently calculated one applies except when a more precise
definition is available. This avoids having multiple DefineCalc()
calls for the
same sCalcMun
member name in your session.
The order of precedence for definitions is as follows:
When you set an empty sExpression
, it removes that particular calculation from
the system. The normal behavior of Alt + F9 (or an equivalent macro) deletes the existing registered
DefineCalc()
definitions and forces a global re-evaluation of the workbook. This
can be useful to verify that your final workbook’s definitions are accurate as definitions can
accumulate during a session as you edit DefineCalc()
formulas.
DefineCalc
MUN or sExpression
can
cause cascading problems with other MDX calculations and result in errors that return bad values for
the query.Examples
In this example, DefineCalc()
defines a calculation that is called
foo
on the plan_lines
dimension default hierarchy, for the
Planning Sample
server on any data source. The expression for the UDC is the sum of
line 1
and line 2
.
=DefineCalc("*","Planning Sample","[plan_lines].[foo]","[plan_lines].[line 1] + [plan_lines].[line 2]")
In the following example, DefineCalc
defines a calculation that is called
'MySubset' on the plan_lines
dimension default hierarchy, for the Planning
Sample
server on any data source, and the sExpression
is the aggregate of
the subset MySubset
on the plan_lines
dimension.
=DefineCalc("*","Planning Sample","[plan_lines].[MySubset]","AGGREGATE(TM1SubsetToSet([plan_lines],'MySubset'))")
This would create the comparable auto subset UDC outcome from a Perspectives report.