Sie sind auf Seite 1von 8

@CURRMBR Function A Discussion

FROM TECHREF
@CURRMBR
Returns the member that is currently being calculated in the specified dimension (dimName). This function
can be used as a parameter of another function, where that parameter is a single member or a list of members.
Syntax
@CURRMBR (dimName)
Parameter
dimName

Description
A single dimension name.

Notes
You cannot use the @CURRMBR function in a FIX statement.
You cannot use the @CURRMBR function on the left-hand side of a formula.
The time required for retrieval and calculation may be significantly longer if this function is in a formula attached
to a member tagged as Dynamic Calc or Dynamic Calc and Store.
Example
In the Sample Basic database,
@CURRMBR(Year);

returns Jan if the current member of Year being calculated is Jan.


As a more complex example, consider the following formula in the context of the Sample Basic database.
Assume that the Measures dimension contains an additional member, Average Sales.
"Average Sales"
(IF(@ISLEV(Product,0))
Sales;
ELSE
@AVGRANGE(SKIPNONE,Sales,@CHILDREN(@CURRMBR(Product)));
ENDIF;);

This formula populates each upper-level member of the Product dimension (100, 200) at Average Sales. To
calculate Average Sales, the Sales values for the level 0 members of Product are averaged and placed in their
respective parent members. The Average Sales values for the level 0 Product members are the same as the
Sales values, as specified by the IF statement in the calculation script.
This example produces the following report:
Jan

New York

Sales

Actual

Average Sales

=====

=============

100-10

100-20

10

10

100-30

15

15

100

30

10

200-10

20

20

200-20

25

25

200-30

30

30

200-40

35

35

200

110

27.5

300

#MI

#MI

400

#MI

#MI

Diet

35

11.67

Product

140

35

@CURRMBRRANGE
Generates a member list that is based on the relative position of the current member being calculated.
Syntax
@CURRMBRRANGE (dimName, {GEN|LEV}, genLevNum, [startOffset], [endOffset])
Parameter
dimName
GEN|LEV
genLevNu
m
startOffset

Description
Name of the dimension for which you want to return the range list.
Defines whether the range list to be returned is based on a generation or a level within the
dimension.
Integer value that defines the absolute generation or level number of the range list to be returned.
Defines the first member in the range to be returned.
A null value returns the first member of the specified genLevNum.
An integer value returns the member name relative to the current member being calculated.

endOffset

A negative value specifies a member prior to the current member being calculated in the
dimension.
A value of 0 returns the name of the member currently being calculated.
A positive value specifies a member after the current member being calculated in the dimension.
Defines the last member in the range to be returned.
A null value returns the last member of the specified genLevNum.
An integer value returns the member name relative to the current member being calculated.
A negative value specifies a member prior to the current member being calculated in the
dimension.
A value of 0 returns the name of the member currently being calculated.
A positive value specifies a member after the current member being calculated in the dimension.

Notes
You cannot use the @CURRMBRRANGE function in a FIX statement.
The first three parameters of this function (dimName,{GEN|LEV},genLevNum) provide a member range list.
The startOffset and endOffsetparameters create a subset of this list. For example, consider the following syntax in the
context of the Sample Basic database:
@CURRMBRRANGE(Year,LEV,0,-1,1)
In this example, the full range list contains the level 0 members of the Year dimension (Jan, Feb, Mar, Apr, May, Jun,
Jul, Aug, Sep, Oct, Nov, Dec). If the current member being calculated in the Year dimension is Jan,
the startOffset and endOffset parameters reduce this list to (Jan, Feb). Since there is no member prior to Jan in the
full range list, only two members are returned: Jan itself and the member after it, Feb. If the current member being
calculated is Feb, the subset list would include three members: Jan, Feb, Mar.
Currently, this function can be used only within range and financial functions, such as @AVGRANGE,
@MAXRANGE, @COMPOUND, and @SHIFT.
Example
Example 1
Average Inventory is calculated by summing opening inventories from the first month of the year to the current period
plus one period, and dividing the result by the number of periods to date plus one period. This calculation is
accomplished by defining the @CURRMBRRANGE function within therangeList parameter of the @AVGRANGE
function.
"Average Inventory" = @AVGRANGE(SKIPNONE,"Opening Inventory",
@CURRMBRRANGE(Year, LEV, 0, , 1));
This example produces the following result:
Jan Feb Mar Apr

Nov Dec

Opening Inventory 100 110 120 130 . . . 200 210


Average Inventory 105 110 115 120 . . ..155 155
Since a null value is specified for startOffset, the average operations always begin at the first member of the range
list, Jan. The endOffsetparameter, 1, specifies that the member after the current member being calculated is included
in each average operation. So, for Average Inventory->Jan, the values for Jan and Feb are averaged; for <Average

Inventory->Feb, the values for Jan, Feb, and Mar are averaged; and so on. The values for Nov and Dec are the same
since there is no member after Dec in the range list.
Example 2
Inventory Turnover is calculated by summing period-to-date Sales and dividing the result by the Average Inventory.
Turnover = @SUMRANGE(Sales,@CURRMBRRANGE(Year, LEV, 0, , 0))/"Average Inventory"
which produces the following result:
Jan

Feb

Mar

Apr

Average Inventory 110

116.7 122.5 126

Sales

40

44

Turnover

0.36 0.72

48
1.08

52
1.46

Example 3
Consider the following formula:
@CURRMBRRANGE(Year,LEV,@CURLEV("Year"),-1,1)
The full range list contains the members of the Year dimension at a particular level. The level is determined by taking
the level of the current member being calculated. For example, if the current member being calculated is Jan, the full
range list contains all level 0 members of Year dimension (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov,
Dec). The startOffset and endOffset parameters reduce this list to (Jan, Feb). As there is no member prior to Jan in
the full range list, only two members are returned: Jan and Feb. If the current member being calculated is Feb, the
subset list includes three members: Jan, Feb, Mar.
Note:

The usage demonstrated by this example would require RTDEPCALCOPTIMIZE to be set to FALSE.

FROM OTHER SOURCES


How does @CURRMBR work?
Essbase provides a suite of calculation functions to facilitate the definition and development of complex member
formula calculations. The @CURRMBR calculation function is especially useful with scoping and managing complex
calculations. The @CURRMBR (dimension) function is used to return the name of the member currently being
calculated in the specified dimension.
When using the @CURRMBR calculation function, take into consideration if the calculation is dense or sparse. The
@CURRMBR calculation function is expected to be slower when used on a dense dimension since the function
calculates at the block level, not the cell level. As a result, the function will calculate all of the dense dimension
members, even if a particular dense dimension member is not present in the query. Conversely, performance is not
an issue when using the @CURRMBR calculation function on a sparse dimension since the block corresponds to
only one sparse dimension member.
In addition, the @CURRMBR function on a dense dimension could produce unexpected results or errors when used
in conjunction with other functions such as @CONCATENATE. For example, if a dynamically calculated member in a
query contains the formula Actual->@MEMBER (@CONCATENATE (@NAME (@CURRMBR

("Account")),"_Total")) and the Account dimension is sparse, the query will run without error as long as the account in
the query generates a valid outline member. However, if the Account dimension is dense, the query will result in the
following error even if the account in the query generates a valid outline member:
Error executing formula for [member name] (line 0): attempt to cross a null @ member in function [@X]
The error is produced because the @CURRMBR function calculates at the block level and therefore calculates on all
accounts in the dense block. Not all accounts within the block will generate a valid outline member, resulting in the
error message above.

@CURRMBR IN ALLOCATIONS
Often times with a Hyperion Essbase or Planning application, an allocation of data will be required. Many times, the
allocation is simply moving data from one member to another. When the number of members involved is large,
developing the script can be time consuming. When the members frequently change, the maintenance of the
calculation can be a nuisance.
When the members involved in the allocation are similar on both sides (the from and the to), the following method
can be employed to speed the development and limit, or eliminate, any maintenance required.
Requirement
The application has 50 members in which the data needs to be moved. The data originates from an account coming
from the general ledger. The data needs to be moved to a new member that doesnt exist in the chart of accounts.
The new member will exist in a different part of the hierarchy.
Solution
The first step is to create a corresponding member for each of the 50 accounts that need allocated. These accounts
will be identical to the original 50, except they will be prefixed with a D identifying them as a dummy, or made up,
account. Each of these new accounts will have a UDA of allocation. The prefix of the member and the UDA are not
critical. They will likely be something more meaningful to the requirements.
GL Acct

Dummy Account

500345

D500345

500578

D500578

607878

D607878

Once the hierarchy is ready to handle the allocation, the following function can be used. In layman's terms, this only
executes on the new members added (identified by the unique UDA) and makes them equal to the corresponding
member without the added prefix. We will assume that this is being executed on a scenario that equals Actuals.
FIX(@UDA(allocation))
/* Make the new member equal to the old member */
Actuals = @MEMBER ( @SUBSTRING ( @NAME(@CURRMBR("Account")) , 1));
/* Clear the old member */
@MEMBER ( @SUBSTRING ( @NAME(@CURRMBR("Account")) , 1)) = #Missing;
ENDFIX
Lets assume that the UDA is NOT added to the new, or dummy, member. If the UDA is on the originating member,
the calculation would look like this.
FIX(@UDA(allocation))
/* Make the new member equal to the old member */

@MEMBER ( @CONCATENATE("D",@NAME(@CURRMBR("Account")))) = Actuals;


/* Clear the old member */
Actuals = #Missing;
ENDFIX
Now we can break down these functions. Remember, the calculations loop through all members in all dimensions. In
this example, setting the result equal to Actuals is simply making the account that the calculation is looking at, at
that particular point in the loop, equal to whatever is on the other side of the equation.
@MEMBER ( @SUBSTRING ( @NAME(@CURRMBR("Account")) , 1))
There are four functions used in this string.
@MEMBER will convert a string to a member name
@SUBSTRING requires 2 parameters (3 optional). The first is the larger string from which you want to take a smaller
string. The second is where to start, with 0 being the first character. The third is how many characters to include. If
this is left blank, it will take all the characters to the right of the second parameter.
@NAME will convert a member to a string.
@CURRMBR gets the current member of a specified dimension.
Putting this all together, this calculation (from inside out) is getting the current member of the Accounts dimension
(d345678). It converts that member to a string. It takes all the characters to the right of the first character
(345678). Then it converts the string back to a member. At this point, we can set that member equal to something.
@MEMBER ( @CONCATENATE("D",@NAME(@CURRMBR("Account"))))
The functions here are the same as above, except we are not removing the d. We are adding it.
@CONCATENATE accepts two parameters and will combine those two in to one string
Putting this all together, this calculation (from inside out) is concatenating two strings, a D and the current member
of the Accounts dimension (d345678). It then converts the string to a member. At this point, we can set that
member equal to something.
Benefits
By using these functions, the calculations can be much smaller, quicker to develop, and completely maintained by the
outline. This effectively gives the user community ownership on the maintenance.

OTHER USAGES
Transhipments
In some Essbase models there is a need to capture two essentially identical elements in separate dimensions. One
common example of this is a transhipment model, where it is necessary to identify both the origination and
destination of a shipment.
Two Dimensions
The most straightforward, and often user-friendly, manner to accomplish this type of tracking is to have the same
hierarchy in two dimensions, with each member prefixed differently (i.e. the Source location members might be
prefixed with "TO:" while the Destination members would be prefixed with "FROM:").
Net Shipments

A simple metric to consider in this type of model is often Net Shipments. In a multidimensional database, to calculate
Net Shipments, shipments out of a location needs to be subtracted from shipments in (or vice-versa, depending on
your preference). Assuming this is being calculated for Location A, the formula might look like:
Shipments -> TO:A -> Total Sources - Shipments -> From:A -> Total Destinations
(I.E. take all of the shipments that are sent to "A", regardless of where they are from, and subtract all of the shipments
from "A" regardless of where they go to).
The Problem
The formula is simple and straightforward for one location, and remains similar for all other locations, but, every time
a location is added, renamed, or deleted the calculation must be updated manually.
The Solution
Assuming the hierarchies are carefully constructed to always require "TO:" before the source location and "FROM:"
before the destination location, Essbase can programatically determine the corresponding member by removing and
replacing the prefix.
Components
Several string manipulation functions are required:

@NAME or @ALIAS: Used to pass either an Essbase Member Name or the respective member's Alias
Name to another function as a string.

@SUBSTRING: This function will return a portion of a string passed to it.

@CONCATENATE: Used to join two strings together.

@MEMBER: Turns a string into a reference to a member name.

For this example, I'll also utilize @CURRMBR. This function returns the current member being calculated from a
given dimension.
So, to determine the corresponding destination from a member in the source dimension:

1.

Turn the current member in the source dimension into a string:@NAME(@CURRMBR("Source"))

2.

Remove the prefix "TO:" from the string:@SUBSTRING(@NAME(@CURRMBR("Source")),3)

3.

Prefix the new string with


"FROM:":@CONCATENATE("FROM:",@SUBSTRING(@NAME(@CURRMBR("Source")),3))

4.

Convert the string into a reference to a


member:@MEMBER(@CONCATENATE("FROM:",@SUBSTRING(@NAME(@CURRMBR("Source")),3)))

Using this formula, you can fix on the portion of a hierarchy in the Source dimension, and have access to each
member's corresponding Destination member. The original example of calculating Net Shipments might look like:
Fix(@RELATIVE("Source",0))

"Net Shipments"(
"Shipments"->"Total Destination" - "Shipments"->"Total Source">@MEMBER(@CONCATENATE("FROM:",@SUBSTRING(@NAME(@CURRMBR("Source")),3)));
);
ENDFIX

Das könnte Ihnen auch gefallen