53
SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions Table of Contents Before You Begin 1 Lab Setup 1 Exercise 1: Creating an Analysis Services Cube 3 Exercise 2: Browsing the cube 23 Exercise 3: Creating and Enhancing Dimensions and Hierarchies 27 Exercise 4: Creating Calculated Members & KPIs 39

Lab14 Designing Analysis Services

Embed Size (px)

Citation preview

Page 1: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions

Table of Contents

Before You Begin 1Lab Setup 1Exercise 1: Creating an Analysis Services Cube 3Exercise 2: Browsing the cube 23Exercise 3: Creating and Enhancing Dimensions and Hierarchies 27Exercise 4: Creating Calculated Members & KPIs 39

Page 2: Lab14 Designing Analysis Services

Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein.

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.

Copyright © 2007 Microsoft Corporation. All rights reserved.

Microsoft are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

Version 1.2

Page 3: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 1

Before You BeginEstimated time to complete this lab

90 minutes

ObjectivesAfter completing this lab, you will be able to:

Create an Analysis Services cube

Browse the cube

Create dimensions, hierarchies & attribute relationships

Check and dismiss Best Practice Design Alerts (AMO warnings)

Create calculated members and Key Performance Indicators (KPIs)

PrerequisitesBefore working on this lab, you must have:

Basic knowledge of the SQL Server Relational Database Management System

Basic knowledge of

Online Analytical Processing

Lab SetupLab scenario (if applicable)

Virtual PCThis lab makes use of Microsoft Virtual PC 2004 or Virtual PC 2007, which is an application that allows you to run multiple virtual computers on the same physical hardware. During the lab, you will switch among different windows, each of which contains a separate virtual machine running Microsoft Windows Server® 2003.

Before you start the lab, familiarize yourself with the following basics of Virtual PC:

To switch the focus for your mouse and keyboard to the virtual machine, click inside the virtual machine window.

To remove the focus from a virtual machine, move the mouse pointer outside the virtual machine window.

To mimic the CTRL+ALT+DELETE key combination inside a virtual machine, use <RIGHT>ALT+DEL. In Virtual PC, the <RIGHT>ALT key is called the host key.

Page 4: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 2

To enlarge the size of the virtual machine window, drag the lower-right corner of the window as seen in the screenshot.

To switch to and from full-screen mode, press <RIGHT>ALT+ENTER.

Log on to a computer in a virtual machine1. Press <RIGHT>ALT+DEL (instead of CTRL+ALT+DEL) to open the logon dialog box.

2. Type the following information, and then click OK:

User name: Administrator

Password: Pa$$word

Exercise 1: Creating an Analysis Services CubeIn this exercise, you will develop an Analysis Services solution using the Business Intelligence Development Studio, a SQL Server environment based on Microsoft Visual Studio 2005. You create Analysis Services projects in Business Intelligence Development Studio by using the Analysis Services Projects template. The Analysis Services project helps you organize and manage the items that are required to build, debug and deploy an Analysis Services solution. The solution you are to develop is an Analysis Services cube, which is one of the most common tasks in Analysis Services. To help you with this, you have a powerful Cube Wizard, which help simplify the creation an Analysis Services cube significantly. A cube and its dimensions can be created by using a single wizard because the relationships between attributes, dimensions, and facts are automatically detected.

To create an Analysis Services cube, you will:

• Create a Data Source containing the information Analysis Services needs to connect to a database.

• Create a Data Source View, which is a logical representation of the tables from the original data store(s) containing the schema information and Named Calculations that is to be used when building the cube.

• Create a Cube containing data from multiple fact tables that have different dimensionality and granularity.

Before you begin the lab, you must start and log on to the computers.

Tasks Detailed Steps

Start the server (using Virtual PC).

Launch Microsoft Virtual PC from the Start menu. If the Virtual PC Console does not appear, look for its icon in the System Tray, and double-click the Microsoft Virtual PC icon in the System Tray.

Page 5: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 3

Tasks Detailed Steps

Select SQL Server 2008 HOLs and click Start.

Once the virtual server is running, on the Action menu within the virtual server window, click Ctrl+Alt+Del (or press Right Alt+Del on your keyboard) to send a Ctrl+Alt+Del sequence to the login dialog box within the virtual server window.

You can press Right Alt+Enter to switch the virtual machine to full-screen display. To switch the virtual machine back to a windows display, press Right Alt+Enter again.

Log on as Administrator, using a password of Pa$$word.

Note: Because of some Virtual Machine Configurations and Lab Environment Setup it might be possible that you are not required to launch Microsoft Virtual PC to Start the lab environment. In some lab environments you are also not required to logon to the virtual machine since this configuration might have been preset.

Page 6: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 4

Task 1: Create an Analysis Services Project

1. Click Start | All Programs | Microsoft SQL Server 2008 | SQL Server Business Intelligence Development Studio.

2. Click File | New | Project.

3. In the New Project dialog box, in the Project Types pane, click the Business Intelligence Projects folder.

4. In the Templates pane, click the Analysis Services Project icon.

5. In the Name text box, type Analysis Services

6. In the Location text box, enter C:\SQLHOLs\Designing Analysis Services Solutions

7. The New Project dialog box should now look like Figure 1.

8. In the New Project dialog box, click OK.

Figure 1

NOTE : You have now created a new Analysis Services project. The project is created in a new solution and the solution is the largest unit of management in the Business Intelligence Development Studio environment. The solution contains one or more projects and you can view the solution and its projects in the Solution Explorer pane on the right hand side in the Business Intelligence Development Studio. If the Solution Explorer is not visible you can view it by View | Solution Explorer from the menu bar (or the keyboard shortcut<Ctrl+Alt+L>)

An Analysis Services Project is a group of related files containing the XML code for all of the objects in an Analysis Services database, and your next task is to create a Data Source.

Page 7: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 5

Task 2: Create a Data Source

INTRO: The data sources in an Analysis Services database provide connection information for one or more data source views. This is used by Analysis Services objects such as cubes and dimensions to reference data.

1. In the Solution Explorer pane, under the Analysis Services solution, right-click the Data Sources folder, and then select New Data Source from the context menu.

NOTE: If the Solution Explorer is not visible you can view it by View | Solution Explorer from the menu bar (or the keyboard shortcut <Ctrl + Alt + L>)

2. In the Data Source Wizard dialog box, on the Welcome to the Data Source Wizard page, click Next.

3. On the Select how to define the connection page, make sure the Create a data source based on an existing or new connection radio button is chosen. Click New.

4. In the Connection Manager dialog box, verify that Native OLE DB/SQL Server Native Client 10.0 is selected in the Provider drop down list.

5. In the Server name field, type “localhost”.

6. Under Log on to the server, ensure that Use Windows Authentication is selected.

7. In the Select or enter a database name drop down list, click AdventureWorksDW.

8. The Connection Manager dialog box should look like Figure 2.

Page 8: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 6

9. Click the Test Connection button. (The connection should test successfully.)

10. Click OK to dismiss the message box.

11. In the Connection Manager dialog box, click OK to close the dialog box.

12. In the Data Source Wizard dialog box, on the Select how to define the connection page, verify that localhost.AdventureWorksDW is selected, and click Next.

13. In the Impersonation Information dialog click the Inherit radio button as shown below and click Next.

NOTE: This option allows us to inherit the credentials that we supplied in the Connection Manager dialog box i.e., Windows Authentication

Page 9: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 7

14. On the Completing the Wizard page, leave the default Data source name Adventure Works DW unchanged, and then click Finish.

NOTE : You have now set up the information describing how to connect to the database you are interested in working with. You may connect to other data sources like Oracle, DB2 or Teradata as per requirements.

Task 3: Create a Data Source View

1. In the Solution Explorer pane, under the Analysis Services solution, right-click the Data Source Views folder, and then select New Data Source View from the context menu.

In the Data Source View Wizard dialog box, on the Welcome to the Data Source View Wizard page, click Next.

2. On the Select a Data Source page, in the Relational data sources pane, verify that Adventure Works DW is selected, and click Next.

NOTE: Analysis Services may take a few moments to read the database schema.

Page 10: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 8

3. On the Select Tables and Views page, type “fact” in the Filter text box and select Enter. Using the Filter will help narrow down the number of tables displayed, which is helpful when working with large data sets

1. In the Available objects list, double-click FactInternetSales and FactSalesQuota to add them to the Included objects list.

NOTE: Alternatively, you can select multiple items at once by holding the <Ctrl> key and click the add button ( ) to add the selected tables (You may maximize the dialog box to see the object names in full)

4. Remove the filter by clearing the text in Filter text box and select Enter. (Note: All object will be listed now)

5. Select FactInternetsales and FactSalesQuota in the Included objects list box. You can select multiple items at once by pressing <Ctrl> + Click

6. Click Add Related Tables

Page 11: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 9

7. The following tables will be added to the Included objects list:

DimTime

DimPromotion

DimCurrency

DimEmployee

DimSalesTerritory

FactInternetSalesReason

DimProduct

DimCustomer

Not all the above tables are needed for this exercise and you will, in the next task, remove some of the tables.

8. Click Next.

9. On the Completing the Wizard page, in the Name text box, type “Direct Sales and Quotas” as shown below and then click Finish.

10. The Data Source View Designer will open.

NOTE: The Data Source View Designer provides a graphical representation of the data schema you have defined.

Task 4: Alter the content of the Data Source View by removing the unwanted tables.

INTRO: The Data Source View contains some tables you are not interested in, so in this task you will change the content of the Data Source View.

11. On the designer surface, right click anywhere in a blank area and select the Add/Remove tables menu item from the context menu.

12. This brings up the Add/Remove Tables dialog box as shown below:

Page 12: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 10

13. In the Included objects list on the Add/Remove Tables page, select the DimSalesTerritory and FactInternetSalesReason tables as shown above. Note that you can select multiple items at once by pressing <Ctrl> + Click

14. Click the remove button ( ) to remove the selected tables.

15. Click OK.

Task 5: Create Named Calculations.

.

1. On the designer surface, right click anywhere in a blank area and select Zoom | 100% from the context menu. Note that you may also use the View menu bar

2. In the Data Source View Designer, move the mouse pointer to the cross-arrow icon ( ) at the bottom-right corner. When the mouse pointer changes to a cross-arrow icon, click and hold left mouse button and the Navigation window will appear. Drag the mouse to navigate around the Data Source View diagram. When the DimTime table is visible, release the mouse button.

NOTE: The above step is useful when you want to inspect what objects you have in your Data Source View. If you want to find a specific table in the Data Source View you can use the Data Source View | Find Table from the menu bar.

Page 13: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 11

3. In the Data Source View diagram, right-click the DimTime table header and choose New Named Calculation

NOTE: Be sure to click the table header; otherwise, New Named Calculation will not appear in the context menu.

4. In the Create Named Calculation dialog box, in the Column Name text box, type “Quarter”. In the Expression text box, type the following:

CalendarYear + ' Qtr ' + Convert(Char(1), CalendarQuarter)

5. The Create Named Calculation dialog box should look like shown below:

6. Click OK

7. Right-click the DimTime table and then click Explore Data. This opens a new tab in which you can view the data for the table.

NOTE: If you like, you can make the tab into a dockable or floating window instead. You do this by right-clicking on the tab header and choose Floating or Dockable as shown below:

Page 14: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 12

8. In the Explore DimTime Table tab, scroll to the right until the Quarter column is visible. You can verify the values in the column to ensure the correctness of the expression you typed in step 4.

9. Click the X in the upper right hand corner to close the tab as shown below to close the table explorer tab.

Task 6: Create a Cube with Multiple Measure Groups

INTRO: A cube is the Analysis Services data store. A cube may contain data from multiple fact tables. The data from each fact table becomes a measure group in the cube.

1. In the Solution Explorer pane, under the Analysis Services solution, right-click the Cubes folder and then click New Cube.

Page 15: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 13

2. In the Cube Wizard dialog box, on the Welcome to the Cube Wizard page, click Next.

3. On the Select Creation Method page, verify that Use existing tables is selected. Click Next.

4. On the Select Measure Group Tables page, in the Data source view drop down list, make sure that Direct Sales and Quotas is selected. In the Measure Group Tables list select FactSalesQuota and FactInternetSales. Click Next.

5. On the Select Measures page, deselect Sales Territory Key and Revision Number. Click Next.

6. On the Select New Dimensions page, uncheck the Fact Internet Sales dimension. Click Next.

7. On the Completing the Wizard page, leave the default Cube name Direct Sales And Quotas unchanged, and click Finish.

8. The Cube Designer will open as a new tab in the Business Intelligence Development Studio as shown below:

Page 16: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 14

NOTE: In the measures pane, Fact Internet Sales and Fact Sales Quota may be underlined with blue crooked lines known as squiggly line. The blue squiggly line indicates a Best Practice Design Alert, also referred to as a AMO Warning, which is a build in alert that helps notify us how to potentially improve our solution design based on embedded best practices. You may also see red squiggly lines, which indicate an error in your design. In Exercise 3 you are to learn more about the Best Practice Design Alerts and how to leverage them.

Task 7: Create a hierarchy in the time dimension

1. In the dimensions pane/explorer, expand Dim Time and click Edit Dim Time as shown below:

2. The Dimension Designer that opens has three panes: One for Attributes, another for Hierarchies and a third for the Data Source View. Drag and drop the CalendarYear, Quarter, EnglishMonthName & DayNumberOfMonth attributes from the Data Source View pane to Attributes pane. Note that the order is not important)

3. To create a hierarchy, drag and drop the Calendar Year attribute from the Attributes pane to the Hierarchies pane.

4. Drag and drop the Quarter attribute from Attributes pane to the on <new level> area of the Hierarchies pane, below the Calendar Year attribute. Note that a highlight will appear as visual indicator

5. Drag and drop the English Month Name attribute from Attributes pane to the <new level>area of the Hierarchies pane, below the Quarter attribute. . Note that a highlight will appear as visual indicator

6. Drag and drop the Day Number of Month from attribute from Attributes pane to the <new level> area .of the he Hierarchies

Page 17: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 15

pane, below the English Month Name attribute. Note that a highlight will appear as visual indicator

7. Right click the Hierarchy title and click Rename. Rename to “Calendar Hierarchy”.

8. The hierarchy should look like as shown below:

9. Click Save All to save the project and close the dimensions designer.

Task 7: Modify the Relationship between a Measure Group and a Dimension

10. In the Cube Designer, (the tab called Direct Sales and Quotas.cube [Design]) click the Dimension Usage tab. Note you can also select the Cube | View | Dimension Usage menu item.

11. In the Fact Sales Quota measure group column, click the Dim Time cell (that is, the cell in the Dim Time row that contains the text "Time Key") to activate the cell, On the right side of the cell, click the ellipsis (_) button as shown below:

12. In the Define Relationship dialog box in the Granularity attribute drop-down list, select CalendarYear.

13. In the Relationship table, click the first cell of the Measure Group Columns column. In the drop down list select CalendarYear.

14. The dialog box should look like shown below:

Page 18: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 16

15. Click OK.

NOTE : We have now set the granularity level to Calendar Year, which will allow uses of the deployed solution to drill down into the data on yearly basis only.

NOTE: Analysis Services allows each measure group to have a different relationship to the cube's dimensions. For example, there are daily sales, but only annual sales quotas

16. In the Fact Internet Sales measure group column, click the Customer Key cell . On the right side of the cell, click the ellipsis (_) button.

17. In the Define Relationship dialog box, in the Select relationship

Page 19: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 17

type drop down list select No relationship, and then click OK.

NOTE: This will ensure that users cannot slice and dice the cube based on the customer dimension. In other words, we don’t want to categorize the measures based on customers)

18. In the Fact Internet Sales measure group column, click the cell of the Dim Time row (the cell is blank). On the right side of the cell, click the ellipsis (_) button.

19. In the Define Relationship dialog box, in the Select relationship type drop down list select Regular. In the Granularity attribute drop down list, click Time Key.

20. In the Relationship table, in the first row of the Measure Group Columns column, select ShipDateKey. Click OK.

21. Verify that the Dimension Usage configuration matches the image shown below:

Task 8: Create Perspectives

INTRO: A perspective is a subset of a cube's measure groups and dimensions. You may want to create a perspective to provide a more focused view of a cube or to restrict access.

1. In the Cube Designer click the Perspectives tab. You can also select Cube | View | Perspectives.

NOTE: The Perspectives tab is the seventh tab in the Cube Designer View and you may need to scroll to the right in order to see the Perspectives tab

Page 20: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 18

2. Select the Cube | New Perspective menu item.

3. In the Cube Designer, under the column heading Perspective Name, click the Perspective cell, chance the current Perspective name to Direct Sales, as shown below, and then select <Enter>.

4. Select the Cube | New Perspective menu item.

5. In the Cube Designer, under the second column heading Perspective Name, click the Perspective cell, change the current perspective name to Quotas, and then select <Enter>.

6. In the Direct Sales and Quotas columns, select or deselect each cell by clicking on the check box, as shown below:

NOTE : Perspectives are smaller subsets of a cube. By selecting or deselecting measures and dimensions of the cube we are creating a selective view of the cube data for a certain perspective

Page 21: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 19

Task 9: Design Storage 1. In the Cube Designer, click the Partitions tab. Make sure that the Fact Internet Sales section is expanded as shown below:

Page 22: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 20

NOTE: You expand or collapse the section you are interested in by clicking on the arrow on the left-hand side in each section

2. In the Fact Internet Sales section, click Design Aggregations. The Aggregation Design Wizard dialog opens. Click Next.

3. Review the Aggregation Usage. Click Next……

NOTE: A cube's data and aggregations may be stored in relational or multidimensional structures. Aggregations are pre-calculated summaries designed to reduce query response time

4. On the Specify Objects Count page, click the Count button and wait for the wizard to complete counting objects and then click Next.

NOTE : Analysis Services may take a few moments to count the number of members in each attribute.

5. On the Set Aggregation Options page, click Performance gain reaches; in the Performance gain reaches % box, type “20” as shown below:

Page 23: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 21

6. Click the Start button. Wait for the wizard to complete designing aggregations and then click Next.

7. On the Completing the Wizard page, select Save the aggregations but do not process them, and then click Finish.

Task 10: Deploy the Analysis Services Solution

INTRO: In the above procedures, various wizards and editors have been creating XML code based on your input. Deployment sends the XML code to the Analysis Server and then processes and creates the Analysis Services database.

1. Select the Build | Deploy Analysis Services menu item.

NOTE: The Analysis Services project is automatically saved when you click Deploy Solution.

2. The deployment progress is also shown in the Deployment Progress pane on the right hand side of the Business Intelligence Development Studio as shown below. The Deployment Progress pane can gives you detailed information about what happens during deployment.

NOTE: The deployment will take a few moments to complete

Page 24: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 22

3. Once deployment is complete, the deployment window will display a message “Deployment Completed Successfully” with a large check icon to the left of the message as shown below:

SUMMARY : You have successfully created a new Analysis Services project. The project is created in a new solution and the solution is the largest unit of management in the Business Intelligence Development Studio environment. The solution contains one or more projects and you can view the solution and its projects in the Solution Explorer pane on the right hand side in the Business Intelligence Development Studio. An Analysis Services Project is a group of related files containing the XML code for all of the objects in an Analysis Services database.

Next we are to browse the cube

Page 25: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 23

Exercise 2: Browsing the cubeIn this exercise, we shall browse the cube.

Task Detailed Steps

Task 1: Browse the cube 1. If the project is not already open, navigate to C:\SQLHOLs\Designing Analysis Services Solutions \Analysis Servicesand double click Analysis Services.sln to open the project

2. In the Cube Designer, click the Browser tab.

NOTE: You can enlarge the Browse view of the Cube Designer by selecting the View | Full Screen menu item. You can return to normal view by repeating the process)

NOTE: If the Browse view of the Cube Designer is accidentally closed, it can be reopened. Select the View | Solution Explorer menu item. Then in the Solution Explorer pane under the Cubes folder, right-click Direct Sales And Quotas.cube, and then click Browset tab.

3. In the Browse view, in the pane on the left hand side - (the Metadata pane), expand the Measures , then expand the Fact Internet Sales folder, click the Sales Amount measure, drag it to the result pane and drop it in the the Drop Totals or Detail Fields Here area.

4. In the Metadata pane, under the Measures, expand the Fact Sales Quota folder, click the Sales Amount Quota, drag it to the data pane and drop it in the Drop Totals or Detail Fields Here area to the right of the Sales Amount . Note that a blue line will appear as an indicator

NOTE: At any point in time, you can right click the data pane and select Clear Results from the context menu to start over again

5. In the Metadata pane, click the DimTime dimension and drag it to the results pane and drop it in the Drop Row Fields Here area.

6. In the data pane, click the empty white space to deselect everything. Then right-click CalendarYear and click Expand Items, as shown below:

Page 26: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 24

Task Detailed Steps

7. After expanding Calendar Year, the next level in the hierarchy, Quarter is displayed as shown below:

Page 27: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 25

Task Detailed Steps

8. In the data pane, click the empty white space to deselect everything. Right click Quarter and then click Expand Items. The next level in the hierarchy, English Month Name is displayed.

9. The cube data looks like shown below.

Task 2: Understand the cube data.

The cube data look like shown below. Now, let us have a look at the data and aggregations that we are exploring. Note that the explanations below are marked with numbers in the diagram)

Page 28: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 26

Task Detailed Steps

1. As we know from building the cube, the time dimension (DimTime) is a hierarchical dimension that we can drill down into all all the way to Day Number of Month, which is the lowest level of granularity. For example, you can click (+) next to the month name to see the days for that month.

2. The Sales Amount measure can be expanded all the way down to Day Number of Month because TimeKey is the granularity attribute under Fact Internet Sales measure group in Dimensions Usage. (Verify this by clicking on Dimensions Usage tab and look under Fact Internet Sales column, Dim Time row. You will notice that TimeKey is the granularity attribute)

3. The Sales Amount Quota measure on the other hand, will only show figures on yearlevel, .The reason being that the Calendar Year is the granularity attribute under Fact Sales Quota measure group in Dimensions Usage. (Verify this by clicking on Dimensions Usage tab and look under Fact Sales Quota column, Dim Time row. You will notice that Calendar Year is the granularity attribute. We had set this in Task 7 of Exercise 1)

4. You can further drill down the data by dragging-and-dropping more dimensions to the data pane.

5. You can filter the data by dragging-and-dropping Dimensions attributes in Drop Filter Fields Here.

6. You can also filter the data by Dimension using the pane marked 6.

Next Exercise: Creating, Enhancing Dimensions & Hierarchies

Page 29: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 27

Exercise 3: Creating and enhancing Dimensions and Hierarchies

In this exercise we are going to create new dimensions and hierarchies. We are also going to lean about best Best Practive Design Alerts (AMO warnings)

Task Detailed Steps

Task 1: Create a new dimension

INTRO: We are now to create a new, additional time dimension

1. If the project is not already open, navigate to C:\SQLHOLs\Designing Analysis Services Solutions\Analysis Services and double click Analysis Services.sln to open the project.

NOTE: If the Solution Explorer pane is not visible, select the View | Solution Explorer menu item

2. In the Solution Explorer pane, right click the Dimensions folder and select New Dimension…

3. The New Dimension Wizard opens.

4. On the Welcome to the Dimension Wizard page, click Next.

5. On the Select Creation Method page, select Use an existing table

6. Click Next

On the Specify Source Information page, ensure that The Direct Sales and Quotas is the selected Data Source View. In the Main table drop down list, select DimTime. Key columns should list Timekey. In the Name column drop down list select FullDataAlternateKey .

7. Click Next

8. On the Select Dimension Attributes page, under the Available attributes section, perform the following actions:

a. Select Day Number Of Week, Day Number Of Month, Day Number Of Year, English Month Name, Calendar

Page 30: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 28

Task Detailed Steps

Quarter, Calendar Year, and Calendar Semester

b. Rename Time Key to Date

c. Rename English Month Name to Month

d. Deselect Enable Browsing for Day Number Of Week, Day Number Of Month and Day Number Of Year.

NOTE: This will disable users from browsing the above attributes when the cube is deployed.

e. The dialog should look as shown below:-

Page 31: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 29

Task Detailed Steps

9. Click Next

10.

On Completing the Wizard page, enter New Time as the name of the dimension.

NOTE: We already have a Time Dimension, hence we name this dimension as New Time

11. Click Finish

12. The Dimension Designer opens.

Task 2: Define Hierarchies

INTRO: Best Practice Design alerts, also referred to as AMO Warnings are blue squiggly lines that appear at design time are you design your solution. The Best Practice Design Alters are notifications providing suggestions as to how you can improve your design. They are optional and can be ignored if desired.

Red squiggly lines are errors and have to be fixed.

Note that the New Time hierarchy name has a blue squiggly. If you hold

Page 32: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 30

Task Detailed Steps

the mouse cursor over it, a warning message is displayed in the tool tip, notifying you that you have a non-parent child dimensions without hierarchies

Also note that the Day Number Of Week, Day Number Of Month and Day Number Of Year attributes that we disabled for browsing are grayed. Since we cannot use them for browsing we cannot use these attributes to build hierarchies.

Now, we are to build hierarchies for our new dimension

1. Drag the Calendar Year attribute from the Attributes pane and drop it in the Hierarchies pane. A hierarchy as the one below have been created:

2. Drag the Calendar Semester attribute from the Attributes pane and drop it on the <new level> field below Calendar Year in the Hierarchies pane. You will notice a blue border before dropping. Your hierarchy should now look as follows:

Page 33: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 31

Task Detailed Steps

3. Drag the Calendar Quarter attribute from the Attributes pane and drop it on the <new level> field below Calendar Semester in the Hierarchies pane.

4. Drag the Month attribute from Attributes pane and drop it on the <new level> field below Calendar Quarter in the Hierarchies pane.

5. Finally drag the Date attribute from the Attributes pane and drop it on the <new level> field below Month in the Hierarchies pane.

The final hierarchy should like as shown below:

6. Rename the hierarchy to a more meaningful name. Click the title Hierarchy and press F2. (Or right click and select Rename)

7. Type Calendar

8. You will notice a new blue squiggly under Calendar. Move your mouse cursor over the squiggly to review the warning message. The alert notifies us that we have not defined any relationships between our attributes, which can negatively impact performance of the deployed cube. Thus, next step is to define our attribute relationships.

Task 3: Define Attribute Relationships

1. Click the Attribute Relationships tab of the Dimension Designer. You will notice a graphical view of the relationships in the hierarchy as shown below:

Page 34: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 32

Task Detailed Steps

2. Drag Calendar Semester and drop it over Calendar Year

3. Drag Calendar Quarter and drop it over Calendar Semester

4. Drag Month and drop it over Calendar Quarter

You will see the relationships defined as shown below:

5. Now the relationships are defined.

Task 4: Check and dismiss Best Practice Design Alerts & errors

INTRO: Now we are to take a closer look at some of the best Practice Design Alerts, the AMO warnings and errors. We will purposely provoke errors to illustrate the Best Practices Design Alerts in action

1. In the Attribute Relationships tab, expand the Date attribute by clicking the down arrow as shown below:

Page 35: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 33

Task Detailed Steps

2. Drag Day Number of Month and drop it over Month. You should see a red squiggly line as shown below:

NOTE: You may remember that we disabled Day Number of Month for browsing. Therefore this member property cannot be used as a child of Month. The red squiggly is an error and needs to be corrected. If not, the solution cannot be deployed. You can move the cursor over the red squiggly to see the error description

3. Drag the Date attribute and drop it over Month attribute. You will see something like this:

You will notice the exclamation mark. We have purposely made two different ways of navigating the hierarchy and the AMO warnings indicate that this as a redundant relationship.

NOTE: move the cursor over the exclamation mark to see the warning description. The redundancy is due to the additional relationship we incorrectly defined when adding the Day Number Of Month attribute. Deleting this incorrect relationship should correct the error.

4. Right click the arrow connecting Day Number Of Month to Month and select Delete. You need to right click the arrow precisely to get the correct context menu

Page 36: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 34

Task Detailed Steps

5. Click OK on the Delete Objects dialog box to delete the relationship.

You will notice that the warnings and errors disappear.

NOTE: If the Error List window is not visible you can view it by selecting View | Error List from the menu bar

6. Click the Dimension Structure tab. Note how the blue squiggly line under the Calendar hierarchy name has disappeared now that we have defined a relationship between the attributes in the hierarchy.

NOTE: You will still see \ a blue squiggly line under the New Time. As mentioned earlier, this is simply a warning, not an error that will prevent us from continuing. Thus for now we will disregard this alert, build the project and then re-visit the remaining AMO warning to check how we can further secure optimal design and performance after we have build the solution.

7. Select Build | Build Analysis Services menu item to build the project.

If the build process is successful, move on to step 9. In case you get build error, please execute the following steps:

a. Right click New Time and select Properties as shown below:

b. In the Properties windows, locate the ErrorConfiguration property and expand it by click the (+) icon.

Page 37: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 35

Task Detailed Steps

c. Change the value for KeyDuplicate property to IgnoreError as shown below:

d. Select the Build | Build Analysis Services menu item to build the project. You should be able to build the project successfullyChange the value again for KeyDuplicate property back to ReportAndStop.

e. Select the Build | Build Analysis Services menu item to build the project.

You can now move to step 9.

8. In the Error List window, notice the warnings that are being displayed.

NOTE: You should see approximately 9 warnings. We will not go through all of them, but will only handle the warnings related to the New Time dimension, we just created. There will be 2 warnings associated with the New Time dimension

9. Locate the warnings related to the New Time dimension as shown below:

Page 38: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 36

Task Detailed Steps

10. Right click the first warning and select Dismiss from the context menu. In this case visible attribute hierarchies are okay, since it’s simply a lab exercise. Thus in the Dismiss Warning dialog box, simply enter a comment stating that ‘for this solution visible hierarchies are acceptable’ and click OK. Right click the next warning, select Dismiss, from the context menu and add a comment stating that ‘the attribute relationship for this additional time dimension is okay as is’ and click OK. In this way the comments tied to each dismissal will help you communicate that warnings have been validated rather than ignored

Page 39: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 37

Task Detailed Steps

N OTE: You are most likely to have 2 warnings. In case you have more warnings related to the New Time dimension, you can dismiss them in a similar manner

11. After you have dismissed all the warnings related to the New Time dimension, you will notice that the blue squiggly under the New Time dimension disappears.

Task 5: Check the global errors and warnings

INTRO: The AMO Warnings can be handled by instance or globally. In the previous steps we worked with the warning at an instance level. Next we are to have a look at the global level.

1. Right click the Analysis Services project in Solution Explorer and select Edit Database as shown below:

Page 40: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 38

Task Detailed Steps

2. The database editor opens. Click the Warnings tab.

3. You will notice the warnings you dismissed earlier at the instance level along with the comments you added.

4. Select each warning and click Re-enable to enable the warnings again.

NOTE: You can disable warnings for all projects by using the Design Warning Rules section

5. In the Design Warning Rules pane, expand Dimension Design by

Page 41: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 39

Task Detailed Steps

clicking the (+) icon.

6. Locate the warning Define attribute relationships as ‘Rigid’ where appropriate.

7. Uncheck the warning as shown below:

Note: The above action will dismiss the warning globally, meaning no warning messages related to this Best Practice Design Alert will appear later on.

8. Click the [x] button to close the editor.

9. Click Save in the Save changes dialog box.

10. Select the Build | Build Analysis Services menu item to build the project.

11. In the Error List you will notice only one warning related to NewTime dimension this time. You will not see the warning that you globally dismissed in Design Warning Rules section above.

Task 6: Browse the New Time dimension

1. Select the Build | Deploy Analysis Services menu item to build the project.

2. Select the Dimension | Process menu item to process the dimension.

3. Click Run in the Process Dimension – New Time dialog box.

4. After processing is complete, click Close in the Process Progress dialog box.

5. Click Close in the Process Dimension – New Time dialog box.

6. In the Dimensions Designer (the Dimension Structure tab), click the Browser tab.

7. If required, click the Reconnect button on the toolbar to refresh the browser with the updated content as shown below:

8. Ensure that Calendar hierarchy is selected in the Hierarchy drop

Page 42: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 40

Task Detailed Steps

down list:

9. You can now browse the Calendar hierarchy of the New Time dimensions as shown below:

Exercise 4: Creating Calculated Members & KPIsIn this exercise, we are to create Calculated Members and Key Performance Indicators.

Task Detailed Steps

Task 1: Create a calculated member

1. If the project is not already open, navigate to C:\SQLHOLs\Designing Analysis Services Solutions\Analysis Services and double click Analysis Services.sln to open the project.

NOTE: If the Solution Explorer pane is not visible, select the View | Solution Explorer menu item

If the Direct Sales And Quotas.cube file is not visible in the

Page 43: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 41

Task Detailed Steps

Information:

Calculated members are stored MDX expressions. They simplify queries used to perform complex analysis.

Solution Explorer pane, expand the Analysis Services database and then expand the Cubes folder.

2. Note: In case you happened to skip the previous exercise, you need to deploy the solution in order to proceed. Select the Build | Deploy Analysis Services menu item to deploy the project.

3. In the Solution Explorer pane, double-click Direct Sales And Quotas.cube. The Cube Designer will open.

4. In the Cube Designer, click the Calculations tab.

5. In the toolbar of the Calculations tab, make sure the Form View button is selected as shown below:

6. Select the Cube | New Calculated Member menu item. Alternatively, you can use New Calculated Member button on the toolbar

7. In the Name text box, type “[Quota Variance]. Ensure that the square brackets are included. In the Calculation Tools pane, on the Metadata tab, expand Measures, then expand Fact Internet Sales, click Sales Amount, drag it to the detail pane and drop it in the Expression text box.

8. In the Expression text box, click anywhere in the blank area to deselect [Measures].[Sales Amount], and type “−” (minus sign).

9. In the Calculation Tools pane, on the Metadata tab, expand Fact Sales Quota, click Sales Amount Quota, drag it to the detail pane and drop it in the Expression text box to the right of the minus sign.

The Expression text box should now contain the following :

[Measures].[Sales Amount]-[Measures].[Sales Amount Quota]

NOTE: You may copy-paste the code if required

10. Select Build | Deploy Analysis Services menu item to deploy the

Page 44: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 42

Task Detailed Steps

project.

11. Select Cube | Process menu item to process the cube.

12. Click Run in the Process Cube dialog box.

13. After processing is complete, click Close in the Process Progress dialog box.

14. Click Close in the Process Cube dialog box.

15. In the Cube Editor, click the Browser tab.

16. If required, click Reconnect button on the toolbar to refresh the browser with the updated content as shown below:

17. In the browser, in the Measure Group pane, expand the Measures folder, expand the Fact Internet Sales folder, click the Sales Amount measure, drag it to the data pane and drop it on the Drop Totals or Detail Fields Here area.

18. Expand the Fact Sales Quota measure group folder Click the Sales Amount Quota measure, drag it on to the data pane and drop it in the Drop Totals or Detail Fields Here area to the right of the Sales Amount measure. . Add Quota Variance - the calculation we created earlier located in the Fact sales Quota folder too

19. In the Measure Group pane, click Dim Time, drag it to the data pane and drop it in the Drop Row Fields Here area.

You should see a output that looks like follows:

Page 45: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 43

Task Detailed Steps

Task 2: Create a KPI 1. In the Cube Designer click the KPIs tab.

2. Select the Cube | New KPI menu item. Alternatively, you can use New KPI button on the toolbar

3. In the Name text box, type Quota Status

4. In the Calculations Tools pane, in the Metadata pane, expand Measures, expand Fact Internet Sales, and then click Sales Amount, drag it to the data pane and drop it in the Value Expression text box.

5. In the Calculations Tools pane, under the Fact Sales Quota folder under Measures, click Sales Amount Quota, drag it to the data pane and drop it in the Goal Expression text box.

6. In the Status section, in the Status Indicator drop down list, select Traffic Light.

7. In the Status Expression text box, type

Iif([Measures].[Quota Variance]<0,-1,1)

8. Select the Build | Deploy Analysis Services menu item to deploy the project.

9. Select the Cube | Process menu item to process the cube.

10. Click Run in the Process Cube dialog box.

11. After processing is complete, click Close in the Process Progress dialog box.

12. Click Close in the Process Cube dialog box.

13. Select the Cube | Show KPIs in | Browser menu item. You should now see the view shown below, which is how the KPI will be exposed to users accessing it through their BI tool or application once the cube is deployed:

NOTE: If required, click Reconnect button on the toolbar to refresh the browser with the updated content

Page 46: Lab14 Designing Analysis Services

SQL Server 2008 Analysis Services: Designing and Extending Analysis Services Solutions 44

Task Detailed Steps

14. You have now completed the Hands On Lab on designing and extending Analysis Services solutions.

15. Select the File | Exit menu item to close the SQL Server Business Intelligence Studio.