PREVSELF

Syntax

PREVSELF (Dimension, {Start Value}, {Count})

Description

The PREVSELF function returns the value of the current data cube from Count members back in Dimension. When the program is calculating the first Count members of Dimension, PREVSELF returns Start Value. If Start Value is omitted, it is assumed to be 0. If Count is omitted, it is assumed to be 1.

Note:

The PREVSELF function operates on detail member names that are persisted in the main record. This function does not use trees to determine the order of members.

Returns

The PREVSELF function returns the value of the current data cube from Count members back in Dimension. When the program is calculating the first Count members of Dimension, PREVSELF returns Start Value. If Start Value is omitted, it is assumed to be 0. If Count is omitted, it is assumed to be 1.

Example

Suppose that you want to forecast sales. For each month, you want to add an estimated Sales Growth to the previous month's sales. When calculating the first month, you want to add sales growth to starting sales. You can do this with the following formula for the SALES cube:

PREVSELF(MONTHS, STARTING_SALES) + SALES_GROWTH

For the first month, this formula returns the starting sales plus sales growth. For every other month, the formula returns the previous month's sales plus sales growth.

The PREVSELF function is useful for keeping a running balance of transactions. For example, suppose that an analytic model contains monthly data cubes called DEPOSITS, WITHDRAWALS, and BALANCE, and a single value data cube called START_BALANCE. You can calculate the BALANCE cube with the following formula:

PREVSELF(MONTHS, START_BALANCE) + DEPOSITS - WITHDRAWALS

This formula calculates the ending balance for each month by adding DEPOSITS and subtracting WITHDRAWALS from the ending balance for the previous month. Because no previous balance is available for the first month, the PREVSELF function returns the value of Start Balance.