Because the State dimension did not exist in the Sales Budget cube, the only possible value in the virtual cube is the non-subdivided All level value?. Allocating Values from a Grand Tot
Trang 1Contents
Overview 1
Allocating Values from a Grand Total 2
Lab A: Allocating Values from a Grand Total 6
Allocating Values from a Subtotal 10
Lab B: Allocating Values from a Subtotal 16
Allocating Values Across Multiple Dimensions22
Lab C: Allocating Values Across Multiple
Dimensions 30
Review 35
Module 8: Case Study—Implementing Budget Allocations
Trang 2products, people, characters, and/or data mentioned herein are fictitious and are in no way intended
to represent any real individual, company, product, or event, unless otherwise noted Complying with all applicable copyright laws is the responsibility of the user No part of this document may
be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without the express written permission of Microsoft Corporation If, however, your only means of access is electronic, permission to print one copy is hereby granted
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property
2000 Microsoft Corporation All rights reserved
Microsoft, BackOffice, MS-DOS, Windows, Windows NT, <plus other appropriate product
names or titles Replace this example list with list of trademarks provided by copy editor Microsoft is listed first, followed by all other Microsoft trademarks in alphabetical order > are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A and/or other countries
Content developed by OLAP Train, Inc for Microsoft Corporation and distributed under license The names of companies, products, people, characters, and/or data mentioned herein are fictitious and are in no way intended to represent any real individual, company, product, or event, unless otherwise noted
Other product and company names mentioned herein may be the trademarks of their respective owners
Trang 3Instructor Notes
This module is a case study where you and the students will work through a single, complex project In the course of the module, students apply many concepts and specific multidimensional expressions (MDX) functions they have learned in previous modules
The assignment is to allocate Budget Units based on Actual Units Analysts in
a fictional company have already entered Budget Units values at a high level into a Sales Budget cube In the Market database, the Sales Actual and Budget cubes have been joined in a virtual cube named Actual and Budget The student’s job is to allocate the Budget Units in the new Actual and Budget virtual cube to the lowest levels of all the dimensions based on the patterns of Actual Units that are contained in the same cube Actual Units reflect historical sales patterns Allocating Budget Units to lower levels based
on historical sales patterns is a typical budget methodology
In addition to allocating budgets to lower levels, students will also create expressions that roll up—or aggregate—the lower-level budgeted units back to higher levels
After completing this module, students will be able to:
! Allocate values from a grand total across a dimension
! Allocate values from an intermediate level across a dimension
! Create a calculated member that allocates values across three dimensions
Materials and Preparation
This section provides you with the required materials and preparation tasks that are needed to teach this module
Required Materials
To teach this module, you need the following materials:
! Microsoft® PowerPoint® file 2093A_08.ppt
Preparation Tasks
To prepare for this module, you should:
! Read all of the materials for this module
! Read the instructor notes and margin notes
! Practice the lecture and demonstration
! Complete the labs
! Review the Teacher Preparation materials on the Teacher Preparation compact disc
Presentation:
80 Minutes
Labs:
120 Minutes
Trang 4Instructor Setup for Group Activities and Labs
This section provides setup instructions that are required to prepare the instructor computer or classroom configuration for group activities and labs All group activities and labs use the same database setup, which requires restoring a database archive
! To prepare for group activities and labs
In this procedure, you restore the Market database, which is a cab file type
1 Start Analysis Manager
2 In the left pane, expand the Analysis Services folder
3 Expand the Server icon and verify that the Market database does not exist
4 Right-click the Server icon, and then click Restore Database
5 Navigate to the C:\Moc\2093A\Batches folder
6 Select Market.cab, click Open, and then click Restore
If the Market database already exists from a previous group exercise or lab,
and cubes within the database contain extraneous information, you can return
the Market database and its cubes to a beginning position by either:
Deleting any calculated members that were created in a specific cube, and then saving the cube
- or - Repeating the preceding restore database procedure
Trang 51 When you allocate a budget, are the allocated values stored in the cube?
No As with all calculated members, the allocations are calculated only for cells that actually appear in a browser or a report Any cells that are not displayed are not allocated
2 If the Sales Budget cube does not even contain a State dimension, where did the All State values come from in the Actual and Budget cube?
If you think of a dimension as subdividing a value, then the All level for
a dimension is the same as not having the dimension at all Because the State dimension did not exist in the Sales Budget cube, the only possible value in the virtual cube is the non-subdivided All level value
3 The query samples show one member each from multiple levels on the Rows axis Is it possible to get that effect by using the Microsoft Office PivotTable® list?
Yes Move a dimension to the Rows axis and display all the levels Click the drop-down arrow next to the button for the top level Clear the check boxes for all the members you do not want to see The Office PivotTable list requires one column for each level, even if there is only one member in each column, and you must explicitly hide each member you don’t want to see
4 Why does the expression Ancestor(Product,Category) work? Doesn’t the
Ancestor function require a member for the first argument?
The CurrentMember function is the default function for a dimension If
a member is needed and you enter a dimension, the CurrentMember function is assumed
5 Why do you need to use the Crossjoin function when aggregating more
than two dimensions? Why cannot you just sum the values from the two sets?
The Sum function—as with essentially all aggregation functions— allows you to enter a single set You can think of it as a query with a single axis If you need to summarize detail values that are calculated at the intersection of two or more dimensions, you must combine the sets from those dimensions into a single set, which is what the Crossjoin function does
6 What is the difference between the CoalesceEmpty function and the combination of IIF and IsEmpty functions?
You could replace CoalesceEmpty with a combination of IIF and IsEmpty The CoalesceEmpty function avoids the need to duplicate the value expression, and it also allows you to combine a series of tests in a single function
Trang 6Module Strategy
This module is one extended case study project, broken into three steps Each step is a section, and each section becomes more complex The final calculated member is extremely complex
Major sections of this module begin with a group activity followed by a lab The following are guidelines for delivering materials in the context of group activities:
! Using group activities to introduce new content You often introduce new concepts or functionality while delivering the procedures within a group activity as a live demonstration For example, you may present a new MDX function by showing first its construction and then its result set as an actual calculated member formula or within a query statement
Use the topic slides that follow the group activity as a review of the content—for example, the syntax of a specific function
! Interaction with students
A group activity flows best when you deliver it as a shared exploration Ask students such questions as: “What would happen if we…?” “Why did this happen?” “Was that what you expected?” Encourage students to ask you questions about the functions being tested
! Discouraging students from following along Because of the complexity of the issues and the challenging nature of the labs that immediately follow the group activities in this module, it is recommended that students do not follow along with the instructor in the group activities in this module Encourage students to focus on the content and structures you are building in the demonstration
! Lab replication of group activity The exercises in the labs closely follow the group activity procedures but do not define each step or show the code answer Encourage students to write and test the MDX expressions on their own, referring back to the group activity procedures for clarification Students may also refer to answer files, which are available for each procedure in an exercise
! Answer files for group activities Where applicable, answer files are provided for each procedure in a group activity If necessary to facilitate your demonstration, copy and paste the correct expression from the answer file into the Calculated Member Builder
Trang 7Use the following additional strategies to present this module:
! Allocating Values from a Grand Total
Explain to students that they will be allocating Budget Units, which exist at the grand total level, to Actual Units, which exist in the cube at the lowest
levels of detail Describe the two-part process that accomplishes this: first create allocation ratios and then multiply the grand total values by the allocation ratios to create detailed values
! Allocating Values from a Subtotal Tell students that this section is an extension of the previous section—
Product, another dimension, is being added to the allocation process Explain that budgets for Product are entered at an intermediate level,
thereby complicating the allocation process Describe the process that
allows them to allocate based on a subtotal—first use the Ancestor function
to find the subtotal to allocate, allocate to lower levels—as in the previous
section—and then aggregate to the higher levels by using the Sum function
in conjunction with the Descendants function
! Allocating Values Across Multiple Dimensions Explain to students that in this section, they will build on the calculated member that they created in the previous sections to now include a third
dimension—the Time.Calendar dimension Explain that to include more than one dimension in the set for a Sum function, they will use the Crossjoin function to join the sets from the individual dimensions Finish
by telling students that they will also use the CoalesceEmpty function to
determine whether they actually need to calculate a cell
Trang 9Overview
! Allocating Values from a Grand Total
! Allocating Values from a Subtotal
! Allocating Values Across Multiple Dimensions
This module is a case study in which you and the instructor will work through a single, complex project In the course of the module, you apply many concepts and specific multidimensional expressions (MDX) functions that you have learned in previous modules
The assignment is to allocate Budget Units based on Actual Units Analysts in
a fictional company have already entered Budget Units values at a high level into a Sales Budget cube In the Market database, the Sales Actual and Budget cubes have been joined in a virtual cube named Actual and Budget Your job is to allocate the Budget Units in the new Actual and Budget virtual cube to the lowest levels of all the dimensions based on the patterns of Actual Units that are contained in the same cube Actual Units reflect historical sales patterns Allocating Budget Units to lower levels based on historical sales
patterns is a typical budget methodology
In addition to allocating budgets to lower levels, you will also create expressions that roll up—or aggregate—the lower-level budgeted units back to higher levels
After completing this module, you will be able to:
! Allocate values from a grand total across a dimension
! Allocate values from an intermediate level across a dimension
! Create a calculated member that allocates values across three dimensions
This module is a case study
in which you and the
instructor will work through a
single, complex project
Trang 10Allocating Values from a Grand Total
! Start with Existing Values
# Actual units at all levels
# Budget units at total level
! Calculate Allocation
# Allocation ratio—current actual divided by total actual
# Allocated budget units—total budget multiplied by allocation ratio
In this section, you will carry out the task of allocating values entered at a total level
Start with Existing Values
In the Actual and Budget virtual cube, Actual Units exist at all levels of the State dimension Budget Units, however, exist only at the total, or All State,
level
When you create new values by using an allocation process, you need to have
an allocation basis—that is, some frame of reference that can be used to define
how the allocation process should work In this case, the allocation basis Actual Units The relative quantity of Actual Units at the lowest levels serves as the basis for allocating Budget Units down to the lowest levels of the State
dimension
Calculate Allocation
The specific formula for each cell of the allocated budget consists of two steps:
! Divide the Actual Units for the current member of the State dimension by the Actual Units value for All State to create a series of allocation ratios
This ratio is a percentage of total calculation, which you learned in a previous module
! Multiply the allocation ratio for the current member of the State dimension
by the Budget Units value for All State to create the allocated budget
Topic Objective
To define, conceptually, how
the allocation formula is
constructed
Lead-in
Now you will learn how to
allocate values at a higher
level to values at the detail
level
Delivery Tip
This slide topic sets
important foundations for
the following group activity
Review the concepts and
procedures carefully and
check that students
understand
Trang 11Group Activity: Allocating Values from a Grand Total
In this group activity, it is recommended that you do not follow along on your own computer Instead, focus on the instructor demonstration and discussion of the allocation process You will have the opportunity to replicate the allocation algorithms in the lab that immediately follows this group activity
You will learn how to create a calculated member that allocates budget values
to the members of a new dimension
! To prepare a query for testing a simple allocation
In this procedure, you run a query suitable for testing a calculated member that allocates a budget values across an entire dimension
1 In Microsoft® Windows® Explorer, navigate to the C:\Moc\2093A\Labfiles folder
2 Double-click the MDX2093A.exe application, and then click OK to accept
the server and provider
3 In the Open window, navigate to C:\Moc\2093A\Labfiles\L08, and then
open the Allocation.MDX query file
Topic Objective
To learn how to allocate
values from a grand total
over an entire dimension
Lead-in
In this group activity, you will
see how to create a
calculated member that
allocates values to the
members of a new
dimension
Trang 124 In the MDX Builder, in the DB list select the Market database, and then in the Cube list select the Actual and Budget cube The initial query, Grand
Total Allocation, looks like this:
WITH MEMBER Measures.[Allocated Budget] as ‘Null’
SELECT {[Actual Units], [Budget Units], [Allocated Budget]}
ON COLUMNS, { [All State] , [USA] , [North West], [Washington]}
ON ROWS FROM [Actual AND Budget]
5 Run the query
On the Columns axis, the result set shows the Actual Units and Budget
Units measures, which are stored in the Actual And Budget virtual cube,
along with the empty Allocated Budget measure, which is defined as part of the query
On the Rows axis, the result set shows one member from each level of the
State dimension When analysts entered the original data, they did not break out the budget along the State dimension Therefore, the Budget Units measure shows a total only for the All State member
! To display a ratio suitable for calculating an allocation
In this procedure, you learn how to create a ratio that can calculate an allocation
You want to allocate the total Budget Units across the various members of the State dimension by using the same ratio as is in the Actual Units member To calculate the proper ratio, you must divide the Actual Units value of the current member of the State dimension by the Actual Units value of the All State member
1 Change the expression for the Allocated Budget member to [Actual Units]/([Actual Units],[All State]) The final query looks like this:
WITH MEMBER Measures.[Allocated Budget] as '[Actual Units]/([Actual Units],[All State])'
SELECT {[Actual Units], [Budget Units], [Allocated Budget]}
ON COLUMNS, {[All State] , [USA] , [North West], [Washington]}
ON ROWS FROM [Actual AND Budget]
for this procedure
Ask students why you do
not need a member from the
State dimension in the
numerator tuple
Because you want the
current member, and
CurrentMember is the
default for each unspecified
dimension
Trang 132 Run the query
In the Allocated Budget column, the result set shows the percent each state contributes to the total for Actual Units
! To allocate a budget over an entire dimension
In this procedure, you allocate the Budget Units value across members at all levels of the State dimension
You now need to simply multiply the ratio by the total Budget Units You want the Budget Units for the All State member, not for the current member, so you must explicitly include All State in the tuple, as with the tuple already in the
denominator
1 At the beginning of the expression for the Allocated Budget member, insert
([Budget Units],[All State]) * The final query looks like this:
WITH MEMBER Measures.[Allocated Budget] AS '([Budget Units],[All State]) * [Actual Units] / ([Actual Units],[All State])'
SELECT {[Actual Units], [Budget Units], [Allocated Budget]}
ON COLUMNS, {[All State] , [USA] , [North West], [Washington]}
ON ROWS FROM [Actual AND Budget]
2 Run the query
The Allocated Budget column now shows the allocated budget value By
using the MDX2093A application, you can quickly see the result of the member over all levels of the dimension
Trang 14Lab A: Allocating Values from a Grand Total
Objectives
After completing this lab, you will be able to:
! Divide a base value into the total to create a ratio
! Multiply the ratio by a new total to allocate values
Prerequisites
Before working on this lab, you must have successfully completed modules 1
through 7 in course 2093A, Implementing Business Logic with MDX in
In this lab, you will create a
calculated member that
allocates values to each
level of a dimension
Explain the lab objectives
Trang 15Exercise 1
Creating an Allocation Calculated Member
In this exercise, you will create an MDX query that shows sample members from multiple levels of the State dimension on the Rows axis You will then build an Allocated Budget calculated member to allocate the All State values to each level of the dimension
As you complete each procedure, compare the result as shown in the procedure screen shot to the result on your own computer If there is a difference, recheck your entry and refer back to the related group activity procedures as necessary
If you still cannot reconcile your result, then refer to the answer file, which is located in:
C:\MOC\2093A\Labfiles\L08\Answers You can copy and paste expressions from this file into the MDX2093A
application for any given procedure
! To display a ratio suitable for calculating an allocation
In this procedure, you create an allocation ratio as the expression for the Allocated Budget calculated member OneRatio.txt is a completed MDX expression used in this procedure
1 In Windows Explorer, navigate to the C:\Moc\2093A\Labfiles folder
2 Double-click the MDX2093A.exe application, and then click OK to accept
the server and provider
3 In the Open window, navigate C:\Moc\2093A\Labfiles\L08, and then open
the LabA.MDX query file
4 In the MDX Builder, in the DB list select the Market database, and then in the Cube list select the Actual and Budget cube
5 Change the expression for the Allocated Budget member to create a ratio that shows the percent each state contributes to the total
What MDX expression did you use?
WITH MEMBER Measures.[Allocated Budget] AS '[Actual Units]/([Actual Units],[All State])' SELECT
{[Actual Units], [Budget Units], [Allocated Budget]}
ON COLUMNS, { [All State] , [USA] , [South West], [California]}
ON ROWS FROM [Actual AND Budget]
Delivery Tip
The procedures in this
exercise essentially
replicate the previous group
activities but without the
answers
Students having difficulty
with the procedures should
first refer back to the group
activity procedures and then
go to the answer file for
guidance
Trang 166 Run the query, and then verify that the result grid appears similar to the following table
7 Why do you not need a member of the State dimension in the numerator tuple? Why do you need Actual Units in both the numerator and the
denominator tuples?
In the numerator tuple, the State dimension uses the current member, which can be omitted from a tuple The Actual Units member is not the current member of the Measures dimension for either tuple
! To allocate Budget Units across the dimension
In this procedure, you change the expression for the Allocated Budget member
so that Budget Units are distributed among all the states OneAllocate.txt is a completed MDX expression used in this procedure
1 Change the expression for the Allocated Budget member to allocate the Budget Units among all the states, based on the Actual Units contribution What MDX expression did you use?
WITH MEMBER Measures.[Allocated Budget] AS '([Budget Units],[All State]) * [Actual Units]/([Actual Units],[All State])'
SELECT {[Actual Units], [Budget Units], [Allocated Budget]}
ON COLUMNS, { [All State] , [USA] , [South West], [California]}
ON ROWS FROM [Actual AND Budget]
Trang 17
Run the query, and then verify that the result grid appears similar to the following table
Trang 18Allocating Values from a Subtotal
! Start with Existing Values
# Actual units at all levels
# Budget units at subtotal (product category) level
! Calculate Allocation
# Use the Ancestor function to find the appropriate level
to allocate
# Use the Descendants function to aggregate missing
higher level values
When the value to be allocated is not at the top of the dimension, the allocation process becomes more complicated
In this section, you will extend the Allocated Budget calculated member from the preceding section to include the Product dimension Across the Product dimension, the analysts entered budgets at the Category level
Start with Existing Values
In the Actual and Budget virtual cube, Actual Units exist at all levels of the Product dimension Budget Units, however, exist only at the Category level
and above
If you allocate based on the All Product member—by analogy with the technique used for the State dimension—you will get the wrong value The allocation ratio must work against the lowest level of the Product dimension where Budget Units exist
Calculate Allocation
The specific formula for each cell of the allocated budget consists of two steps:
! Use the Ancestor function to find the appropriate subtotal to allocate
! After allocating to the lower levels, aggregate the higher levels from the
lower levels by using the Sum function in conjunction with the Descendants function
Topic Objective
To explain how to allocate
values from a subtotal
Lead-in
When the value to be
allocated is not at the top of
the dimension, the allocation
process becomes more
complicated
Delivery Tip
This slide topic sets
important foundations for
the following group activity
Review the concepts and
procedures carefully and
check that students
understand
Trang 19Group Activity: Allocating Values from a Subtotal
In this group activity, it is recommended that you do not follow along on your own computer Instead, focus on the instructor demonstration and discussion of the allocation process You will have the opportunity to replicate the allocation algorithms in the lab that immediately follows this group activity
You will learn how to create a calculated member that allocates Budget values
over two dimensions—where one of the dimensions allocates against a subtotal
Topic Objective
To learn how to create a
calculated member that
allocates values from a
subtotal
Lead-in
In this group activity, you will
learn how to allocate values
from a subtotal
Trang 20! To prepare a query for testing the allocation of a subtotal
In this procedure, you run a query suitable for testing a calculated member that allocates a budget as a percentage of a subtotal
The Sales and Budget cube contains a Product dimension The analysts created a budget for the Product dimension, but data was entered only at the
category level—that is, there are no budgets for subcategories or individual products
1 In the MDX2093A.exe application, in C:\MOC\2092A\Labfiles\L08, open
the file Allocation.mdx., and then in the Query list, select Subtotal Allocation The initial query looks like this:
WITH MEMBER Measures.[Allocated Budget] as ‘([Budget Units],[All State]) * [Actual Units]/([Actual Units],[All State])’
SELECT Measures.AllMembers ON COLUMNS, Crossjoin(
{ [All State], [USA], [North West]}, {[All Product], [Bread], [Bagels], [Colony Bagels]} ) ON ROWS
FROM [Actual AND Budget]
2 Run the query
By adding a Crossjoin function to the Rows axis, you can see the Product and the State dimensions side-by-side Members from the State dimension are still visible, but selected members of the Product dimension also
appear, crossjoined with the states This allows you to see the interaction of the two dimensions
You can see that on the Product dimension, analysts created a budget at the Category level but not at the Subcategory of Product Name levels The Allocated Units calculated member allocates the budget down to the Country and Region level—notice the values in the Allocated Budget
column that do not appear in the Budget Units—but there is no allocation
across the Product dimension
Trang 21! To allocate a budget across the entire Product dimension
In this procedure, you learn what happens if you allocate a budget value across
the entire Product dimension
The Product dimension is not included in the calculated member, so each tuple uses the current member of the Product dimension In the same tuples that include the All State member, you can include the All Product member
1 Insert a comma and [All Product] at the end of each tuple in the expression for the Allocated Budget member The final query looks like this:
WITH MEMBER Measures.[Allocated Budget] as ‘([Budget Units],[All State],[All Product]) * [Actual Units]/
([Actual Units],[All State],[All Product])’
SELECT Measures.AllMembers ON COLUMNS, Crossjoin(
{ [All State], [USA], [North West]}, {[All Product], [Bread], [Bagels], [Colony Bagels]} ) ON ROWS
FROM [Actual AND Budget]
2 Run the query
The Allocated Budget column now shows a value for each level of the Product dimension as well as for each level of the State dimension The
numbers, however, are incorrect
The Budget Units value for the Bread category is 15,000 The analysts explicitly entered this number The Allocated Units for the Bread category,
however, is more than 20,000 units The analysts clearly planned that other categories would grow faster than Bread
Delivery Tip
ProdDimD.txt in
C:\MOC\2093A\D08\Answers
contains the completed MDX
expression for this procedure
Ask students why the
numbers are not correct
They do not take into
consideration the Category
level budget
Trang 22! To allocate Budget Units at the Category level
In this procedure, you allocate budget units based on a subtotal value
The task is to allocate over the products based not on the All Product total, but based on the category for each product The category changes from product to
product You can use the Ancestor function to give you the appropriate
category for each product
1 In both tuples of the Allocated Budget member, replace [All product] with
Ancestor(Product,Category) The final query looks like this:
WITH MEMBER Measures.[Allocated Budget] AS '([Budget Units],[All State],
Ancestor(Product,Category)) * [Actual Units]/
([Actual Units],[All State], Ancestor(Product,Category))' SELECT
Measures.AllMembers ON COLUMNS, Crossjoin(
{ [All State] , [USA] , [North West]}, {[All Product] , [Bread] , [Bagels] , [Colony Bagels]} ) ON ROWS
FROM [Actual AND Budget]
2 Run the query
The Allocated Budget column now properly allocates the category budget down to the products in that category Unfortunately, the All Product value is
left out of the calculation
! To allocate a correct budget over the Product dimension
In this procedure, you allocate the Budget Units value across members at all levels of the State dimension
In order to get the correct All Product total for each State, you must aggregate
it from lower-level values The correct value exists at the Product Name level,
so for any member of the product dimension, you can sum all the descendants
Delivery Tip
WithAllProdD.txt in
C:\MOC\2093A\D08\Answers
contains the completed MDX
expression for this procedure
Ask students how you might
get the All Product total
Some might suggest that
you can get it from the
Budget Units column—but
that is true only for the All
level, not for the other
levels
Delivery Tip
WithProdDimD.txt in
C:\MOC\2093A\D08\Answers
contains the completed MDX
expression for this procedure