Chapter 7: Automate Repetitive Database Tasks
5.6 Connect to OLAP Data in Microsoft SQL Server
You can use Microsoft SQL Server Analysis Services to summarize data originating in large data warehouses. The summarized data is typically stored in one or more cubes or cube files.
You can use Excel to view the summarized data in these cubes and cube files.
■ Note For more information about cube files, see section “1.5: Learn About Multidimensional Databases”
in Chapter 1.
Quick Start
In Excel, to open and work with the data in a cube or cube file, do the following:
1. In Excel 2007, click Data ➤Get External Data ➤From Other Sources ➤From Microsoft Query. In Excel 2003, click Data ➤Import External Data ➤New Database Query.
2. In the Choose Data Source dialog box, on the OLAP Cubes tab, do the following if the desired cube or cube file is not visible; otherwise, skip to step 3:
a. With the <New Data Source> item selected, click OK.
b. Complete the options in the Create New Data Source dialog box, and then click OK.
3. Select the cube or cube file on the OLAP Cubes tab, and then click OK.
4. Complete the options in the Import Data dialog box, and then click OK.
5. Use the PivotTable Field List to create and work with a PivotTable and optionally a PivotChart.
C H A P T E R 5 ■ C O N N E C T TO OT H E R D ATA B A S E S 131
How To
In Excel, to open and work with the data in a cube or cube file, do the following:
1. In Excel 2007, click Data ➤Get External Data ➤From Other Sources ➤From Microsoft Query. In Excel 2003, click Data ➤Import External Data ➤New Database Query.
2. In the Choose Data Source dialog box, on the OLAP Cubes tab, do the following if the desired cube or cube file is not visible; otherwise, skip to step 3:
a. With the <New Data Source> item selected, click OK.
b. In the Create New Data Source dialog box, in the What Name Do you Want to Give Your Data Source, type a name for the cube or cube file data source.
c. In the Select an OLAP Provider for the Database You Want to Access list, select the appropriate OLAP provider, depending on the cube or cube file’s data format.
d. Click the Connect button.
e. Go to the Multidimensional Connection dialog box, and do the following:
• If the cube is stored in a SQL Server Analysis Services server, with the Analysis Server option selected, in the Server box, type the server name on which the cube is stored (and if needed, type the appropriate user name in the User ID box and password in the Password box); click Next; specify the database on which the cube is stored; and then click Finish.
• If the cube file is stored in a file with the .cub extension, click the Cube File option, and type the full path to the cube file; or click the ellipsis (. . .) button, browse to and select the desired cube file, click Open, and then click Finish.
f. In the Create New Data Source dialog box, click OK.
3. Select the desired cube or cube file on the OLAP Cubes tab, and then click OK.
4. Complete the options in the Import Data dialog box to create a PivotTable, a PivotTable and PivotChart, or a connection file only, and put the data on an existing worksheet or new worksheet, and then click OK.
5. Use the PivotTable Field List to create and work with a PivotTable (and optionally a PivotChart).
Try It
In this exercise, you will use Excel to connect to and view data in a cube stored on a Microsoft SQL Server Analysis Services server.
INSTALLING SQL SERVER AND THE SAMPLE DATA
This exercise was written using Microsoft SQL Server 2005 Standard Edition and Microsoft SQL Server 2005 Analysis Services installed, with the AdventureWorksDW sample database, Analysis Services Tutorial sample Analysis Services database, and Analysis Services Tutorial sample cube deployed accordingly. For more infor- mation, see the following:
• For more information on SQL Server 2005 Standard Edition see http://www.microsoft.com/sql/
editions/standard.
• For more information on SQL Server 2005 Analysis Services see http://www.microsoft.com/sql/
technologies/analysis.
• To install the AdventureWorksDW sample database on SQL Server 2005, search the Microsoft Download Center at http://www.microsoft.com/downloadsusing the AdventureWorkskeyword, and then click the SQL Server 2005 Samples and Sample Databases link.
• For more information on creating and deploying the Analysis Services Tutorial sample database and sample cube, see the SQL Server 2005 Analysis Services Tutorial in SQL Server 2005 Books Online. To install SQL Server 2005 Books Online, search the Microsoft Download Center at http://www.
microsoft.com/downloadsusing SQL Server 2005 Books Onlineas the search text, and then click the resulting SQL Server 2005 Books Online link.
To connect to the Analysis Services Tutorial cube on the Analysis Services server, do the following:
1. With Excel started and a blank workbook visible, in Excel 2007, click Data ➤Get Exter- nal Data ➤From Other Sources ➤From Microsoft Query. In Excel 2003, click Data ➤ Import External Data ➤New Database Query.
2. Go to the Choose Data Source dialog box, on the OLAP Cubes tab, and do the following:
a. With the <New Data Source> item selected, click OK.
b. In the Create New Data Source dialog box, in the What Name Do You Want to Give Your Data Source, type AdventureWorksCube.
c. In the Select an OLAP Provider for the Database You Want to Access List, select Microsoft OLE DB Provider for Analysis Services 9.0.
d. Click the Connect button.
3. In the Multidimensional Connection 9.0 dialog box, do the following:
a. With the Analysis Server option selected, in the Server box, type the server name on which the cube is stored (and if needed, type the appropriate user name in the User ID box and password in the Password box), and then click Next.
b. In the Database list, select Analysis Services Tutorial, and then click Finish.
C H A P T E R 5 ■ C O N N E C T TO OT H E R D ATA B A S E S 133
4. In the Create New Data Source dialog box, in the Select the Cube That Contains the Data You Want list, select Analysis Services Tutorial, and then click OK.
5. In the Choose Data Source dialog box, on the OLAP Cubes tab, select Adventure- WorksCube, and then click OK.
6. In Excel 2007, in the Import Data dialog box, with the PivotTable Report option and Existing Worksheet option selected, click OK. A PivotTable is created on the current blank worksheet and the PivotTable Field List is displayed. In Excel 2003, in the Pivot- Table and PivotChart Wizard – Step 3 of 3 dialog box, with the Existing Worksheet option selected, click Finish. A PivotTable is created on the current blank worksheet and the PivotTable Field List is displayed.
To view the data with the PivotTable, do the following:
1. In Excel 2007, in the PivotTable Field List (shown in Figure 5-1), in the Choose Fields to Add to Report list, select the following:
a. Sales Amount check box (in the Internet Sales section)
b. State Province Name – Geography check box (in the Customer section) c. OrderDate.CalendarYear – CalendarSemester – CalendarQuarter –
EnglishMonthName – FullDateAlternateKey check box (in the Order Data section)
Figure 5-1.Selecting the fields to add to the PivotTable in Excel 2007
2. In Excel 2003, in the PivotTable Field List, click the following:
a. Click the Sales Amount field near the bottom of the list; make sure that Data Area is showing in the Add To list, and click the Add To button (as shown in Figure 5-2).
b. Click the State Province Name field; make sure that Row Area is showing in the Add To list, and click the Add To button.
c. Click the OrderDate.CalendarYear – CalendarSemester – CalendarQuarter – EnglishMonthName – FullDateAlternateKey field, select Column Area in the Add To list, and click the Add To button.
Figure 5-2.Selecting the fields to add to the PivotTable in Excel 2003
C H A P T E R 5 ■ C O N N E C T TO OT H E R D ATA B A S E S 135
137
C H A P T E R 6
■ ■ ■
Analyze Data
Excel provides a rich set of tools to enable you to analyze your data to help you make impor- tant decisions based on the outcome of that analysis. Excel data analysis techniques such as sorting, filtering, and subtotaling data; creating data tables; consolidating data; grouping and outlining data; creating tables/lists; creating scenarios; goal seeking; using Solver; creating PivotTables and PivotCharts; and performing statistical data analysis are covered in this chapter.