MDX G OTCHA ! S …or how to keep your hair dark…
Y OUR S PEAKER Boyan Penev Microsoft MVP: SQL Server for 2011 Expertise SSAS PowerPivot SSRS SSIS etc, etc, etc (you get the point ;) Blog:
Q UICK A GENDA MDX Problems Incorrect Data Models Under-used SSAS functionality Inefficient MDX Detecting Problems Demo (some examples)
MDX P ROBLEMS ( RE : D ATA M ODEL ) Leaf-Level Calculations SUM(DESCENDANTS(,,LEAVES), / ) SCOPE(LEAVES( ); This = / ; END SCOPE; Alternatives ETL, DB Views, DSV: / Demo
Root (All) 2008 Jan /01/2008 … 31/01/2008 Feb /02/2008 … 29/02/2008 … … … … Dec /12/2008 … 31/12/ Jan 2009 Leaves
MDX P ROBLEMS ( RE : D ATA M ODEL ) Date Calculations ParallelPeriod() ClosingPeriod() YTD(), QTD(), MTD() Common Causes Incomplete Date Dimensions (gaps, missing members) Wrong Structure (hierarchies, att rels) Dimensions not marked as Time
2008 Q1 08 Mar 2008 Q2 08 Apr 08 May 08 Jun 08 Q3 08 Jul 08 Aug 08 Q4 08 Oct 08 Nov 08 Dec 08 Closing Period(Q3 08) = Aug 08 ParallelPeriod(Quarter, Apr 08) = Mar 08
MDX P ROBLEMS ( RE : SSAS F UNCTIONALITY ) Semi-Additive Measures in EE Replicating the same behaviour in MDX Many 2 Many Relationships Performing SQL-style JOINs in MDX Measure Expressions Writing them in MDX Note that aggregations are not used with MEs
Fact A Dim1 Dim2 Dim3 Dim4 Fact B Dim1 Dim2 FactA.MeasureA (+-*/) FactB.MeasureB
MDX P ROBLEMS ( RE : I NEFFICIENT MDX) Using IIF instead of SCOPE (> importance in 2005) IIF(a.CurrentMember Is, NULL, ) is the same (functionally) as: SCOPE( ); This = NULL; END SCOPE;
MDX P ROBLEMS ( RE : I NEFFICIENT MDX) Set Operations Filter(..,..CurrentMember.MemberValue < ) is equivalent to: {NULL:...&[ ]} Demo
MDX P ROBLEMS ( RE : I NEFFICIENT MDX) Using VBA/Excel Functions VBA!Format() ~ FORMAT_STRING VBA!DateAdd() =....NextMember, or....PrevMember, or....Lag(n), or....Lead(n) VBA!DateDiff() = {... :... }.Count Demo
MDX P ROBLEMS ( RE : I NEFFICIENT MDX) StrToSet and StrToMember Use sparingly LinkMember, LookupCube Avoid at all costs Filter Often over-used, be cautious
D ETECTING P ROBLEMS Execution Time SQL Server Profiler Excessive number of data requests Touching too many partitions and aggregations Performance Monitor Several SSAS MDX counters Bulk mode evaluation nodes Cell-by-Cell evaluation nodes Number of cells evaluated Memory/CPU Utilisation
Q …and hopefully some A