introduction to mdx 2011 v2011 - online tutorials...
TRANSCRIPT
Introduction to MDX
About Stacia
I have no life.
I never sleep.
I’ll sleep when I’m dead.
I’m ancient.
• BI consultant
• Author/co-author of
10 books about BI
• SQL Server MVP
• 12 years BI, 27 years
IT experience
Blog:
blog.datainspirations.com
Twitter: @StaciaMisner
Course Objectives
• Learn multidimensional concepts
• Develop basic multidimensional expressions
• Write MDX queries
• Create script assignments in a cube
• Implement granular security with MDX
• Learn optimization techniques
Prerequisites
• Basic understanding of relational database technology
• Basic understanding of Analysis Services
• No prior programming or SQL query development experience
is required
Course Outline
• Getting Started with MDX
• Building MDX Queries
• Defining Sets
• Adding Calculations to a Query
• Creating Calculations in a Cube
• MDX Scripting
• Implementing Security with MDX Expressions
• Optimizing MDX Queries
Getting Started with MDX
Module Overview
• Introducing MDX
• Comparing MDX with T-SQL
• Thinking about Multidimensional Space
• Exploring Options for Using MDX
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Introducing MDX
• Multi-Dimensional eXpression
• Expression language
o Centralize business logic in cube
o Analogous to Excel formulas
• Query language
o Retrieve data from a cube
o Analogous to Transact-SQL
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
MDX
• Query cubes for reporting and analysis
o Hyperion Essbase
o SAP Netweaver BI
o SAS OLAP Server
o SQL Server Analysis Services
• Reuse cube components
o Calculated member – formula evaluated at query run-time
o MDX script statement – expressions to override cell values under
specific conditions
o Key performance indicator – collection of formulas related to
comparison of a value to a target
• Modify cube components (Create, Alter, Delete)
Comparing MDX with T-SQL
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Location, Location, Location
• Excel formulas require a cell reference (i.e. location)
• A cell reference on a single sheet uses two dimensions
o Column (letter) and row (number)
o Example: B2
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Location, Location, Location
• Formulas using cells on multiple sheets use three
dimensions
– Sheet (name) and column (letter) and row (number)
– Example: ‘Sales 2008’!B2
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Location, Location, Location
• Four dimensions
– Workbook, sheet, column, and row
– Example: '[Bikes.xlsx]Sales 2008'!$B$2
• Six dimensions
– Drive, folder, workbook, sheet, column, and row
– Example: 'C:\Sales\[Bikes.xlsx]Sales 2008'!$B$2
• Seven dimensions
– Server, drive, folder, workbook, sheet, column, and row
– Example: ‘\\SalesServer\C$\Sales\[Bikes.xlsx]Sales 2008'!$B$2
• Eight dimensions, nine dimensions,…and beyond!
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Transitioning to Tuples: Two Dimensions
Mountain-200 Black
Road-250 Black
Touring-1000 Blue
(Road-250 Black, 2/1/2008)
(Mountain-200 Black, 1/1/2008)
$66,095.71
$83,562.57
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Totals are Cells, Too
Mountain-200 Black
Road-250 Black
Touring-1000 Blue
(Road-250 Black, All Dates)
All Products
$4,831,250.71 $1,350,509.36
(All Products, All Dates)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Tuples in Three Dimensions
$66,095.71
All ProductsSales Amount
Order Quantity
Mountain-200 Black
Road-250 Black
Touring-1000 Blue
(All Products,
2/1/2008,
Order Quantity)
209
(Mountain-200 Black, 1/1/2008, Sales Amount)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Exploring Options for Using MDX
• Cube
o Calculated Members
o MDX Script (calculated cells)
o Actions
o Key Performance Indicators
o Security
• Presentation Layer
o Ad hoc query tools
• Manual: SSMS
• Automatic: BIDS, Excel
o Reports
• Reporting Services
• PerformancePoint Analytic
Reports
o SharePoint Filter Web Parts
o PerformancePoint KPIs and
dashboards
Building MDX Queries
Module Overview
• Understanding the MDX Query Editor
• Building Basic MDX Queries
• Adding Sets to a Query
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Understanding the MDX Query Editor
• Using Object Explorer
• Exploring the Query Editor
• Metadata Pane
• Functions
Using Object Explorer
Connect to a server
View objects
and
metadata
Exploring the Query EditorToolbar buttons for common commands
Tab Groups
Color-coded text
Results and
messages
Metadata Pane: Measures
Measure Groups
Measure
Calculated Measure
Metadata Pane: Dimensions
Dimensions
Hierarchy
Attribute
Metadata Pane: User Hierarchies
User Hierarchies Hierarchy Level
Attribute Hierarchies vs User Hierarchies
• Attribute Hierarchy
o Two-level structure
• ‘All’ level
• Leaf level
o Can use to create ad hoc
hierarchies
• User Hierarchy
o Multi-level structure
• ‘All’ level
• One or more levels
• Might not include leaf
level
o Provides drill-down path
for users and query
optimizations
Metadata Pane: Members
Hierarchy levels
Member
[Product].[Product
Categories].[Category].&[1]
Member: Bikes
Functions
Functions: Set Functions
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Basic Query Syntax: Simplest Query
SELECT
FROM <Cube>
All Products Sales AmountOrder Quantity
Mountain-200 Black
Road-250 Black
Touring-1000 Blue
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Basic Query Syntax: Requesting a Tuple
SELECT
FROM <Cube>
WHERE
(Member1,Member2,...)
All Products Sales AmountOrder Quantity
Mountain-200 Black
Road-250 Black
Touring-1000 Blue
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Referencing a Member
• UniqueName
o [Product].[Product].[Mountain-200 Black, 38]
• Alternatives
o [Product].[Mountain-200 Black, 38]
o Product. [Mountain-200 Black, 38]
o [Mountain-200 Black, 38]
• Precede member with
o Dimension name
o Hierarchy name
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Referencing a Member
• Hierarchical referenceo [Product].[Products].[Product].[Mountain-200 Black, 38]
• Alternately precede member with
o Parent member
o Level name
• Key reference
o [Date].[Date].&[20080101]
Level Name
Key Column
Ampersand precedes key
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Using Brackets in a Member Reference
• Embedded space
o Product.[Mountain Bikes]
• Reserved word
o [Date].&[2008]
• First character is not a letter or underscore
o [Date].Calendar.[2008]
• Does not contain characters other than letters,
underscores, or numbers
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Basic Query Syntax: Single Axis
Select a single measure:
SELECT measure1 ON COLUMNS FROM cube
Select all measures:
SELECT [Measures].Members ON COLUMNS
FROM cube
Set
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Basic Query Syntax: Two Axes
SELECT
measure1 ON COLUMNS,
dimension.Member ON ROWS
FROM cube
SELECT
measure1 ON 0,
dimension.Member ON 1
FROM cube
comma
Axis labels
Alternative labels
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Basic Statement Structure: Two Axes
SELECT
dimension.Member ON ROWS,
measure1 ON COLUMNS
FROM cube
Order of axes doesn’t
matter
But with one axis only, you must use COLUMNS!
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Adding Sets to a Query
• Multiple members from the same dimension and hierarchy
create a set
o List members and enclose in braces
o Single member set doesn’t need braces
• Many MDX functions create a set
SELECT
{measure1, measure2} ON COLUMNS,
dimension.hierarchy.Members ON ROWS
FROM cube
Braces for explicit members
Set functions:
• Members
• Children
• Descendants
• And more…
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
All Products Sales AmountOrder Quantity
Mountain-200 Black
Road-250 Black
Touring-1000 Blue
Basic Query Syntax: Adding Columns
SELECT
<Set> ON COLUMNS
FROM <Cube>
WHERE
(Member1,Member2,...)
(Mountain-200 Black,
1/1/2008,
Sales Amount)
(Mountain-200 Black,
1/1/2008,
Order Quantity)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
All Products Sales AmountOrder Quantity
Mountain-200 Black
Road-250 Black
Touring-1000 Blue
Basic Query Syntax: Adding Rows
SELECT
<Set> ON COLUMNS,
<Set> ON ROWS
FROM <Cube>
WHERE
(Member1,Member2,...)
(All Products,
1/1/2008,
Sales Amount)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Basic Query Syntax: Variations
SELECT
<Set> On Columns
FROM <Cube>
SELECT
<Set> On 0
FROM <Cube>
Is
equivalent
to…
SELECT
<Set> On Columns,
<Set> On Rows,
FROM <Cube>
SELECT
<Set> On 0,
<Set> On 1
FROM <Cube>
Is
equivalent
to…
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Basic Query Syntax: Variations
SELECT
<Set> On Rows
FROM <Cube>
Rows axis cannot stand alone
SELECT
<Set> On 1
FROM <Cube>
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
How to Think about a Query
�
Rows and
columns
evaluated
independently
�
Tuples
constructedfrom
current row member
plus
current column
member
plus
WHERE clause
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
How to Think about a Query
�
Rows and
columns
evaluated
independently
�
Tuples
constructedfrom
current row member
plus
current column
member
plus
WHERE clause
� Empty members removed if NON EMPTY on axis
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Using the Cell Properties Clause
• Include the clause to retrieve formatted value, colors, etc.
• Add the clause at the end of the SELECT statement
SELECT
[Measures].[Sales Amount] On Columns
FROM [Adventure Works]
CELL PROPERTIES Formatted_Value;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Available Cell PropertiesCell Property Description
ACTION_TYPE Bitmask for type of action(s) assigned to cell
BACK_COLOR Bitmask for background color
CELL_ORDINAL Ordinal number of cell in cell set
FONT_FLAGS Bitmask for display for italic, bold, underline or strikeout
FONT_NAME Font name for display of value or formatted value
FONT_SIZE Font size for display of value or formatted value
FORE_COLOR Bitmask for foreground color
FORMAT Equivalent to FORMAT_STRING
FORMAT_STRING String defining format for value
FORMATTED_VALUE String display of value with formatting applied
LANGUAGE Locale to which format_string applies
UPDATEABLE Indicator whether the cell can be updated
VALUE Unformatted value of cell
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Removing Empty Rows or Columns
• Use the NON EMPTY keyword on an axis to eliminate
empty tuples
SELECT
{measure1, measure2} ON COLUMNS,
NON EMPTY dimension.Members ON ROWS
FROM cube
Defining Sets
Module Overview
• Creating Sets with Functions
• Using Functions for Set Operations
• Working with Hierarchical Sets
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Creating a Set with a Function
• Use .Members function to get all members of a level
o Dimension.Hierarchy.Members
o Dimension.Level.Members
• Use .AllMembers function to include calculated members
• Use braces and explicitly include members in a set
SELECT
[Sales Amount] ON 0,
[Product].[Category].Members ON
Rows
FROM [Adventure Works];
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Using Sets in a Query
• On an axis (ON ROWS or ON COLUMNS)
• In the slicer (WHERE)
• As a calculation in query (WITH SET…)
• As a calculation in cube (CREATE SET…)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Using Functions for Set Operations
• Order
• Head (or Tail)
• TopCount (or BottomCount)
• Filter
• Crossjoin (using * operator)
Order([Product].[Product].Members,[Sales Amount],DESC)
Head([Product].[Product].Members,3)
TopCount([Product].[Product].Members,3,[Sales Amount])
Filter([Product].[Product].Members,[Sales Amount]>1000)
[Product].[Category].Members * [Date].[Calendar Year].Members
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Order
Order(Set, Expression, Direction)
• Orders members by specified expression
• Expression can be numeric or string value
• Direction is ascending or descending – ASC, DESC
• Or hierarchical groupings ignored – BASC, DESC
select
{[Measures].[Sales Amount],
[Measures].[Order Quantity]} on columns,
Order(
[Product].[Product].[Product].Members,
[Measures].[Sales Amount], DESC) on rows
from Sales;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Head (Tail)
Head(Set, Integer)
• Filters the set to include only the number specified by
Integer beginning with the first member in set
select
{[Measures].[Sales Amount],
[Measures].[Order Quantity]} on columns,
Head(
[Product].[Product].[Product].Members,
2) on rows
from Sales;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
TopCount (BottomCount)
TopCount(Set, Integer, Measure)
• Orders members by measure in descending order
• Filters the ordered set to include only the number
specified by Integer
SELECT
[Sales Amount] ON 0,
TopCount(
[Product].Members,3,[Sales Amount])
ON ROWS
FROM [Adventure Works];
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
• BottomCount
• TopPercent
• BottomPercent
• TopSum
• BottomSum
Variations of TopCount
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Filter
Filter(Set, Expression)
• Filters the set to include only the members that meet the
specified condition
• Condition can compare string or numeric values
SELECT
[Sales Amount] ON COLUMNS,
Filter(
[Product].Members,[Sales Amount]>1000)
ON ROWS
FROM [Adventure Works];
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
CrossJoin
CrossJoin(Set1, Set2) or Set1 * Set2
• Creates a set of tuples from two sets
• For more than two sets,
• Use nested CrossJoin functions or…
• Use * operator
select
{[Measures].[Sales Amount], [Measures].[Order Quantity]}
on columns,
non empty
Crossjoin(
[Product].[Subcategory].[Subcategory].Members,
[Date].[Calendar].[Year].Members) on rows
from Sales
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Manipulating Sets
• Except
• Generate
• NonEmpty
• Extract
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Except
Except(Set1, Set2)
• Creates a set of members that exist only in the first set
Except(
TopCount([Customer]),10,
([Prior Year Sales]),
TopCount([Customers]),10,
(Current Year Sales])
)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Generate
• Creates a new set by iteratively applying an expression to
a specified set
SELECT
[Sales Amount] ON COLUMNS,
Generate(
[Date].[Calendar].[Calendar Year].Members ,
[Date].[Calendar].CurrentMember *
TopCount(
[Product].[Product Categories].[Product].Members,
3,
[Measures].[Sales Amount])
)
ON ROWS
FROM [Adventure Works];
Generate(Set1, Set2)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Nonempty
NonEmpty(Set, Measure)
• Eliminates members that result in empty tuple with the
specified measure
SELECT
[Sales Amount] ON COLUMNS,
NonEmpty(
[Product].[Product].[Product].Members,
[Sales Amount]) ON ROWS
FROM [Adventure Works];
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Extract
Extract(Set, Dimension.Hierarchy)
• Eliminates members that result in empty tuple with the
specified measure
SELECT
[Sales Amount] ON 0,
Extract(
NonEmpty(
([Product].[Product].Members,
[Sales Territory].[Sales Territories].[Europe],
[Date].[Year].[2004]),
[Sales Amount])
[Product].[Product])
ON ROWS
FROM [Adventure Works];
Defining an Asymmetrical Query
CY 2006 CY 2007
Sales Amount Sales Amount Order Quantity
• Use explicit tuples in sets
• Use same “hierarchality” in each tuple
{([CY 2006],[Sales Amount]),
([CY 2007],[Sales Amount]),
([CY 2007],[Order Quantity])}
Some OLAP browsers don’t
support asymmetrical queries
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Using Functions and Keywords on the Axis
Use this To do this
Hierarchize To force the default dimension sort order
NON EMPTY To eliminate empty rows (or columns)
DIMENSION PROPERTIES
MEMBER_CAPTION
To retrieve captions
SELECT
[Sales Amount] ON COLUMNS,
NON EMPTY Hierarchize(«set»)
DIMENSION PROPERTIES MEMBER_CAPTION
ON ROWS
FROM <cube>
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Working with Hierarchical Sets
• Parent
• Ancestor
• Children
• Descendants
• Siblings
• Other
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Parent
• Returns the member above the current member
All Dates
2009
Q1 2009 Q2 2009
Apr 2009
May 2009
Jun 2009
Q3 2009
July 2009
Aug 2009
Sep 2009
Q4 2009
[July 2009].Parent
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Ancestor
• Returns member above the current member at specified
levelAll Dates
2009
Q1 2009 Q2 2009
Apr 2009
May 2009
Jun 2009
Q3 2009
July 2009
Aug 2009
Sep 2009
Q4 2009
Ancestor([July 2009], [Year])
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Children
• Returns a set of members below the current member
All Dates
2009
Q1 2009 Q2 2009
Apr 2009
May 2009
Jun 2009
Q3 2009
July 2009
Aug 2009
Sep 2009
Q4 2009
[Q3 2009].Children
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Descendants
• Returns a set of members below the current member at
a specified distance or at a specific level
All Dates
2009
Q1 2009 Q2 2009
Apr 2009
May 2009
Jun 2009
Q3 2009
July 2009
Aug 2009
Sep 2009
Q4 2009
Descendants([2009], Month)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Siblings
• Returns a set of members on the same level and with the
same parent as the specified member
All Dates
2009
Q1 2009 Q2 2009
Apr 2009
May 2009
Jun 2009
Q3 2009
July 2009
Aug 2009
Sep 2009
Q4 2009
[July 2009].Siblings
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Other Hierarchical Functions
• Ancestors
• Ascendants
• Cousin
• FirstChild
• FirstSibling
• LastChild
• LastSibling
Adding Calculations to a Query
Module Overview
• Understanding Types of Calculations
• Building Calculated Members
• Exploring More MDX Functions
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Understanding Calculation Behavior
• Calculated Members
o New members added to a hierarchy at run time
• Scripts
o Replace the values that would otherwise be in part of a cube
o Appear to be procedural, but really define state formulas
• All calculations are ‘pull’ not ‘push’
• Results of calculations may be cached, but not persisted
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Types of Calculations: Tuple-Based
• “Pct of Total” Example
([Road-250 Black, 44], [Sales Amount])
/ ([All Products], [Sales Amount])
• Analogous to Excel references: =B4/$B$2
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Types of Calculations: Set-Based
• “YTD Sales” Example
Sum(YTD(), [Measures].[Sales Amount])
• Analogous to Excel ranges: =SUM($B$2:B5)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Building Calculated Members
WITH
MEMBER Measures.myMeasure1 AS expression1
MEMBER Measures.myMeasure2 AS expression2
SELECT
{Measures.myMeasure1, Measures.myMeasure2}
ON COLUMNS,
dimension.Member ON ROWS
FROM cube
WHERE (Members)
Add as many
calculations as you
need in WITH clause
Reference
calculations directly
or indirectly on
columns or rows
or in WHERE clause
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Complete and Partial Tuples
• Complete Tupleo One member from each attribute hierarchy
o Required to retrieve a value
• Partial Tupleo Omits some attribute hierarchies
o May have as few as one attribute hierarchy
• Omitted hierarchies in partial tuple use CurrentMember
• CurrentMember Defined byo Row/column axes
o Slicer definition
o Default member
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Tuples and Regular Cells
• Tuple Comes from Row,
Column, and Filter
([Accessories], [2002],
[A Bike Store], [Jiang,Stephen],[Order Quantity])
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
([Order Quantity])
Tuples and Unspecified Hierarchies
• Unspecified attribute hierarchies use the current member [Order Date].[Calendar Year].
([Reseller Name].CurrentMember,[Sales Person Hierarchy].CurrentMember
[Order Date].[Calendar Year].CurrentMember,[Product Category].CurrentMember,
[Order Quantity])
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Specifying a Member in a Tuple
• Constant
o [Sales Amount]
• Current Member
o Typically omit
• Function operating on Current Member
o [Date].CurrentMember.PrevMember
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Miscellaneous Functions
• Level
o Returns a Level object
• Name
o Returns a String object
o Used to identify the following
• Dimension
• Level
• Member
• Properties
o Returns a String object
Dimension.Hierarchy.Name
Dimension.Hierarchy.Level.Name
Dimension.Hierarchy.Member.Name
Dimension.Hierarchy.Level
Dimension.Hierachy.Member.Properties(“PropertyName”)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Conditional Expressions
IIF (
[Measures].[Sales Amount] = 0
OR
IsEmpty([Measures].[Sales Amount]),
NULL,
[Sales Amount]
/ ([All Products], [Sales Amount])
)
Boolean Expression
TRUE condition
FALSE condition
CASE statements are also valid in MDX
but IIF statements perform better
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Exception Handling
• Test for Empty Cells
o IsEmpty
• Test for Existence of Member
o Is
IsEmpty((Product.Category.Bikes, [Sales Amount]))
Product.Category.CurrentMember IS Product.Category.Bikes
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Building a Named Set
WITH
Set Set1 AS expression
SELECT
Measures.measure1 ON COLUMNS,
Set1 ON ROWS
FROM cube
Time-Series Analysis
• WTD, MTD, QTD, YTD
• ParallelPeriod()
• .PrevMember
• .Lag(n)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Functions for Time-Series Analysis
• PeriodsToDate
• xTD (WTD, MTD, QTD, YTD)
PeriodsToDate([Date].[Calendar].[Year])
All Dates
2010
Q1 2010
Q2 2010
Q3 2010
Q4 2010
{ Q1 2010}
{ Q1 2010, Q2 2010}
{ Q1 2010, Q2 2010, Q3 2010}
{ Q1 2010, Q2 2010, Q3 2010, Q4 2010}
YTD()
PeriodsToDate or YTD results by Date member:
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
xTD
YTD([Date].Member)
• Similar to PeriodsToDate function
• Options: WTD, MTD, QTD, YTD
• Default date member: CurrentMember unless otherwise
specified
• Creates set from first period of year to specified member
SELECT
[Sales Amount] ON COLUMNS,
YTD([July 2009]) ON ROWS
FROM [Adventure Works];
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
YTD with Month Member
All Dates
2009
Q1 2009
Jan 2009
Feb 2009
Mar 2009
Q2 2009
Apr 2009
May 2009
June 2009
Q3 2009
July 2009
Aug 2009
Sep 2009
Q4 2009
Oct 2009
Nov 2009
Dec 2009
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
YTD with Quarter Member
All Dates
2009
Q1 2009
Jan 2009
Feb 2009
Mar 2009
Q2 2009
Apr 2009
May 2009
June 2009
Q3 2009
July 2009
Aug 2009
Sep 2009
Q4 2009
Oct 2009
Nov 2009
Dec 2009
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
ParallelPeriod Function
All Dates
2008
Q1 2008 Q2 2008 Q3 2008
July 2008
Aug 2008
Sep 2008
Q4 2008
2009
Q1 2009 Q2 2009 Q3 2009
July 2009
Aug 2009
Sep 2009
Q4 2009
• Finds corresponding member of common ancestor
• Defaults to base from time current member
• With Level argument, controls common ancestor
• Only meaningful in User hierarchy
ParallelPeriod(
[Date].[Calendar Year].[Year],
1,
[July 2009])
ParallelPeriod(Level, Lag, Date.Member)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
PrevMember Function
• Returns previous member on same level
• Can be used with any hierarchy , but typically used with time hierarchy
• Assumes sequential importance
• Does not require user hierarchy
All Dates
2009
Q1 2009 Q2 2009 Q3 2009
July 2009
Aug 2009
Sep 2009
Q4 2009
Date.Calendar.Member.PrevMember
[Aug 2009].PrevMember
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Lag
• Similar to PrevMember with greater “distance”
• Lag(n)
All Dates
2010
Q1 2010
Q2 2010
Q3 2010
Q4 2010
Q4 2009
Q1 2010
Q2 2010
Q3 2010
PrevMember or Lag(1) results by Date member:
Date.Calendar.Lag(n)
Creating Calculations in a Cube
Module Overview
• Creating Calculated Measures and Custom Members
• Defining Named Sets
• Creating KPIs
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Creating Calculated Measures
New Calculated Member
Minimum definition:
• Name
• Parent hierarchy
• Parent member
(non-measure only)
• Expression
Form View
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Creating Calculated Measures
Additional properties:
• Format string
• Visible
• Associated
measure group
• Display folder
Do not set non-empty behavior property
Optional expressions:
• Fore color
• Back color
• Font name
• Font size
• Font flag
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Creating Calculated Measures
Create Member CurrentCube.[Measures].[Gross Profit Margin]As
([Measures].[Reseller Sales Amount]-[Measures].[Reseller Cost])/[Measures].[Reseller Sales Amount],
FORMAT_STRING = "Percent", FORE_COLOR = iif([Gross Profit Margin] < .10, 255 /*Red*/, 0 /*Black*/), VISIBLE = 1 , DISPLAY_FOLDER = 'Reseller Sales', ASSOCIATED_MEASURE_GROUP = 'Reseller Sales';
Script View
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Creating Custom Members
CREATE MEMBER CURRENTCUBE.[Product].[Category].[All].[Other Products]AS Aggregate(
{[Product].[Category].&[Accessories], [Product].[Category].&[Clothing],[Product].[Category].&[Components]}
), FORMAT_STRING = case when Measures.CurrentMember is Measures.[Gross Profit Margin] then "Percent" when Measures.CurrentMember is Measures.[Reseller Order Quantity] then "#,#" else "Currency" end, VISIBLE = 1, language=1033 ;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Working with Custom Members
Available only in the designated hierarchy
No effect on dimension hierarchy’s aggregate values
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Defining Named Sets
New Named Set
Minimum definition:
• Name
• Expression
• Type
• Dynamic
• Static
Form View
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Defining Named Sets
CREATE DYNAMIC SET CURRENTCUBE.[Top 10 Products]AS
TopCount(
[Product].[Product Name].[Product Name].Members,10,[Measures].[Reseller Sales Amount]
), DISPLAY_FOLDER = 'Product Sets' ;
Script View
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Working with Named Sets
Separate object in metadata tree
Placement in Filter
Pane to view members
in BIDS
selectMeasures.Members on columns,[Top 10 Products] on rowsfrom [Adventure Works DW]
Reference directly in queries
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Creating KPIs
New KPI
What is the value to measure?
What is the target for comparison?
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Creating KPIs
• How close is the value
to the target?
• What image displays
when the value is
close to or far from
the goal?
• How does the value
compare to a previous
period?
• In what direction
should the arrow
point?
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Working with KPIs
Browser View
Set the date context in the Filter Pane
select{KPIValue("Gross Profit Margin"),KPIGoal("Gross Profit Margin"),KPIStatus("Gross Profit Margin"),KPITrend("Gross Profit Margin")}on columns,[Date].[Calendar].[CalendarYear].Members on rowsfrom [Adventure Works DW]
MDX Scripting
Module Overview
• Introducing the MDX Script
• Adding Calculations to the MDX Script
• Debugging an MDX Script
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Introducing the MDX Script
• Overwrite values in cube cells
• Execute multiple MDX statements within a defined scope
• Plan solve order more intuitively
• Use Find and Replace to make changes
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
MDX Script Fundamentals
• Statements
o MDX Scripting statements: CALCULATE, SCOPE, etc.
o CREATE MEMBER
o CREATE SET
o Conditional statements
• Expressions
o Subcube
o Assignment expressions
All statements in an MDX script must be separated by a semicolon
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
MDX Scripting Statement: CALCULATE
• Required statement in MDX script
• Used to populate each higher level cube cell with
aggregated value of lower level cells
• Changes to lower level cell values change the aggregated
value of high level cell
• “Last pass wins”
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
CREATE MEMBER
• Optional propertieso FORMAT_STRING
o LANGUAGE
o SOLVE_ORDER
o VISIBLE
o NON_EMPTY_BEHAVIOR
o FORE_COLOR
o BACK_COLOR
o FONT_NAME
o FONT_SIZE
o FONT_FLAGS
Create Member CurrentCube.[Measures].[Reseller Gross Profit]
As [Measures].[Reseller Sales Amount]
-
[Measures].[Reseller Total Product Cost];
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
CREATE SET
Create Dynamic Set CurrentCube.[Top 5 Products]
As TopCount(
[Product].[Product].Members,
5,
[Measures].[Sales Amount]
);
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Conditional Statements: CASE…WHEN
Create Member CurrentCube.[Measures].[Ratio to Parent Product]
As
Case
When
[Product].[Product Model Categories].CurrentMember.Level.Ordinal
= 0
Then
1
Else
[Measures].[Sales Amount]
/
( [Product].[Product Model Categories].CurrentMember.Parent,
[Measures].[Sales Amount] )
End,
Format_String = "Percent" ;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Subcube
• A subset of cells contained in a cube
• All attribute hierarchies includedo If no members specified, just the All member
o Otherwise, one or more members as follows• A single member
• Some or all members of a single level
• Descendants of a single member
(
[Date].[CalendarYear].&[2005],
[Date].[Calendar].[Fiscal Quarter].Members,
[Measures].[Sales Amount Quota]
)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Assignment Expression
(
[Date].[CalendarYear].&[2005],
[Date].[Calendar].[Fiscal Quarter].Members,
[Measures].[Sales Amount Quota]
) = 800000;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Other MDX Scripting Statements
• SCOPE
• THIS
• FREEZE
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
SCOPE and THIS
• Defines the current subcubeo All MDX expressions apply to subcube
o THIS function is reference to subcube
• Contains additional SCOPE statements as needed to further subdivide a subcube
SCOPE(
[Date].[CalendarYear].&[2005],
[Date].[Calendar].[Fiscal Quarter].Members,
[Measures].[Sales Amount Quota]
);
THIS = 8000000;
END SCOPE;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
FREEZE
• Protects cells from being overwritteno By subsequent expressions
o By aggregations resulting from CALCULATE
Freeze
(
[Date].[Calendar].[Fiscal Quarter].Members,
[Measures].[Sales Amount Quota]
) ;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Allocations with MDX Script
• Scenario
o Sales Quota data provided at quarterly level
o Sales Quota data not available at monthly level
o Sales Quota data not available for Q3 and Q4 2008
• Solution
o Allocate Sales Quota data to months
• Equal allocation for 2005
• Weighted allocation for all other years
o Compute Sales Quota data for 2008 from parallel period
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Equal Allocation
Scope([Measures].[Sales Amount Quota]);Scope (
[Date].[Calendar Year].&[2005],[Date].[Calendar].[Month].Members
) ;
This = [Date].[Calendar].CurrentMember.Parent / 3 ;
End Scope ;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Prepare for Weighted Allocation
Freeze
(
[Date].[Calendar].[Quarter].Members,
[Measures].[Sales Amount Quota]
) ;
Scope
(
[Date].[Calendar Year].&[2007] : Null,
[Date].[Calendar].[Month].Members
) ;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Weight Computation
This =
( ParallelPeriod (
[Date].[Calendar].[CalendarYear], 1,
[Date].[Calendar].CurrentMember
),
[Measures].[Reseller Sales Amount]
)
/
( ParallelPeriod (
[Date].[Calendar].[CalendarYear], 1,
[Date].[Calendar].CurrentMember.Parent
),
[Measures].[Reseller Sales Amount]
) ;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Weight Allocation
This = [Measures].CurrentMember * [Date].[Calendar].Parent ;
End Scope ;
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Compute from Parallel Period
Scope (
[Date].[Calendar Year].&[2008],{[Date].[Quarter].&[2008]&[3], [Date].[Quarter].&[2008]&[4]},[Date].[Calendar].[Quarter].Members
) ;
This = ParallelPeriod(
[Date].[Calendar].[CalendarYear], 1,[Date].[Calendar].CurrentMember
) * 1.35 ;
End Scope ;End Scope;
Implementing Security with MDX Expressions
Module Overview
• Configuring User Access
• Defining Dimension Security
• Configuring Cell-Level Security
• Implementing Dynamic Security
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Configuring User Access
• Data Sources
o Read permission to access underlying data source required
only for specific data mining queries
• Dimensions
o Read permission to access dimension data, inherited by all
cubes that use dimension
• Dimension Data
o Grant (or deny) permission to view specified dimension
members and associated measures
o Use MDX expressions to configure permissions
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Configuring User Access
• Cubeso Grant permission to access cube data, drill through to
underlying data, or access local cube
o Dimension access permissions inherited from dimension, unless overridden
• Cell Datao Grant (or deny) permission to view cell-level data
o Use MDX expressions to configure permissions
• Mining Structures and Mining Modelso Grant permission to access mining structures
o Grant permission to access, browse and drill through mining models
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Defining Dimension Security
• Read or read/write
• Allowed set
• Denied set
• Default member
• Visual totals
Read/write permission at dimension level
requires
Read/write permission at cube level
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Configuring Cell-Level Security
• Read permissions
o Allows user to view measure data
• Read contingent permissions
o Allows user to view calculated measure data if user has
permissions to view base measures
• Read / write permissions
o Allows user to perform write-back operations
Read/write permission at cell level requires
Read/write permission at cube level
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Implementing Dynamic Security
• Create tables
o Users: User ID, UserName
o BridgeDimensionUsers: DimensionID, UserID
• Create dimension in BIDS for Users
• Create measure group in BIDS for BridgeDimensionUsers
• Create Allowed member set on Dimension
NonEmpty(Dimension.Hierarchy.Members(StrToMember(“[Users].[User].[“
+ UserName() + “]”),[Measures].[Bridge Dimension Users Count])
)
Optimizing MDX Queries
Module Overview
• Using SQL Server Profiler to Analyze Queries
• Optimizing Queries for the Formula Engine
• Optimizing Queries for the Storage Engine
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Reviewing Potential Query Bottlenecks
• Network
• Query design
• Dimension design
• Aggregation design
• Linked dimensions or measure groups across servers
• ROLAP
• No partitions
• Remote partitions
• Dimension or cell writeback
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Where Do You Start?
• Eliminate infrastructure bottlenecks
• Resolve resource contention issues
• Identify time required by the storage engine or the
formula engine to run query
• Use results to focus on optimization on query or
database design
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Architecture Overview
Analysis Services Server
Client ApplicationMDX Query
Storage Engine
Formula Engine
Formula Engine Cache
Calculation Engine Subcube Operations
Dimension Data Measure Group Data
Storage Engine
Storage Engine CacheAttribute Store
Hierarchy Store
Aggregations
Fact Data
Compute Cell Data
Populate Axes
Query Parser
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Formula Engine
• Retrieve Data
o Translation of request into subcube requests
• Produce Result Set
o Bulk calculation of subcube(s)….
o OR Cell-by-cell calculation
• Store Results in Cache
o Query Scope
o Session Scope
o Global Scope
Formula Engine Cache
Subcube Operations
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Cell by Cell Computation
Measures.[Sales Amount]
Measures.[Product Contribution]
(Measures.[Sales Amount], Product.[Product Categories].Parent
/
=
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Block Computation Logic
• Known Facts
o A = Product.CurrentMember
o B = Product.Parent
o Only when A is not null, A / B is not null
o B is always constant
o Storage Engine requests return non-null data only
Perform calculation only when:
- numerator values are returned by the Storage Engine- denominator is a constant value
New in SSAS 2008
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Block Computation
Measures.[Sales Amount]
Measures.[Product Contribution]
(Measures.[Sales Amount], Product.[Product Categories].Parent
Step 1: Get non-null values from the Storage Engine
Step 2: Calculate the expression
Step 2: Add null values into the query results
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Storage Engine: Dimensions
Attribute Store
Key Store
DataID Attribute Key Member
Property Store
DataID Attribute Property
Ordered by DataID for fast random access
Key Hash Name Hash
Relationship Store
DataIDs
Bitmap Indexes
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Storage Engine: Dimensions
Hierarchy Store
Set Store
DataID
Structure Store (Parent level)
Level
IndexDataID
Parent
DataID
FirstChild
DataID
Children
Count
Path of each member
Applies only to natural hierarchies
Structure Store (Child level)
Level
IndexDataID
Parent
DataID
FirstChild
DataID
Children
Count
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Storage Engine: Measure Groups
• Storage Engine Cacheo Loads as queries execute
o Clears with cleaner thread or processing of partition
• Aggregation Datao Responds to request with
aggregated values in storage
o Summarizes lower level aggregated values on-the-fly as needed
• Fact Datao Scans MOLAP partitions and
partitions segments in parallel
o Uses bitmap indexes to scan pages to find requested data
Storage Engine
Measure Group Data
Storage Engine
Storage Engine CacheAggregations
Fact Data
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Which Engine is the Bottleneck?
• Time to execute query (cold cache)
o Storage Engine time = add elapsed time for each Query
Subcube event
o Formula Engine = Total execution time (Query End event)
– Storage Engine time
• Bottleneck is engine consuming 30% or more of total
query execution time
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Prepare for Query
Clear Cache
Reload MDX Script (without caching)
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
MDX Query
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Query Results
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Profiler Results Begin
• Query Begin indicates successful query parsing
• Serialize Results Current counts members on
each axis
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Storage Engine Reads Partitions
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Query Subcube Event
• Sum each Query Subcube Event to compute
total Storage Engine query time
• Review TextData for vectors returned to formula
engine…very cryptic
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Query Subcube Verbose Event
• Use Query Subcube Verbose Event to
understand vectors
Subcube Details
Value Result
0 Default member returned
* All members returned
+ Selected members returned
- Slice below granularity returned
4 Single member’s DataID
Subcube Details
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Profiler Results End
• Serialize Results Current reports total number of
cells in query results
• Query End reports total query duration
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Duration Analysis
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Optimizing Calculations
• Applying Conditional Logic Effectively
• Removing Empty Tuples
• Writing Efficient MDX
Applying Conditional Logic Effectively
• Use IIF or CASE statement
o FE calculates cell-by-cell in
calculation space
o Evaluates for each query
o Increases query response
time
• Use Scope Assignment
o FE calculates for range of cells
in calculation space
o Evaluates once
o Optimizes query performance
Best Practice!
Trade-offs between IIF and CASE:
• IIF faster - only two branches
• CASE easier to read than nested IIFs
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
MDX Script
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
MDX Query
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Duration Analysis
• Query down from 64 ms
• FE down from 84%
Removing Empty Tuples
• Set functions return
nonempty and empty tuples
by default
• Elimination of empty tuples
optimizes queries
o Number of rows and/or
columns reduced
o Serialization faster with
nonempty tuples only
Best Practice!
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
What is an Empty Tuple?
• No fact table record for the specified measure and
dimension combination
• Fact table record exists but contains null value for
measure
Tip: Set measure’s NullProcessing property to Preserve else SSAS converts to 0
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
NON EMPTY Keyword
• Removes empty tuples from specified axis
• Fact table data
o Better query performance with sparse data
• Calculated data
o Slower query performance
o Requires evaluation of all cells in query before removing
empty tuples
o Note: Null values are treated as 0 in calculations NULL –
[Sales Amount] is not NULL
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Analysis of NON EMPTY
• Query up from 46 ms
• FE down from 76%
• Query uses calculated
data
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
NonEmpty Function
• NonEmpty function removes empty tuples from specified
set
• Don’t use calculated measure to find empty tuples
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Analysis of NonEmpty Function
• Query up from 46 ms
• FE down from 73%
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Exists Function
• Exists(Set,,”Measure Group”) function excludes tuples
not found in fact data
o Don’t do this
• Filter on member properties
o Do this
• NonEmpty and Exists
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Analysis of Exists Function
• Query up from 61 ms
• FE down from 73%
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Comparison Empty Tuples
0
10
20
30
40
50
60
70
80
90
CASE Statement SCOPE Statement NON EMPTY
keyword
NEB NonEmpty function Exists function
FE
SE
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
MDX Functions to Avoid
• LookupCube
• NonEmptyCrossjoin
• LinkMember
• StrToSet or StrToMember
o Use server-side ADOMD.NET
• StrToValue
o Use .MemberValue
Worst Practice!
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Using Subcubes
SELECT
measure1 ON COLUMNS,
dimension1.Member ON ROWS
FROM
(select dimension2.members ON COLUMNS from
(select dimension3.members ON COLUMNS from
cube))
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Partitioning
• Create multiple partitions to enable optimal scans of fact
data
• Partition by one or more attributes used in many
queries, such as Year
o Number of records per partition
> 2 million and < 20 million
o Partition size
> 50 MB and < 250 MB Best Practice!
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Aggregation Design: Tools
• Aggregation Design Wizard
o View aggregation candidates
o Update member and fact record counts
o Develop and apply aggregation design
• Usage-Based Optimization Wizard
o Capture query sampling in usage log
o Tune aggregation performance to actual usage
• Aggregation Utility (2005) / Aggregation Designer (2008)
o Override aggregation design algorithm
Best Practice!
Good Practice
Leveraging the FE Cache
• Not shared across multiple
sessions
o CREATE MEMBER –
single session scope
o WITH MEMBER –
single query scope
• Shared across multiple
sessions
o MDX Script –
global scope
Copyright © 2007-2011 by Data Inspirations Inc. All rights reserved.
Warming the Cache
• Cache is empty when server starts or partition processes
• Cache warming preloads general queries
o Create a VB.NET or C#.NET application
o Use ascmd.exe
o Add a script task to an Integration Services package
o Execute Reporting Services reports