Examples for CALCULATED MEMBER
You can use the MDX
Calculated Member construct to define new Members for special functions, depending on existing Members of Dimensions and Measures. The following examples show how the MDX function Calculated Member is used to:Example 1
Use
Calculated Member to:The OLAP processor returns the figures; the MDX processor makes the calculation.
The following code fragment gives an example of this: At runtime, the
Calculated Member profit change from previous month (Profit Change) is calculated by subtracting the Profit for the previous month from the profit for the current month:WITH MEMBER [Measures].[Profit Change] AS
The following graphic displays the results table: Both the profit and the profit change against the previous month is shown for all months of the year 2001.
Example 2
Using the MDX function
AGGREGATE allows you to carry out multiple filtering at run time.The following MDX fragment gives an example of this. At run time, the filter specified in the
WHERE clause is constructed. The system aggregates along the three values in the Calculated Member AGGREGATE function.WITH MEMBER [0D_PLANT].[Aggregate] AS
The following graphic shows the results table: The system returns the profit, the number of documents, and the open orders for the months in 2001 for the selected values OD_PLANT = 1111,2222,6666.
Example 3
Using
Calculated Member also allows you to apply linear regression, a special form of time series analysis. In linear regression, the line of best-fit is calculated from a series of dots. This function can be used to predict future values.The following code fragment shows an appropriate example:
WITH
The following graphic displays the results table: The profit is displayed as is the predicted value taken from the linear regression calculation:
The following chart depicts the actual profit values per month (blue dots) against the predicted values (red dots) on the line of best-fit: