implementing calculations using mdx. drinks tea lemon earl grey coffee columbian dimension family...

17
Implementing Calculations Using MDX

Upload: margery-quinn

Post on 14-Dec-2015

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Implementing Calculations Using MDX

Page 2: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

Dimension Family Relationships

Drinks is the Parent of Tea and Coffee Drinks is the Parent of Tea and Coffee

Tea and Coffee are Children of Drinks Tea and Coffee are Children of Drinks

Tea and Coffee are Siblings Tea and Coffee are Siblings

Tea and Columbian are Descendants of Drinks

Tea and Columbian are Descendants of Drinks

Tea and Drinks are Ancestors of Earl Grey Tea and Drinks are Ancestors of Earl Grey

Lemon and Columbian are Cousins Lemon and Columbian are Cousins

All are dimension Members All are dimension Members

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

DrinksTea Lemon Earl GreyCoffee Columbian

Page 3: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Comparing to Spreadsheet Formulas

Page 4: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Defining Calculated Members

Can Belong to Any Dimension

Calculate at Query Time

Do Not Impact Cube Size

Are Usually Defined by Stored Members

Can Also Be Defined by

Other calculated members

Arithmetic operators

Numeric constants

MDX functions

Can Make Use of External Function Libraries

Appear as Stored Members to Clients

Page 5: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Every Cell Has a Name

All Product

Bread

Dairy

Meat

UnitsUnitsDollarsDollars

(Bread, USA, Units)(Bread, USA, Units)

([All Product], [All State],Dollars)

([All Product], [All State],Dollars)

(Meat, Mexico,Dollars)

(Meat, Mexico,Dollars)

USA

Cana

da

Mexico

All S

tate

Page 6: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

One Dimension — Single Coordinate

Geometry x=3

0 1 2 3 4 5

Cube [February]

Page 7: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Comma and parentheses

Two Dimensions — Double Coordinate

0

1

2

3

4

5

1 2 3 4 50

01

2345

1 2 3 4 50

([January], [Sphinx Bagels]) Cube

Geometry (x=3, y=4)

Order does not matter

Page 8: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Three Dimensions — Triple Coordinate

(x=4, y=2, z=3)

4

12

31

2

3

0

1

2

3

4

5

45

1 2 3 12

3012345

45

Geometry

([Washington], [January], [Sphinx Bagels])

Washington

Oregon

Cube

Page 9: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Tuple: Multidimensional Coordinate

A Tuple Is a Multidimensional Cell Coordinate At most one member from a dimension Order of members does not matter If more than one dimension

• Separate members with commas• Enclose tuple in parentheses

How Do You Pronounce Tuple? Too-ple (like quadruple) Tup-ple (like quintuple)

Page 10: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Complete and Partial Tuples

Complete Tuple

One member from each dimension Required to retrieve a value

Partial Tuple

Omits some dimensions May have as few as one dimension

Omitted Dimensions in Partial Tuple Use Current Member

Current Member Defined by:

Row/column axes Slicer definition Default member

Page 11: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Tuples and Unspecified Dimensions

Unspecified DimensionsUse the Current Member ([Sales Units])([Sales Units])

(State.CurrentMember,Time.Calendar.CurrentMember,

Product.CurrentMember,[Sales Units])

(State.CurrentMember,Time.Calendar.CurrentMember,

Product.CurrentMember,[Sales Units])

Page 12: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Tuples and Regular Cells

Tuple Comes from Row, Column, and Filter

([All State], [All Time],

[Dairy], [Sales Dollars])

([All State], [All Time],

[Dairy], [Sales Dollars])

Page 13: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Percent of Total Calculations

Sales Dollars Relative %All Product 76,741$ 100%Bread 30,600$ 40% Bagels 3,552$ 5% Muffins 13,081$ 17% Sliced Bread 13,967$ 18%Dairy 32,533$ 42%Meat 13,607$ 18%

Page 14: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Creating Non-Measure Calculated Members

Common Applications

Calculate the difference between two members Calculate the average of multiple members Create rollups outside of the normal hierarchy

Aggregation Behavior

Do not roll up in the parent dimension Do not affect or add to cube aggregations

Calculated Member Intersections

Intersect with every member of every other dimension

Page 15: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Using Functions within Calculated Members

Used for Complex Calculations

Included in the Calculated Member Builder

Located in Specific Folders

Page 16: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Understanding Other Calculation Methods

Custom Rollup Formulas

Override the Aggregate Function properties across a dimension level

Apply to all members of a level

Custom Member Formulas

Replace the definition of a single member without affecting other members

Enable members to aggregate with the other dimension members

Calculated Cells

Supply data values to existing cube cells based on MDX logic

Allow for specific calculation scope and logic

Page 17: Implementing Calculations Using MDX. Drinks Tea Lemon Earl Grey Coffee Columbian Dimension Family Relationships  Drinks is the Parent of Tea and Coffee

Introducing Solve Order

Meat

Sales $ / Units

UnitsSales $

Bread

Dairy + Meat

Dairy

4.00

400 150 2.67

0.67100

100

300 75

150

75 1.33

Meat

Sales $ / Units

UnitsSales $

Bread

Dairy + Meat

Dairy

400 150 5.33

100

100

300 75

150

75

4.00

0.67

1.33