Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 20. Advanced Crystal Analysis Re... > Crystal Analysis in the Real World—M...

Crystal Analysis in the Real World—MDX

As mentioned in the previous section, the primary exposure that a Crystal Analysis designer has to MDX or Crystal OLAP Syntax is in the creation of custom calculations not already available in the data source. This section provides some real-world examples of MDX in action to facilitate some quick learning. Table 20.5 highlights a few sample calculations, their purpose and a quick explanation of their components.

Table 20.5. MDX Samples
CalculationDescriptionMDX and/or Crystal OLAP Syntax
Member NameOften in Financial Reporting, the repetition of the Member Name is required in the middle of the worksheet (see Figure 20.19). This can be accomplished using the MDX CurrentMember and Name functions. In Figure 20.19, the caption has been changed to dashes for cosmetic reasons.KPI.CurrentMember.Name Crystal OLAP provides similar functionality with the GetName function.
VarianceThe Variance function provided in the Calculation Expert uses the conditional IIF MDX function to check for null values and basic member syntax and math to calculate the variance.IIf( [Measures].[Budget] = NULL, NULL, (([Measures].[Actual]-- Measures].[Budget]) / Measures].[Budget]) * 100)
Note that the sample OLAP cube already had a Variance calculation created but was re-created here to demonstrate the MDX.
GrowthThe Growth function provided in the Calculation Expert provides a default growth calculation based on the growth of the current member (Q2 1998 in Figure 20.19) over the immediately previous member (Q1 1998) at that member's level in the hierarchy. In the example shown in Figure 20.19, this will not do because a Year over Year comparison is required. The default MDX provides a good starting point for modification. The original calculation used the PrevMember MDX function to capture the last Quarter. This needed to be replaced in the new calculation with a cocktail of MDX functions including Cousin, CurrentMember, Parent, and PrevMember MDX functions.The Default Growth Function MDX:

IIf( [KPI].&[1] = NULL, NULL,

IIf( Count( { ([KPI].&[1],

[Time].PrevMember) } ) > 0, 100 *

(([KPI].&[1]--([KPI].&[1],

[Time].PrevMember)) / ([KPI].&[1],

[Time].PrevMember)), 0))
The Edited Growth Function to Reflect Year over Year Growth:

IIf( [KPI].&[1] = NULL, NULL,

IIf( Count({([KPI].&[1],

Cousin([Time].CurrentMember,[Time].

CurrentMember.Parent.PrevMember))})

> 0, 100 * (([KPI].&[1]--([KPI].&[1],

Cousin([Time].CurrentMember,

[Time].CurrentMember.Parent.

PrevMember))) / ([KPI].&[1],

Cousin([Time].CurrentMember,[

Time].CurrentMember.Parent.

PrevMember))), 0))
Note that Cousin looks for the member at the same level of the first argument in the same relative position underneath the second argument's hierarchy.
Parent Company SalesThe LookUpCube function enables you to process an MDX statementon a separate cube within the same SQL Server database. In this hypothetical example, the Sales Report cube is accessed and Sales for All Products in the most recent year (using the LastChild MDX command) is reported back into this report. Now, you have the ability to perform more interesting financial calculations such as Contribution to Parent Company's revenues.LookupCube("Sales Reports", ([Products].[All Products], Year].[All Years].LastChild)")
Note that members in the Sales Reports Cube that are not explicitly specified are set to their defaults. Ensure these are appropriate before completing a calculation.
External Table Look-ups are not available in Crystal OLAP syntax—only in MDX and SQL Server Analysis Services.



  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint