Вы находитесь на странице: 1из 22

Module: Multidimensional Model: Advanced Features Lab

IMPORTANT: You must log on to your computer using an administrator account in order to
successfully complete the labs in this module.

Lab A: Calculations and KPIs


Approximate duration: 90 minutes

In this lab, you will add calculations and KPIs to the Simple Sales cube, enabling
business users to view the combined sales for Internet and reseller sales, and the
ratio of sales of a particular product to all sales as well as to its parent. You will
also define a named set, enabling business users to easily view sales data with
respect only to core products. You will also design KPIs to quickly review and
analyze how Internet and reseller sales compare to specific goals. You will add a
distinct count measure, a calculation, and a KPI to enable business users to quickly
review the growth in the number of Internet customers.

If you did not complete Lab E in the previous module, use the Simple Sales
solution in the C:\SSAS\SSAS Dev Labs\SSAS Lab 4e\Completed folder for the
tasks in this lab.

Exercise 1
Defining an Assignment That Allocates the Sales Amount Quota to the Month
Level

In this exercise, you will define an assignment that allocates the Sales Amount
Quota value from the Calendar Quarter level equally to each month within the
quarter.

Define the assignment

1. Switch to the Calculations tab in the Simple Sales cube designer.


2. Add a SCOPE statement that limits the scope of the cube to the members of
the Month level and the Sales Amount Quota measure. To accomplish this
task, perform the following steps:
a. Click Script View ( ) on the toolbar. Note that there is a semicolon
after the word CALCULATE.
b. On a new line, type SCOPE ( )
c. Limit the scope of the cube to the members of the Month level in the
Calendar hierarchy by adding the following code in the parentheses:
[Order Date].[Calendar].[Month].members

© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features

d. Further limit the scope to the Sales Amount Quota measure by


adding the following code in the parentheses after the previous
statement:

[Measures].[Sales Amount Quota]

e. Separate the two SCOPE arguments with a comma.


f. Type a semicolon after the SCOPE statement. At this point, the code
should look like this:

g. Use a THIS statement to assign to each member within the scope a


value equal to 1/3 of the value of its parent. To accomplish this task,
add the following statement on a new line:

THIS = [Order Date].[Calendar].CurrentMember.Parent/3;

The completed code is shown below.

Debug the assignment statement

3. Set a breakpoint on the assignment statement (i.e., the THIS statement), as


the following screenshot shows.

To set a breakpoint, click in the left margin next to the statement where you
want the execution to stop.

© 2012 SolidQ
Module: Multidimensional Model: Advanced Features Lab

4. Start the debugger.

To start the debugger, press F5 on the keyboard or Start Debugging on the


toolbar or the Debug menu.

A pivot table pane appears in the bottom portion of the Calculations tab, as
shown below. Notice that the script execution stops before executing the
assignment statement.

5. Enter the following MDX query on the MDX1 tab:

select {[Order Date].[Calendar].[Calendar Quarter].&[2007]&[4],[Order


Date].[Calendar].[Calendar Quarter].&[2007]&[4].children} on
rows,[Measures].[Sales Amount Quota] on columns from [Simple Sales]

© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features

6. Run the query. Notice that the allocation to each month within the fourth quarter of
2007 has not yet occurred, as shown below.

7. Continue debugging to execute the assignment statement.

To continue while in debug mode, press F10 on the keyboard or click Step Over on
the toolbar or the Debug menu.

Notice that the allocation now occurs, as shown below.

8. Stop debugging and remove the breakpoint.

To stop debugging, press Shift+F5 on the keyboard or click Stop Debugging on the
toolbar or the Debug menu.

Exercise 2
Defining a Calculated Measure and Compare with Measure Based on Named
Query

In this exercise, you will define a calculated measure based on the Internet Sales
Amount and Reseller Sales Amount measures. You will also create a physical
measure based on a named query that combines the sales amount values from
the InternetSales and ResellerSales tables. You will then compare these two newly
defined measures.

© 2012 SolidQ
Module: Multidimensional Model: Advanced Features Lab

Define the Total Sales Amount calculated measure

1. Open (or switch to) the Calculations tab in the Simple Sales cube designer.
2. Click Form View ( ) on the toolbar and select the last command in the
Script Organizer pane.

3. Click New Calculated Member ( ) on the toolbar.


4. Define a Total Sales Amount calculated measure using the following
information:

Property Value

Name [Total Sales Amount]


Parent hierarchy Measures
Expression [Measures].[Internet Sales Amount] +
[Measures].[Reseller Sales Amount]
Format String Currency
Visible True
Non-empty behavior Internet Sales Amount, Reseller Sales Amount

Note that the benefit of non-empty behavior has diminished in SSAS 2008.
When completed, your form should look like the one below.

Is this calculation performed during querying or during processing?

© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features

Define the Sales Amount physical measure based a named query

5. Switch to the Simple Sales data source view designer.


6. Define a new diagram called Sales Summary.
7. In the Sales Summary diagram, define a named query called Sales Summary.
In the SQL pane at the bottom of the designer, paste the code found in the
SalesSummary.txt file in the C:\SSAS\SSAS Dev Labs\SSAS Lab 5a folder.

To begin defining a named query, click New Named Query in the context
menu of the diagram pane or on the Data Source View menu. This will bring
up the Create Named Query dialog box shown below.

8. Click Run to review the results from this query and then save this named
query.
9. Switch to the Cube Structure tab in the Simple Sales cube designer and then
define a new measure based on the Sales Amount column in the Sales
Summary table.

© 2012 SolidQ
Module: Multidimensional Model: Advanced Features Lab

To accomplish this task, click Show All Tables and then drag the Sales
Amount column from the Sales Summary table into the Measures pane, as
shown below.

Why does a red squiggly line appear under the Sales Summary measure
group?

How can you resolve this error?

10. Specify Currency as the value for the FormatString property for the Sales
Amount measure.
11. Switch to the Dimension Usage tab. Notice the red squiggly line appears
here as well.
12. Define regular relationships between the Sales Summary measure group and
the Product and Order Date cube dimensions, specifying the key attribute
for each cube dimension as the granularity attribute, as shown in the
following screenshot.

© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features

13. Click the Cube Structure tab, click the key column, and define a new
database dimension called Sales Channel based on the Sales Channel
column in the Sales Summary table. (Define only this single attribute as the
key column and define no other dimension attributes.) Specify Sales
Channel as the dimension name.
14. Add the new Sales Channel dimension as a cube dimension by right-clicking
in the Dimensions pane and adding a cube dimension.
15. Return to the Dimension Usage tab and verify that the Sales Channel
dimension is now related to the Sales Summary measure group, as shown
below.

© 2012 SolidQ
Module: Multidimensional Model: Advanced Features Lab

Compare the Total Sales Amount and Sales Amount measures

16. Deploy the Simple Sales cube.


17. Switch to the Browser tab, reconnect, and then click the Analyze in Excel
icon.
18. Add the Sales Amount measure from the Sales Summary measure group to
the data area, add the Sales Channel attribute hierarchy to the Row Labels
area, and add the Product Categories user hierarchy to the Column Labels
area.
19. Restrict the members of the Product Categories user hierarchy to Bikes, as
shown below.

20. Add the Total Sales Amount measure to the data area and replace the Sales
Summary attribute on the row axis with the Order Date.Calendar user
hierarchy. Notice that the data values are identical.
21. Remove the Product Categories user hierarchy from the column axis.
22. Filter by the United States member of the Customer Geography user
hierarchy in the Customer dimension. Notice that the data values are no
longer identical, as shown below.

© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features

Why do the values in the data pane for Sales Amount and Total Sales
Amount not match each other?

Which measure displays the value that users would expect and why? (Is
there a correct answer?)

23. Change the filter to the United States member of the Geographies hierarchy
of the Reseller Geography cube dimension and compare with the previous
filter, as shown below.

Exercise 3
Defining Ratio to All and Ratio to Parent Calculated Members

In this exercise, you will define two calculated members to enable business users
to compare sales of a product to its parent as well as to the All level.

Define the Ratio to All calculated member

1. Switch to the Calculations tab in the Simple Sales cube designer.


2. Click Form View on the toolbar and then click New Calculated Member on
the toolbar.
3. Define the Ratio to All calculated measure using the following information.
You can copy the expression from the RatioToAll.txt file in the
C:\SSAS\SSAS Dev Labs\SSAS Lab 5a folder.

© 2012 SolidQ
Module: Multidimensional Model: Advanced Features Lab

Property Value
Name [Ratio to All]
Parent hierarchy Measures
Expression
Case
When
IsEmpty( [Measures].[Sales Amount] )
Then 0
Else
( [Product].[Product Categories].CurrentMember
, [Measures].[Sales Amount]) /
( [Product].[Product Categories].[(All)].[All]
, [Measures].[Sales Amount] )
End

Format String Percent


Visible True
Non-empty behavior Sales Amount
Associated Measure Group Sales Summary

4. Define the Ratio to Parent calculated measure using the following


information. You can copy the expression from the RatioToParent.txt file in
the C:\SSAS\SSAS Dev Labs\SSAS Lab 5a folder.

Property Value
Name [Ratio to Parent]
Parent hierarchy Measures
Expression
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


Visible True
Non-empty behavior Sales Amount
Associated Measure Group Sales Summary

© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features

5. Deploy the Simple Sales cube.


6. Switch to Excel, reconnect, and then clear the pivot table.
7. Add the Sales Amount, Ratio to All, and Ratio to Parent measures to the
values area. Notice that the ratios are 100% when you are at the All level, as
shown below.

8. Add Sales Channel to the column label axis.


9. Add the Product Categories user hierarchy to the row label axis and then
expand the Bikes member of the Product Category level. Remove the
Product Category filter to show all categories.
Notice the difference between Reseller Sales and Internet Sales for the bike
subcategory in terms of contributions to total sales, as shown below. Road
Bikes constitute a significantly higher portion of total sales for Internet Sales
than it does for Reseller Sales.

Exercise 4
Defining a Named Set for Core Products

In this exercise, you will define a named set to easily enable business users to
analyze sales of subcategories of bikes without the distraction of non-core
products.

Define and browse the named set

1. Switch to the Calculations tab in the Simple Sales cube designer.


2. Click New Named Set on the toolbar.
3. Define the Core Products named set using the following information:

© 2012 SolidQ
Module: Multidimensional Model: Advanced Features Lab

Property Value
Name [Core Products]
Expression [Product].[Product Categories].[Product
Category].[Bikes]

You can either type this expression into the Expression pane or drag it from
the Metadata tab in the Calculation Tools pane on the Calculations tab. The
screenshot below shows the expression added to the Calculations tab.

4. Deploy the Simple Sales cube.


5. Switch to the Browser tab and reconnect. Notice that the Core Products
named set appears in the Products dimension.
6. Switch to Excel and replace the Product Categories with the Core Products
named set in Row Labels area. Notice that only the members of the Bike
category appear in the data area, as shown below.

© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features

Exercise 5
Defining Key Performance Indicators

In this exercise, you will define a sales revenue key performance indicator to
enable business users to compare changes in sales revenue over time with
specified targets. You will also define a growth in customer base KPI, which will
use a distinct count measure that you will also define in this exercise.

Define the Sales Revenue KPI

1. Switch to the KPI tab in the Simple Sales cube designer.


2. Click New KPI on the toolbar.
3. Define the Sales Revenue KPI. Use the following information to accomplish
this task. You can copy the Goal Expression from the
SalesRevenueGoalExpression.txt file, the Status Expression from the
SalesRevenueStatusExpression.txt file, and the Trend Expression from the
SalesRevenueTrendExpression.txt file in the C:\SSAS\SSAS Dev Labs\SSAS Lab
5a folder.

Property Value
Name Sales Revenue
Associated Measure Group Sales Summary
Value Expression [Measures].[Sales Amount]

Goal Expression
Case
When IsEmpty
(
ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
)
Then [Measures].[Sales Amount]
Else 1.15 *
(
[Measures].[Sales Amount],
ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
)
End

© 2012 SolidQ
Module: Multidimensional Model: Advanced Features Lab

Property Value
Status Indicator Cylinder
Status Expression
Case
When KpiValue( "Sales Revenue" ) /
KpiGoal( "Sales Revenue" ) > 1
Then 1
When KpiValue( "Sales Revenue" ) /
KpiGoal( "Sales Revenue" ) <= 1
And
KpiValue( "Sales Revenue" ) /
KpiGoal( "Sales Revenue" ) >= .85
Then 0
Else -1
End

Trend Indicator Standard arrow


Trend Expression
Case
When IsEmpty
(
ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
)
Then 0
When VBA!Abs
(
(
KpiValue( "Sales Revenue" )
-
(
KpiValue( "Sales Revenue" ),
ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
)
)
/
(
KpiValue( "Sales Revenue" ),
ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
)

© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features

Property Value

Trend Expression (continued)


) <=.02
Then 0
When
(
KpiValue( "Sales Revenue" )
-
(
KpiValue( "Sales Revenue" ),
ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
)
)
/
(
KpiValue( "Sales Revenue" ),
ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
) >.02
Then 1
Else -1
End

4. Deploy the Simple Sales cube.

5. Click Browser View ( ) on the toolbar and then click Reconnect on the
Browser View toolbar.
6. In the subcube area of the Browser View, restrict the cube area to the Q1,
2007 member of the Order Date.Calendar user hierarchy, as shown below.

7. Switch to Excel and open (or refresh if Excel is open from a previous lab) the
Simple Sales cube.

© 2012 SolidQ
Module: Multidimensional Model: Advanced Features Lab

To refresh Excel, click Refresh All on the Data ribbon. Verify that the Sales
Revenue KPI appears in the PivotTable Field List.

8. Clear the pivot table.


9. In the PivotTable Field List, select Value, Goal, Status, and Trend for the Sales
Revenue KPI to add these as values in the pivot table.
10. Add the Order Date.Calendar user hierarchy to the row area.
11. Restrict the calendar years displayed to 2005, 2006, and 2007.
12. Select the Product.Product Categories user hierarchy and add it to the row
area. Notice how various product categories met or exceeded their goals.
13. Format the Sales Revenue Goal column as currency, as shown below.

Define the Customer Count distinct count measure

14. Switch to the Cube Structure tab in the Simple Sales cube designer.
15. Add a new measure.

To begin, click New Measure on the context menu for the Measures pane or
on the Cube menu.
16. Use the following information to define the Customer Count measure:
Property Value
Usage Distinct Count
Source table InternetSales
Source column CustomerKey

17. Click OK to create the measure.

© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features

18. Set the following properties for the new measure and measure group:
Property Value
Name (Measure group) Internet Customers
Name (Measure) Customer Count
Visible (Measure) False

Why is distinct count automatically placed in a separate measure group?

Why did you make this measure invisible?

Define the Customer Growth calculated measure

19. Switch to the Calculations tab in the Simple Sales cube designer.
20. Click New Calculated Member on the toolbar.
21. Define the Customer Growth calculated member. Use the following
information to accomplish this task. You can copy the expression from the
CustomerGrowth.txt file in the C:\SSAS\SSAS Dev Labs\SSAS Lab 5a folder.
Property Value
Name [Customer Growth]
Parent hierarchy Measures
Expression
Case
When [Order Date].[Calendar].CurrentMember.Level.Ordinal = 0
Then "NA"
When IsEmpty
(
(
[Order Date].[Calendar].CurrentMember.PrevMember,
[Measures].[Customer Count]
)
)
Then Null
Else
(
([Order Date].[Calendar].CurrentMember,
[Measures].[Customer Count] )
-
([Order Date].[Calendar].PrevMember,
[Measures].[Customer Count] )
)
/
([Order Date].[Calendar].PrevMember,
[Measures].[Customer Count] )
End

© 2012 SolidQ
Module: Multidimensional Model: Advanced Features Lab

Property Value
Format string Percent
Visible True
Associated Measure Group Internet Sales

Define the Growth in Customer Base KPI

22. Switch to the KPI tab in the Simple Sales cube designer.
23. Click Form View on the toolbar and then click New KPI on the toolbar.
24. Define the Growth in Customer Base KPI. Use the following information to
accomplish this task. You can copy the Goal Expression from the
GrowthInCustomerBaseGoalExpression.txt file, the Status Expression from
the GrowthInCustomerBaseStatusExpression.txt, and the Trend Expression
from the GrowthInCustomerBaseTrendExpression.txt in the C:\SSAS\SSAS
Dev Labs\SSAS Lab 5a folder.

Property Value
Name Growth in Customer Base
Associated Measure Group Internet Sales
Value Expression [Measures].[Customer Growth]
Goal Expression
Case
When [Order Date].[Calendar].CurrentMember.Level Is
[Order Date].[Calendar].[Calendar Year]
Then .30
When [Order Date].[Calendar].CurrentMember.Level Is
[Order Date].[Calendar].[Calendar Quarter]
Then .075
When [Order Date].[Calendar].CurrentMember.Level Is
[Order Date].[Calendar].[Calendar Month]
Then .025
Else "NA"
End

Status Indicator Road Signs


Status Expression
Case
When KpiValue( "Growth in Customer Base" ) >=
KpiGoal ( "Growth in Customer Base" )
Then 1
When KpiValue( "Growth in Customer Base" ) >=
KpiGoal ( "Growth in Customer Base" ) * .90
And

© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features

Property Value

Status Expression (continued)


KpiValue( "Growth in Customer Base" ) <
KpiGoal ( "Growth in Customer Base" )
Then 0
Else -1
End

Trend Indicator Standard arrow


Trend Expression
Case
When IsEmpty
(
ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
)
Then 0
When VBA!Abs
(
(
KpiValue( "Growth in Customer Base" )
-
(
KpiValue( "Growth in Customer Base" ),
ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
)
)
/
(
KpiValue( "Growth in Customer Base" ),
ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
)
) <=.02
Then 0
When
(
KpiValue( "Growth in Customer Base" )
-
(
KpiValue( "Growth in Customer Base" ),

© 2012 SolidQ
Module: Multidimensional Model: Advanced Features Lab

Property Value

Trend Expression (continued)


ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
)
)
/
(
KpiValue( "Growth in Customer Base" ),
ParallelPeriod
(
[Order Date].[Calendar].[Calendar Year],
1,
[Order Date].[Calendar].CurrentMember
)
) >.02
Then 1
Else -1
End

Browse the Simple Sales cube and the Growth in Customer Base KPI

25. Deploy the Simple Sales cube.


26. Switch to Excel.
27. Click Refresh All on the data ribbon.
28. Remove the Sales Revenue KPI.
29. Remove the Product Categories user hierarchy.
30. Add the Value, Status, and Trend measures for the Growth in Customer Base
KPI.
31. Remove the 2005, 2008, 2009, and 2010 members of the Calendar user
hierarchy.
32. Expand the 2006 and 2007 members of the Calendar user hierarchy. Notice
the growth in the customer base over the eight calendar quarters displayed,
as shown in the following screenshot.

© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features

© 2012 SolidQ

Вам также может понравиться