Lab A: Calculations and Kpis
Lab A: Calculations and Kpis
Lab A: Calculations and Kpis
IMPORTANT: You must log on to your computer using an administrator account in order to
successfully complete the labs in this module.
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.
© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features
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
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.
© 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.
To continue while in debug mode, press F10 on the keyboard or click Step Over on
the toolbar or the Debug menu.
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
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.
Property Value
Note that the benefit of non-empty behavior has diminished in SSAS 2008.
When completed, your form should look like the one below.
© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features
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?
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
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.
© 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
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
© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features
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.
© 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.
© 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.
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
© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features
Property Value
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.
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
© 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
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
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
© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features
Property Value
© 2012 SolidQ
Module: Multidimensional Model: Advanced Features Lab
Property Value
Browse the Simple Sales cube and the Growth in Customer Base KPI
© 2012 SolidQ
Lab Module: Multidimensional Model: Advanced Features
© 2012 SolidQ