Professional Documents
Culture Documents
Table of Contents
Developing a SQL Server 2012 Tabular BI Semantic Model with Visual Studio 2010 ................ 1
Exercise 1 Creating the Tabular Model Project .............................................................................................................2 Exercise 2 Importing Data and Creating Relationships ..................................................................................................4 Exercise 3 Enhancing the Model Interface ..................................................................................................................17 Exercise 4 Defining Measures and a KPI ......................................................................................................................26 Exercise 5 Analyzing the Model in the Excel Client .....................................................................................................31 Exercise 6 Defining Perspectives, Partitions and a Role ..............................................................................................36 Exercise 7 Deploying and Managing the Model ..........................................................................................................42
Developing a SQL Server 2012 Tabular BI Semantic Model with Visual Studio 2010
Objectives
After completing this lab, you will be better able to: Create a Tabular project Load data in the model designer Enhance the model design with calculated columns and hierarchies Define measures to aggregate and transform the tabular data Explore and test the model using Excel Define perspectives Define and refresh table partitions Define a security role Deploy the project to a Tabular instance of Analysis Services
Scenario
In this lab, you will develop a Tabular BI Semantic Model based on the AdventureWorksDWDenali sample database. Specifically it will allow the sales analysis of the reseller sales against sales quota. You will work with the entire development lifecycle including the creation of the project, the importing of data from both Microsoft SQL Server and a data feed data source, the enhancement of the model, and the definition of measures and a Key Performance Indicator (KPI). Once you have explored and tested the model you will enhance it with perspectives, partitions and a security role. Finally you will deploy the project to a Tabular instance of Analysis Services. The completed solution is available in the End folder of this lab.
120 Minutes
SQL2012 The password for the Administrator account on all computers in this lab is: pass@word1
Page 1 of 44
C:\TrainingKitFiles\Labs\SQL11UPD06-HOL-01\Source.
b. Double-click the Setup.cmd file in this folder to launch the setup script and run all
Note: In this task, you will launch SQL Server Data Tools to configure options that will be applied to new Tabular projects.
a. To open SQL Server Business Intelligence Development Studio, click the Start
button, and then select All Programs | Microsoft SQL Server 2012 RC0 | SQL Server Data Tools.
b. To configure the Analysis Services options, on the Tools menu, select Options. c. In the Options window, expand the Analysis Services group, and then select the
d. In the Default Workspace Server dropdown list, select ASTABULAR. e. Click Test Connection. f.
When the connection test has succeeded, click OK. list, ensure that the same Tabular instance of Analysis Services used in the previously.
g. Select the Deployment page, and in the Default Deployment Server dropdown
When the connection test has succeeded, click OK. Click OK.
Note: In this task, you will create an Analysis Services Tabular project.
a. To open the AdventureWorksBI solution, on the File menu, select Open |
Page 2 of 44
Developing a SQL Server 2012 Tabular Tasks SQL2012 3. Creating an Analysis Services Tabular Project Detailed Steps Project/Solution.
b. In the Open Project window, navigate to C:\TrainingKitFiles\Labs\SQL11UPD06-
In the Name box, replace the text with Sales Analysis, and then click OK. Note: In Solution Explorer, notice the Sales Analysis project consists of a single item named Model.bim. This item is the model you will develop in this lab.
f.
Notice that the Model.bim item was automatically opened upon project creation. Each Tabular project consists of a single model, and no additional models can be added. When deployed, the project creates a database on the target Analysis Services instance, and the model can be queried.
g. To save the project, on the File menu, select Save All.
Note: It is a good practice to regularly save the solution to protect your development effort in case of an unexpected application crash. The Save All function is also available from the toolbar.
Page 3 of 44
Data Source. Note: Many menu functions are also conveniently available on the toolbar.
b. In the Table Import Wizard window, in the Connect to a Data Source step, notice
enter SQL2012.
d. In the Database Name dropdown list, select the AdventureWorksDWDenali
database.
e. In the Friendly Connection Name box, modify the text to
AdventureWorksDWDenali.
f.
Click Next.
Page 4 of 44
then click Next. Note: You must ensure that your logged in credentials, and the credentials of the Analysis Services instance, have permission to read data in the AdventureWorksDWDenali database.
h. In the Choose How to Import the Data step, notice the default option to select
In the Select Tables and Views step, select the DimEmployee source table. In the corresponding Friendly Name column, modify the text to Salesperson.
k. To preview and filter the data in the DimEmployee table, click Preview & Filter. l.
In the Table Import Wizard window, to unselect all columns, unselect the checkbox located in the top left corner.
EmployeeKey SalesTerritoryKey FirstName LastName LoginID columns to locate the SalesPersonFlag column.
n. To filter the table to include only salespeople rows, scroll to the very end of the o. In the SalesPersonFlag column header, click the down arrow, unselect (Select
p. Click OK.
Page 5 of 44
t. Click OK. u. Select the DimProduct table, and repeat the steps used to configure the
DimEmployee table, but modify the Friendly Name column to Product, and then select the following columns. ProductKey ProductSubcategoryKey EnglishProductName Color column header (located to the left of the Color column), click the down arrow, unselect (Select All), select TRUE.
v. To filter the table to include only finished goods rows, in the FinishedGoodsFlag
w. Click OK. x. In the Table Import Wizard window, click OK. y. To review the column selection and filter, click the Applied Filters link. z. Ensure that the details in the Filter Details window look like the following, and
Page 6 of 44
aa. Click OK. bb. Select the DimProductCategory table, modify the Friendly Name column to
ProductCategory, and then then select the following columns. ProductCategoryKey EnglishProductCategoryName
cc. Click OK. dd. To review the column selection, click the Applied Filters link. ee. Ensure that the details in the Filter Details window look like the following.
ff. Click OK. gg. Select the DimProductSubcategory table, modify the Friendly Name column to
ProductSubcategory, and then select the following columns. ProductSubcategoryKey EnglishProductSubcategoryName ProductCategoryKey
hh. Click OK. ii. To review the column selection, click the Applied Filters link. jj. Ensure that the details in the Filter Details window look like the following.
kk. Click OK. ll. Select the DimSalesTerritory table, modify the Friendly Name column to
nn. To review the column selection, click the Applied Filters link. oo. Ensure that the details in the Filter Details window look like the following.
Page 7 of 44
pp. Click OK. qq. Select the FactResellerSales table, modify the Friendly Name column to
ResellerSales, and then select the following columns. ProductKey OrderDateKey ShipDateKey ResellerKey EmployeeKey SalesTerritoryKey OrderQuantity TotalProductCost SalesAmount
rr. Click OK. ss. To review the column selection, click the Applied Filters link. tt. Ensure that the details in the Filter Details window look like the following.
uu. Click OK. vv. Select the FactSalesQuota table, modify the Friendly Name column to
xx. To review the column selection, click the Applied Filters link. yy. Ensure that the details in the Filter Details window look like the following.
In the Table Import Wizard window, to import the data, click Finish.
In the Importing step, ensure that the status of each work item looks like the following.
Page 8 of 44
In the Details window, review the creation of model relationships. The Wizard has created relationships for all foreign keys where the referenced and referencing columns have been included in the tables column selection. Note: Notice in particular the second last relationship created between the FactResellerSales tables SalesTerritoryKey column and the DimSalesTerritory tables SalesTerritoryKey column. This relationship is marked as inactive. Only one active path can exist, directly or indirectly, between two tables in the model. An active relationship already exists between the FactResellerSales and DimEmployee tables, and the DimEmployee table has an active relationship to the DimSalesTerritory table. Active relationships are used by default in client tools.
ddd. eee. ggg.
To close the Details window, click OK. Notice the addition of the seven tables inside the model designer.
Note: All data loaded into the model is read-only. The only way to modify the data is to modify the source data and then either refresh an individual table or table partition, or refresh the data source which will refresh all tables that are based on that data source. It is also possible to modify the table properties which allow modifying the selection of columns and row filters. Notice the Error List window, and review the warning. To close the window, click the X located in the top right corner of the window. Note: This window opens automatically after certain designer processes. You may need to close this window to maximize the available model designer space.
hhh.
iii. To save the project, on the File menu, select Save All.
Note: In this task, you will explore the data loaded into the ResellerSales table.
a. In the model designer, select the ResellerSales table.
Page 9 of 44
Developing a SQL Server 2012 Tabular Tasks 2. Exploring the ResellerSales Data Detailed Steps
b. Notice that this table has 60,855 rows.
header, click the down arrow, and then select Sort Largest to Smallest.
d. To filter the data by a particular region, in the SalesTerritoryKey column header,
click the down arrow, unselect (Select All), select 1, and then click OK.
e. Notice that the filtered table has 7,872 rows.
f.
To reset the table sort, on the toolbar, click the Clear Sort button.
g. To remove all table filters, on the toolbar, click the Clear All Filters button.
Complete the following task on: SQL2012 3. Importing an Additional Table From an Existing Connection
Note: In this task, you will reuse the AdventureWorksDWDenali connection to import rows retrieved by a query.
a. To launch the Table Import Wizard based on an existing connection, on the
select Write a Query That Will Specify the Data to Import, and then click Next.
d. In the Specify a SQL Query step, in the Friendly Query Name box, modify the text
to Reseller.
e. To design query, click Design. f.
In the Table Import Wizard window, in the Database View pane, expand the Tables folder, and then expand the DimReseller table. ResellerKey BusinessType ResellerName
h. Expand the DimGeography table, and then select the following columns (in this
Page 10 of 44
Developing a SQL Server 2012 Tabular Tasks Detailed Steps order). EnglishCountryRegionName
i.
StateProvinceName City In the Selected Fields pane looks like the following.
Note: The Auto Detect feature has automatically identified the relationship between the two tables and will construct an appropriate join clause to relate the data in these tables.
j.
k. Notice the query statement that has been inserted into the SQL Statement box, l.
In the Importing step, ensure that the status of each work item looks like the following.
m. Click Close. n. Notice the addition of the Reseller table inside the model designer.
Note: Relationships do not exist between the tables imported in the first import process and the Reseller table. You will add them in a later task of this exercise.
o. To save the project, on the File menu, select Save All.
Complete the following task on: SQL2012 4. Importing Data From a Data Feed
Note: In this task, you will use Microsoft Visual Studio 2010 to start a web application that hosts a data service. You will then use the Table Import Wizard to import particular date columns from the CorporateDate data feed.
a. To prepare the data feed, open Microsoft Visual Studio 2010 from Start |
Page 11 of 44
When the Internet Explorer window opens, review the URL to the data service. Note: The AWService.svc returns an ATOM service document. Notice the CorporateDate feed embedded in the service document.
f.
This window must be left open while importing data from the data feed.
g. Switch to SQL Server Data Tools. h. To launch the Table Import Wizard, on the Model menu, select Import From
Data Source.
i.
In the Table Import Wizard window, in the Connect to a Data Source step, scroll to the end of the list, and then select Other Feeds.
j.
k. In the Connect to a Data Feed step, in the Friendly Connection Name box, modify l.
m. Click Next. n. In the Impersonation Information step, select the Service Account option, and
selected.
p. In the corresponding Friendly Name column, modify the text to Date.
q. To preview and filter the data in the CorporateDate table (feed), click Preview &
Filter.
r. In the Table Import Wizard window, to unselect all columns, unselect the
Page 12 of 44
Developing a SQL Server 2012 Tabular Tasks Detailed Steps MonthOfYearLabel CalendarQuarterOfYearLabel CalendarYearLabel
t. Click OK. u. To review the column selection, click the Applied Filters link. v. Ensure that the details in the Filter Details window look like the following.
w. Click OK. x. In the Table Import Wizard window, to import the data, click Finish. y. In the Importing step, ensure that the status looks like the following.
z. To close the Table Import Wizard window, click Close. aa. Notice the addition of the Date table inside the model designer.
Note: Relationships do not exist between the tables imported from the AdventureWorksDWDenali database and the CorporateDate feed. You will add them in the next task.
bb. To save the project, on the File menu, select Save All. cc. Switch to instance of Microsoft Visual Studio 2010 used to host the data service. dd. On the File menu, select Exit.
Complete the following task on: SQL2012 5. Adding Relationships to the Date Table in Data View
Note: In this task, you will define relationships between the ResellerSales and Date tables, and between the ResellerSales and Reseller tables.
a. In the model designer, select the ResellerSales table. b. In the ResellerSales table, right-click the OrderDateKey column header, and then
Page 13 of 44
d. Click Create. e. Repeat the last three steps in this task to create the same relationship, but from
Right-click the ResellerKey column header, and then select Create Relationship. column based on the following.
g. In the Create Relationship window, configure the related lookup table and
h. Click Create. i. j.
To review the model relationships, on the Table menu, select Manage Relationships. In the Manage Relationships window, notice the two relationships to the Date table.
k. Notice that the second relationship to the Date table you created is inactive.
Page 14 of 44
Note: Recall that only one active path can exist between two tables. The first relationship you created is automatically configured to be active. The second, and any subsequently created relationships, will be configured to be inactive. You can use the Manage Relationships window or the Diagram View to edit relationships and change their active status.
l.
Click Close.
Complete the following task on: SQL2012 6. Exploring the Model in Diagram View
Note: In this task, you will explore the model tables in Diagram View and define a relationship between the SalesQuota and Date tables.
a. To switch the model view to Diagram View, in the bottom right corner of the
Note: Diagram View is a useful way to visualize the models tables and relationships. Beyond the model visualization, this view exposes useful functionality to enhance the design of the model. Oftentimes this functionality is available in Data View (the default view consisting of the tables and rows). Calculated columns and measures can only be defined in Data View, and hierarchies can only be defined in Diagram View. When appropriate, you can choose to work in the view that is most productive for you.
b. Notice the options at the top of the designer window to allow the developer to
select a perspective (to be covered later), to reset the table layout (auto arrange), filter the display of different model objects (columns, hierarchies, measures and KPIs), and explore the view by navigating with the minimap, zooming, and adjusting the size to fit to screen or restoring the diagram to its original size.
Page 15 of 44
d. Drag the rectangle about the minimap to explore the diagram, and use it to help
To reposition the Date table, select and drag the table so it is near the SalesQuota table. Note: While it is possible to right-click a tables column to launch the same Create Relationship window (used earlier in this exercise), it is also possible to drag a column to another tables column to create a relationship.
f. g. Drag the SalesQuota tables DateKey column to the Date tables DateKey
column.
h. To rearrange the tables in the diagram, click Reset Layout. i. j.
When prompted to reset the layout, click Reset Layout. To save the project, on the File menu, select Save All.
Page 16 of 44
Detailed Steps Note: In this task, you will enhance the Date table with a Calendar hierarchy.
a. To switch the model view to Data View, in the bottom right corner of the
Table.
d. In the Mark As Date Table window, in the Date dropdown list, notice that the
Date column is automatically selected, and then click OK. Note: Marking a date table will help client applications understand how time is defined in the model. SQL is one such example that interrogates the model for a date table.
e. To rename the MonthOfYearLabel column, right-click the MonthOfYearLabel
Replace the column header text with Month, and then press Enter. Quarter, and the CalendarYearLabel column to Year.
g. Repeat the last two steps to rename the CalendarQuarterOfYearLabel column to h. To view the Month column values, in the Month column header, click the down
arrow, and then review the distinct values, available for filtering, found in the column.
Page 17 of 44
i. j.
Notice that the months are sorted alphabetically, and then click Cancel. To configure the months to sort chronologically in client tools, select the Month column, and then on the Column menu, select Sort | Sort By Column. MonthOfYearKey column.
k. In the Sort By Column window, in the second dropdown list, select the
l.
m. In the Month column, review the distinct values found in the column, and notice
Page 18 of 44
Note: Maximizing the table is a very convenient way to view its definition and to configure it.
p. In the Date table, to create a hierarchy, in the top right corner, click Create
Hierarchy.
q. When the hierarchy is added to the table, replace the default name with
hierarchy.
t. To hide all columns, select the DateKey column, and then while pressing the Shift
Note: Users exploring and querying this model do not need to access the columns directly. Year, quarter and month values are now available from the Calendar hierarchy which is now the only visible object in this table.
v. Ensure that the Date table looks like the following.
Page 19 of 44
Complete the following task on: SQL2012 2. Enhancing the SalesTerritory Table
Note: In this task, you will enhance the SalesTerritory table with a Regions hierarchy.
a. Locate and maximize the SalesTerritory table. b. As an alternate way to create a hierarchy, right-click the SalesTerritoryGroup
column, and then select Create Hierarchy. Note: The selected column, SalesTerritoryGroup, will become the first level in the new hierarchy.
c. When the hierarchy is added to the table, replace the default name with Regions,
Note: It is possible to have a level name different from the name of the column it is based on. The name in parentheses is the name of the column the hierarchy level is based on.
Page 20 of 44
Developing a SQL Server 2012 Tabular Tasks Detailed Steps To add the next level to the Region hierarchy, right-click the SalesTerritoryCountry column, and then select Add to Hierarchy | Regions. Note: There is a possible RC0 bug. If Visual Studio crashes you will need to assemble the hierarchy using the approach in the previous task for the Calendar hierarchy.
f. g. Rename the new level to Country. h. Repeat the last two steps to add the SalesTerritoryRegion column as the third
To hide all columns, select the SalesTerritoryKey column, and then while pressing the Shift key, select the SalesTerritoryGroup column. Right-click the selected columns, and then select Hide From Client Tools.
l.
Complete the following task on: SQL2012 3. Enhancing the Salesperson Table
Note: In this task, you will enhance the Salesperson table with a calculated column to display the salespersons full name.
a. To edit the Salesperson table in Data View, right-click the header of the
c. Enter the following expression in the selected cell, and then press Enter. =[FirstName] & " " & [LastName]
Note: To inject the column references into the expression, when you are ready to enter the column name, simply click anywhere in the column.
d. To rename the new column, right-click the CalculatedColumn1 column, and then
To hide a range of columns, select the EmployeeKey column, and then while pressing the Shift key, select the LoginID column.
Page 21 of 44
Complete the following task on: SQL2012 4. Enhancing the Product Table
Note: In this task, you will enhance the Product table with calculated columns to introduce the related Subcategory and Category columns. You will then create the Products hierarchy.
a. Right-click the header of the Product table, and then select Go To. b. Rename the EnglishProductName column to Product. c. Use the steps in the previous task to add a new column based on the following
Note: This expression navigates the relationship to the ProductSubcategory table to lookup the EnglishProductSubcategoryName column value.
d. Add another column based on the following expression, and rename the column
to Category.
=RELATED(ProductCategory[EnglishProductCategoryName])
Note: This expression navigates two relationships, first to the ProductSubcategory table, then the ProductCategory table, to lookup the EnglishProductCategoryName column value.
e. To hide the ProductCategory table, right-click the ProductCategory tab, and then
select Hide from Client Tools. Note: This efficiently hides all columns in the table.
f.
g. Switch to Diagram View. h. Notice that the ProductCategory and ProductSubcategory tables are shaded,
Locate and maximize the Product table. As an alternate way to create a hierarchy, select the Product column, and then while pressing the Ctrl key, select the Subcategory and Category columns.
When the hierarchy is added to the table, replace the default name with Products, and then press Enter. Note: A hierarchy can only add levels based on columns in the same table. This is why you added calculated columns to introduce the related subcategory and category values.
l.
The behavior for the multi-select method used in this step to create a hierarchy is slightly different from the incremental level addition method used earlier. When using the multi-select method, the fields will be ordered based on cardinality (the field with Page 22 of 44
Developing a SQL Server 2012 Tabular Tasks Detailed Steps fewer members will be the higher level in the hierarchy). This is to be interpreted to be a suggestive order of levels only since it this may not necessarily be the correct order.
m. Hide all columns from the client tools, except the Color column. n. Ensure that the Product table looks like the following.
Complete the following task on: SQL2012 5. Enhancing the Reseller Table
Note: In this task, you will enhance the Reseller table by creating a Geography hierarchy.
a. Locate and maximize the Reseller table. b. To rename the ResellerName column, right-click the column, and then select
Rename.
c. Replace the column header text with Reseller, and then press Enter. d. Repeat the last two steps to rename the EnglishCountryRegionName column to
Create a second hierarchy named Geography based on the Country, State, City and Reseller columns (in that order).
g. Hide all columns from the client tools. h. Ensure that the Reseller table looks like the following.
Page 23 of 44
i.
Complete the following task on: SQL2012 6. Enhancing the ResellerSales Table
Note: In this task, you will enhance the ResellerSales table by hiding all columns.
a. Locate and maximize the ResellerSales table. b. Select and then hide all columns from the client tools.
Note: Generally, when enhancing the design of a fact table it is common to hide the dimension keys and measure columns, and then define explicit measures using aggregate functions. You will do this in the next exercise. Be aware that this design approach may not be appropriate when developing a model for use by Power View. Power View has the ability to support implicit measures, in which case the columns should be left visible and no measure should be defined.
c. Ensure that the ResellerSales table looks like the following.
Note: In this task, you will enhance the SalesQuota table by hiding all columns.
a. Locate the SalesQuota table. b. Select and then hide all columns from the client tools.
Page 24 of 44
Developing a SQL Server 2012 Tabular Tasks SQL2012 7. Enhancing the SalesQuota Table Detailed Steps
c. Ensure that the SalesQuota table looks like the following.
Page 25 of 44
larger to view its content. Note: You can right-click the table tab to show or hide the Measure Grid.
d. Notice that the Distinct Count of ProductKey measure is added.
Note: When adding a measure in this way it will be placed in the grid below the column it is based on. Note that the location of the measure within the Measure Grid does not matter. The column used to define the measure, or the sequence of measures within a column, does not impact on how it is evaluated and you can move a measure to any location of the grid without impacting the formula.
e. Select the measure, and then in the formula bar, notice the expression that defines the
measure, and notice also that the measure name followed by a colon (:) precedes the expression.
f.
In the Properties window (located at the bottom right), modify the Measure Name to Distinct Products.
g. In the formula bar, notice the updated name that precedes the expression.
Note: You can choose to modify the measure name in either location. Note also that measure names must be unique within the model. It is not possible to have a measure with the same name as a column.
h. In the Properties window, modify the Format property to Whole Number, and then modify
Widen the ProductKey column to reveal the measure name and its value, 334. Filter the EmployeeKey column to filter on the value 272.
Page 26 of 44
k. Click OK.
Notice that the value of the measure has changed to 278. The table filters can help test the measure expressions. Note: The true test of a measure is in a PivotTable where filter context can be configured using columns from a different table.
l. m. Clear the table filters.
columns, multi-select the columns, and then on the Column menu, select AutoSum | Sum.
o. In the Properties window, modify the first new Measure Name property to Orders, the
Format property to Whole Number, and the Show Thousand Separator property to True.
p. Repeat the last step in this task to add, rename and format the other two measures.
q. To add a measure based on an expression, in the Measure Grid, select the cell beneath the r. In the formula bar, enter the following expression, and format the measure as Whole
Number, and the Show Thousand Separator property to True. Note: For convenience, the remaining measure expressions defined in this exercise can be copied from the Assets\Snippets.txt file located in the Source folder. To paste the clipboard content into the formula bar, right-click inside the formula box, select Paste, and then press Enter.
Profit:=[Sales] - [Cost] s. Add the following measure beneath the last, and format the measure as Percentage. Profit%:=[Profit] / [Sales] t. Add the following measure beneath the last, and format the measure as Whole Number,
Page 27 of 44
Developing a SQL Server 2012 Tabular Tasks Detailed Steps Note: This measure uses the TOTALYTD function to calculate year-to-date sales values based on the dates in the related Date table. Recall that there are two relationships between the ResellerSales and Date tables. The active relationship is based on the OrderDateKey and the inactive relationship is based on the ShipDateKey. The active relationship is always used by default. You will create one more measure in this table to also calculate year-to-date sales values using the ShipDateKey relationship.
u. Add the following measure beneath the last, and format the measure as Whole Number,
Note: The CALCULATE function is being used to force the evaluation of the Sales measure in the context of the relationship between the ShipDateKey and Date tables DateKey column. In other words, you are specifying a formula that will navigate the inactive relationship.
v. To review the table definition, switch to Diagram View. w. Locate and maximize the ResellerSales table. x. Ensure that the ResellerSales table looks like the following.
Complete the following task on: SQL2012 2. Adding Measures the SalesQuota
Note: In this task, you will add and format measures to the SalesQuota table.
a. Locate and right-click the SalesQuota table, and then select Go To. b. In the Measure Grid, in any cell, add the following measure, and then format the measure
Note: The data in the SalesQuota table is stored at quarter granularity, and yet the data in the ResellerSales table is stored at month granularity. This expression is using the IF function test whether only a single month is being used to filter
Page 28 of 44
Developing a SQL Server 2012 Tabular Tasks Table Detailed Steps the measure. If it is a single month, then the CALCULATE function is used to evaluate the sum of the SalesAmountQuota column for all months. As the month is only accessible by navigating the Calendar hierarchy, it is known that specific a Year and Quarter will be in context. Essentially the CALCULATE function is returning the value for the quarter that the month belongs to. This value is then divided by three. This expression is only accurate if each quarter contains three months, which is the case with the data loaded into the Date table in Exercise 2.
c. Add the following measure beneath the last, and format the measure as Whole Number,
Note: In this task, you will add the Sales Performance KPI to the SalesQuota table.
a. Add the following measure beneath the last, and format the measure as Whole Number,
Note: This new measure is a direct reference to the Sales measure. It will become the base measure used to create a KPI.
b. Right-click the Sales Performance measure, and then select Create KPI. c. In the Key Performance Indicator (KPI) window, notice that the KPI base measure (value) is
Note: This configuration will produce a status based on the ratio of Sales over Quota multiplied by 100. A value of 100 or more will mean that the sales are on or exceeding target. A value less than 0 will mean that sales are not meeting target.
e. In the Define Status Thresholds boxes, modify the values to 90 and 100. f.
In the Select Icon Style gallery, select the sixth from the left.
Page 29 of 44
g. Click OK. h. In the Measure Grid, notice the icon added to the Sales Performance measure to denote
i. j.
To review the table definition, switch to Diagram View. Maximize the SalesQuota table.
l.
Page 30 of 44
OK.
c. When Excel opens, you may need to switch to the Excel window. d. In the PivotTable Field List (located on the right), review the model structure
consisting of measures, KPIs, dimensions and the dimension hierarchies. Note: This field list is the regular Excel PivotTable Field List used when connecting to OLAP cubes. The PowerPivot Field List is not available for analyzing a Tabular model.
e. To test the model, in the PivotTable Field List, from inside the Date dimension,
f.
In the Calendar report filter (cell B1), click the down arrow, expand the All | CY2003 members, and then select the CY Q4 member.
Page 31 of 44
g. Click OK. h. In the PivotTable Field List, from inside the SalesTerritory dimension, drag the
In the PivotTable Field List, in this order, select the following fields. Type Measure Measure Measure KPI Measure Measure Field ResellerSales | Sales SalesQuota | Quota SalesQuota | Variance KPIs | Sales Performance | Status ResellerSales | Profit% ResellerSales | Distinct Products
j.
Page 32 of 44
l.
To display only the North America member, right-click the North America member (cell A6), and then select Filter | Keep Only Selected Items. member (cell A6), and then select Expand/Collapse | Expand to "Region".
m. To expand all of the Regions hierarchy levels, right-click the North America n. Notice that the Northwest region is under performing, and then right-click the
Northwest member (cell A9), and then select Filter | Keep Only Selected Items.
o. To introduce the salespeople into the report, in the PivotTable Field List, from
inside the Salesperson dimension, drag the Salesperson hierarchy into the Row Labels drop zone, directly beneath the Regions hierarchy.
q. Notice the CY Q4 quarter Quota values for the three Northwest salespeople. r. To filter at month level, in the Calendar report filter (cell B1), click the down
arrow, expand the selected CY Q4 member, notice the chronologically ordered months, select the Oct member, and then click OK.
s. Now notice that the month level Quota values are one third of the quarter level
values.
Page 33 of 44
Complete the following task on: SQL2012 2. Testing the YTD Measures
Note: In this task, you will create a report using the two YTD measures created in Exercise 4.
a. To create a new worksheet, click the Insert Worksheet tab.
b. To create a new PivotTable, on the Insert ribbon tab, inside the Tables group,
click PivotTable.
c. In the Create PivotTable window, select the Use an External Data Source option,
In the PivotTable Field List, inside the Date dimension, drag the Calendar hierarchy to the Row Labels drop zone. Expand/Collapse | Expand to "Month".
g. In the PivotTable, right-click the CY2002 member (cell A4), and then select h. To hide the quarter members, right-click any month member, and then select
In the PivotTable Field List, inside the ResellerSales measure group, select the Sales YTD (Ordered) and Sales YTD (Shipped) measures. Notice the accumulation of sales over month, and the different values for each measure.
Page 34 of 44
Developing a SQL Server 2012 Tabular Tasks Complete the following task on: SQL2012 3. Finishing Up Detailed Steps Note: In this task, you will close the Excel client.
a. To close Excel, on the File ribbon tab, click Exit. b. When prompted to save the changes, click Dont Save.
Page 35 of 44
g. To add another perspective, click New Perspective again. h. Name the new perspective Monitoring, and then select the following tables.
Page 36 of 44
i. j.
Click OK. In Diagram View, in the Select Perspective dropdown list, select Monitoring.
Note: You will use the Monitoring perspective in Excel later in this exercise. Complete the following task on: SQL2012 2. Defining Partitions on the ResellerSales Table Note: In this task, you will define partitions on the ResellerSales table to allow its data to be refreshed for individual years.
a. Switch to Data View. b. Select the ResellerSales table. c. On the Table menu, select Partitions. d. In the Partition Manager window, notice that there is one partition named
In the OrderDateKey column header, click the down arrow, and then select Number Filters | Between.
h. Click OK.
Page 37 of 44
Developing a SQL Server 2012 Tabular Tasks Detailed Steps Note: Defining multiple partitions for a table allows the efficient removal of data from the model, and also allows refreshing data at partition level. There is no need to refresh partitions, particularly historical ones, where the source data has not changed. Typically partitions are based on time periods.
i. j. l.
To add a new partition, click Copy. In the Partition Name box, modify the text to ResellerSales 2002. Modify the OrderDateKey values in the WHERE clause to 20020101 and 20021231, respectively.
m. To validate the query, click Validate. n. Repeat the last five steps to create two additional partitions based on the
Partitions.
q. Notice the refresh options that support refreshing all tables, the current table, or
s. Click OK. t. Ensure that the status of each work item looks like the following.
Note: If you add up the rows for each partition they come to 60,855 the number
Page 38 of 44
Developing a SQL Server 2012 Tabular Tasks Detailed Steps contained in the original partition.
u. Click Close.
Note: Partitions can also be managed by administrators using the Object Explorer in SQL Server Management Studio. In addition to the ability to create partitions, delete partitions, define the partition queries and refresh partitions, it is also possible to merge partitions. It is not uncommon that partitions are created, defined and managed by administrators using SQL Server Management Studio.
v. To save the project, on the File menu, select Save All.
Note: In this task, you will define a role to limit retrieving data for bike products only, and for the sales territory, the salesperson is assigned to.
a. Click Server manager from the Task bar. b. Expand Configuration | Local Users and Groups. c. Click Groups. d. Click Action. e. In the New Group window, write Salespeople and click Create, then click Close. f.
g. To explore the salespeople data, select the Salesperson table. h. If necessary, expand the LoginID column to view all the values in the column. i. j. l.
Notice that the salesperson Pamela Ansman-Wolfe has your login ID. Also, notice that this salesperson belongs to SalesTerritoryKey 1. Navigate to the SalesTerritory table. To define a model role, on the Model menu, select Roles.
k. Notice that the region for SalesTerritoryKey 1 is Northwest. m. In the Role Manager window, click New. n. In the Name box, replace the text with Salespeople. o. In the Permissions dropdown list, select Read.
p. In the Row Filters tab, in the Salesperson table row, enter the following
Note: This expression uses the LOOKUPVALUE function to retrieve the SalesTerritoryKey value for the current user. This way the role will allow salespeople to see data related to other salespeople within their own region. This is a dynamic filter.
q. In the Row Filters tab, in the ProductCategory table row, enter the following
Page 39 of 44
v. Click OK. w. In the Enter the Object Names to Select box, enter Salespeople, and then click
Check Names. Note: The Salespeople group is maintained by the network administrator to include all Adventure Works salespeople, regardless of sales territory.
x. Click OK. y. In the Role Manager window, click OK. z. To save the project, on the File menu, select Save All. aa. To test the role, on the Model menu, select Analyze in Excel. bb. In the Analyze in Excel window, select the Role option. cc. In the dropdown list, select the Salespeople role, and then click OK. dd. In the Perspective dropdown list, select the Monitoring perspective.
ee. Click OK. ff. When Excel opens, you may need to switch to the Excel window. gg. In the PivotTable Field List, from inside the SalesTerritory dimension, drag the
Page 40 of 44
Developing a SQL Server 2012 Tabular Tasks Detailed Steps Expand to "Region".
ii. Right-click the France member (cell A4), and then select Show/Hide Fields |
Group.
jj. Repeat the last step to hide the Country members also.
kk. In the PivotTable Field List, from inside the SalesQuota measure group, select the
Notice also that the Grand Total display a visual total (i.e. not the total for all regions).
Page 41 of 44
Note: This property was set when the project was created. It was based on the options configured in Exercise 1.
d. Notice that the Database property is set to the name of the project.
e. Click Cancel. f.
Make sure the Site is running from Exercise 2 Task 4. and then select Deploy.
g. To deploy the project, in Solution Explorer, right-click the Sales Analysis project, h. In the Deploy window, ensure that the status of each work item looks like the
following.
Page 42 of 44
Click Close. To close SQL Server Data Tools, on the File menu, select Exit.
Complete the following task on: SQL2012 2. Exploring the Deployed Database
Note: In this task, you will use SQL Server Management Studio to explore the deployed database.
a. To open SQL Server Management Studio, click the Start button, and then select
All Programs | Microsoft SQL Server 2012 RC0| SQL Server Management Studio.
b. In the Connect to Server window, configure the following properties.
Note: If the Connect to Server window does not open automatically, on the File menu, select Connect Object Explorer. You will need to substitute <servername> for the name of the Analysis Services instance used to deploy the project to.
c. Click Connect. d. In Object Explorer (located on the left), expand the Databases folder. e. Expand the Sales Analysis database folder, and then expand each of the child
folders.
Right-click several of the connections, tables and the role to learn about the functions available to the administrator. Note: Once the database is deployed, common tasks include backing up the database; modifying connection settings; refreshing data sources, tables and partitions; creating, deleting, and merging partitions; and, creating roles to grant permissions to users.
f.
The data sources, tables and table partitions can be refreshed according to a recurring schedule by creating a SQL Server Agent job. Complete the following task on: Note: In this lab, you have developed a Tabular BI Semantic Model based on the AdventureWorksDWDenali sample database to support the sales analysis of the
Page 43 of 44
Developing a SQL Server 2012 Tabular Tasks SQL2012 3. Summary Detailed Steps reseller sales against sales quota. You worked with the entire development lifecycle including the creation of the project, the importing of data from both Microsoft SQL Server and a data feed data source, the enhancement of the model, and the definition of measures and a Key Performance Indicator (KPI).
Page 44 of 44