Integrating Microsoft SQL Server 2000 OLAP and Microsoft Office: OLAP Reporting with an Office PivotTable List
Publishing an Excel PivotTable Report as an Office PivotTable List
Let's approach the creation of a PivotTable list first from the perspective of the PivotTable report. We'll create a quick report to use as a basis for this part of the lesson, both as a review for Part 1 of this series, and to make this a stand-alone lesson (an objective of this series). If you need to review the details of any of the steps involved, refer to Part 1 of this series.
Setting Up the Base PivotTable Report
The PivotTable Wizard provides a guided process for connecting Excel to the OLAP cube. Begin by taking the following steps:
Open a new workbook in Excel 2000 (or beyond).
To initialize the PivotTable and PivotChart Wizard, choose Data, PivotTable and PivotChart Report.
The Step 1 of 3 wizard dialog box appears.
Select External Data Source and then click Next.
The Step 2 of 3 dialog box appears.
For this tutorial, we'll use the sample OLAP cube called HR. Click the Get Data button.
Microsoft Query starts, and presents the Choose Data Source dialog box.
Click the OLAP Cubes tab, select <New Data Source>, and click OK.
The Create New Data Source dialog box appears (see Figure 1).
Figure 1 The Create New Data Source dialog box.
Type HR Cube in box 1. Select Microsoft OLE DB Provider for OLAP Services 8.0 in box 2.
Click the Connect button.
The Multidimensional Connection dialog box appears.
Select Analysis Server as the location of the multidimensional data source. Enter the server name, user ID, and password, and then click Next.
In Figure 2, I supplied localhost as the server name. The name localhost can be supplied if Excel and the cube share the same server machine.
Figure 2 The Multidimensional Connection dialog box.
The next Multidimensional Connection dialog box appears, asking for the target database/OLAP data source.
Select the FoodMart 2000 database that accompanied the Analysis Server installation, and then click Finish.
The Create New Data Source dialog box reappears, with the new target data source indicated to the right of the Connect button.
Select the HR cube in box 4 (see Figure 3), and then click OK to return to the Choose Data Source dialog box.
Figure 3 The completed Create New Data Source dialog box.
Select HR Cube as the data source (see Figure 4), and then click OK to return to the Step 2 of 3 dialog box (see Figure 5). Notice that Data Fields Have Been Retrieved now appears to the right of the Get Data button.
Figure 4 The HR Cube data source is selected.
Figure 5 Data fields have been retrieved.
An empty PivotTable report appears, with the PivotTable toolbar floating alongside it.
Drag the Count button (a measure) from the PivotTable toolbar to the Data section (the portion of the PivotTable area that displays Drop Data Items Here), and drop the Count button.
Most of the framework highlights disappear, and the PivotTable report begins to take shape, showing the Total of Count.
Drag the Store dimension to the row axis of the PivotTable report, where Total appears at present for Count.
Drag the Time dimension to the column axis of the PivotTable report, where the empty cell appears to the right of Count and above Total.
Drag the Store Type dimension to the page axis of the PivotTable report.
Drag the Department Description button from the PivotTable toolbar to the right of the Store Country column. The result set should resemble that shown in Figure 6.
Figure 6 The result set so far.
Click the arrow button to the right of the Year column heading, uncheck 1997 (see Figure 7) to narrow the reporting scope for now, and click OK.
Figure 7 Deselecting 1997.
Drag the Pay Type button to the right of the Year column.
Select PivotTable, Table Options on the PivotTable toolbar (see Figure 8) to display the PivotTable Options dialog box.
Figure 8 Selecting the table options.
Figure 9 The PivotTable Options dialog box.
Figure 10 The PivotTable Report with modifications.
For information about the other setpoints, see the online Help and other documentation.
Select File, Save As and save the worksheet as Headcount_PivotTable report.xls, simply to preserve its contents.
Publishing the Base PivotTable Report
Now we'll publish the report as an interactive web page.
Choose File, Save As, and select Web Page in the Save as Type box at the bottom of the Save As dialog box.
Click the Change Title button, and use the following title:
Headcount: Location, Department and Employee Type
Type Headcount in the File Name text box (see Figure 11) and click the Publish button.
Figure 11 Save the PivotTable report as a web page.
The browser launches, and the Publish as Web Page dialog box appears.
In the dialog box, select the following items (see Figure 12):
- Item to Publish: PivotTable
- Add Interactivity With: PivotTable Functionality
- Open Published Web Page in Browser.
Figure 12 The completed Publish as Web Page dialog box.
Click Publish. Compare your results to Figure 13.
Figure 13 The PivotTable list based on the Headcount PivotTable report.
Working with the PivotTable List
Having created a PivotTable list from a standard PivotTable report, we can now begin to explore the features of the PivotTable list. As we discuss some of its nuances and practice using the list, we'll compare it to the PivotTable report explored in Part 1 of this series.
Click the Field List button, initializing the PivotTable field list window as shown in Figure 14. We'll return to the field list a little later.
Figure 14 The Field List button (in red square on the PivotTable toolbar), and the PivotTable field list window it initializes.
Click the PivotTable list title bar (the blue bar displaying HR in white, at the top of the PivotTable list) to select the entire PivotTable list.
Click the Property Toolbox button (to the left of the Field List button used in step 1 above).
The PivotTable Property Toolbox appears, with Entire PivotTable in the Selection box (see Figure 15).
Figure 15 PivotTable Property Toolbox.
The PivotTable Property Toolbox is context-sensitive, and is based on the section of the PivotTable list selected prior to clicking the Property Toolbox button (refer to step 3 above).
Leaving the PivotTable Property Toolbox in place, click the Store Type dimension label, simply to select it. The PivotTable Property Toolbox contents change to match the new context (see Figure 16).
Figure 16 The PivotTable Property Toolbox changes to match the new context.
You can manipulate the font, pitch, text format, and background, along with modifying the caption and show/hide characteristics. Keep in mind, however, that a limitation of the PivotTable list (but not the standard PivotTable report) is the restriction that you can only apply different backgrounds or fonts to three separate groups of items.
Chief among other functional differences (in my opinion) between the Excel PivotTable report and Office PivotTable list is the degree of control afforded the user with regard to dimension level handling. The PivotTable report allows easy manipulation of members and dimensions, but virtually none with dimension levels. The PivotTable list provides far more control and flexibility, by allowing direct interaction with the dimension levels.
Let's examine this concept with some detailed practice steps.
Close the PivotTable Property Toolbox and PivotTable field list window(s), if they're still open.
The three store countries were published from the original PivotTable report in the expanded mode. Let's zoom to the summary levels, to get a feel for the process. Click the minus (-) sign to the left of each of the Canada, Mexico, and USA store countries.
Expand the USA store country by selecting USA at the row axis, and then right-clicking and selecting Expand.
Notice that no Store levels appear below Store Country, even though we have expanded Store Country for USA. We can manipulate levels quite easily in the PivotTable list, however, and will do so via the following steps.
Click the Field List button, reinitializing the PivotTable field list window.
Expand the Store dimension within the PivotTable field list, and highlight the Store State level beneath it.
Drag the Store State level from the PivotTable field list onto the PivotTable list, dropping it when the blue line indicates a "drop zone" on the row axis, to the right of the Store Country column, as shown in Figure 17.
Figure 17 Adding a level into the row axis of the PivotTable list.
Right-click the Store State column heading and select Expand, to expand all the store states together.
The result should appear similar to that partially shown in Figure 18. Notice that the Expand selection expanded only the USA store states (as USA was the only expanded store country).
Figure 18 Expanding the new store state levelpartial view.
Click the drop-down arrow button at the Store Country label and clear the check boxes for Canada and Mexico, leaving USA as the only store country member. Then click OK.
Notice the immediate effect of the filter on the compactness of the PivotTable list. The selection/deselection of an item in the dimension tree acts in the PivotTable list as a filter, whereas in the PivotTable report, selection/deselection drives the appearance of items (and levels, if necessary) on the axis.
Another difference between the Office PivotTable list and the Excel PivotTable report is that, in the PivotTable list, whether members are visible or not, levels can be added or removed from an axis. By the same token, members can be visible only from the respective levels that are specified for inclusion on the axis. In a PivotTable report, the reverse is true: A level is visible on an axis if the level's members are visible. Making the children of a member visible will add the next level, if it exists.
To return to our scenario, management wants more detail in the report, and the capability to do "one-stop shopping." Many managers even want to be able to produce a list of the employees that make up the headcount numbers. Let's set about giving management what it wants.
To make this fit easily for our practice session, let's narrow the population a bit more. (Later, we'll discuss more options for sizing the display for information consumers.)
Drag the Store Country level off the PivotTable list.
A red X symbol is displayed, indicating removal, and the Store Country column disappears. If you click the Store State label's (newly appearing) drop-down arrow button, however, you'll see that Store Country is certainly present in spirit, even though it's invisible in the display. We retain our recent "USA only" filter, as is evident in the Store State selection that remains in the PivotTable list (see Figure 19).
Figure 19 It's "Exit, stage left" for the Store country, but the filter remains.
Drag the Store State level from the row axis immediately to the right of the Store Type dimension in the Filter area (the equivalent of the page axis in an Excel PivotTable report).
Click the drop-down arrow button at the Store State label, which now appears on the page axis.
Work down the Store hierarchy in the dimension tree to select the CA member (see Figure 20). Then click OK.
Figure 20 Filter to the CA store state.
Notice that the All top level automatically clears itself. (The page axis is referred to as the Filter Area, in PivotTable list terminology.)
If necessary, click the Field List button to reinitialize the PivotTable field list window.
Drag the entire Employees dimension from the PivotTable field list onto the PivotTable list, dropping it when the blue line indicates a drop zone on the row axis, to the right of the Department Description column (see Figure 21).
Figure 21 Adding the employee level directly.
Notice that this time we have not only dragged a level and its children over, but in effect we've nested an entire dimensional hierarchy as a predefined subset in one motion. It requires expanding, and it can certainly mean a crowded report, but the potential for high-leverage, user-friendly OLAP analysis here is immense.
Let's clean up a bit, and look at more features.
Expand the Department Description column by right-clicking the heading and selecting Expand from the context menu.
Notice that the CEO shows up on every line. This is not my idea of a great hierarchical design, and is of limited value in our filtered PivotTable list. The information is repeated on every row, and consumes space inappropriately (much as corner offices themselves are sometimes misallocated). We might find this level useful, if the PivotTable list presented the data for, say, a consolidated group of companies with more than one CEO, but since Ms. Nowmer apparently reigns alone, it might be safe to contract the reporting structure by the common field to conserve space.
Remove the CEO column from the PivotTable list by right-clicking the CEO label, and selecting Remove Field from the context menu.
Ms. Nowmer steps aside, but the newly appearing drop-down arrow button at the Senior Management level label indicates that the CEO filter remains available. This illustrates again the capability we gain in the PivotTable list to work more directly with levels, a distinct enhancement over an otherwise comparable PivotTable report.
Right-click the Senior Management label, and expand Senior Management by selecting Expand on the context menu.
The result set should resemble that partially shown in Figure 22.
Figure 22 Expanding the Senior Management column.
Scrolling down, we see that numerous departments appear to have further sublevels, while the departments at the top of the PivotTable list appear to go no further than the current level (as evidenced by the Total* entries that appear to their right).
Click the drop-down at the Department Description label on the column axis. Work down the Store hierarchy in the dimension tree to select the Store Management member, removing all other check marks.
The filtered view should resemble that partially shown in Figure 23.
Figure 23 The newly filtered PivotTable list.
Drag the Department Description field to the filter area, and drop it to the right of the Store label.
Click the Department Description drop-down arrow button to view the department members.
Notice that the filter (via the check boxes) has been reset to All. This is the default. Check the Store Management check box to reinstate the previous filter, and click OK.
Right-click the Senior Management column label, and select Property Toolbox from the context menu.
Click Captions to expand the section, and change the caption to read Sr Manager (see Figure 24). This will conserve space.
Figure 24 Changing the caption.
Expand the Format section and change the font to Arial Narrow, with a color of Indigo. (ToolTips display the color name when the mouse pointer is positioned over a color.)
Close the Property Toolbox. Compare your results to Figure 25.
Figure 25 Format changes enacted for the dimension/level labels.
Notice that the format changes applied to the Store Management level label are replicated to all dimension and level labels. This is another difference between the Office PivotTable list and the Excel PivotTable report: In the PivotTable report, you can change the formatting of any cell, just as with a standard Excel spreadsheet. In the PivotTable list, by contrast, you can change the fonts or backgrounds for only three main groups of items (and only to the group collectively):
- Dimension/level labels
- Individual item labels
Format settings for any member of the three groups apply globally in the PivotTable list to every member of the same group. The following steps illustrate this further.
Expand Level, Level 01, Level 02, and Level 03 by right-clicking and checking Expand on the respective context menu for each.
Right-click Jose Bernard in the Level 01 column, and select Property Toolbox from the context menu.
Expand the Format section, if necessary. Keep the Arial font, but change the font color to Dark Teal and the Background to White.
Close the Property Toolbox. Compare your results to Figure 26.
Figure 26 Format changes enacted for item labels.
Notice that changing formats for any member of a group (in this case, item labels) changes all members of the group simultaneously.
Right-click the Level 03 label and select Sort Descending from the context menu.
Right-click the Level 03 label and uncheck Subtotal in the context menu.
Total* in the Level 03 rows disappears.
Right-click the Level 04 label and select Remove Field from the context menu.
To select the entire PivotTable list, click the title bar (it shows HR in white at the top of the PivotTable list).
Right-click to open the context menu, and select Property Toolbox.
In the PivotTable Property Toolbox, expand the Totals section.
Set Total Orientation to Columns and uncheck the Total All Items check box.
Right-click Level 02 and uncheck Subtotal on the context menu.
Right-click Level 01 and uncheck Subtotal on the context menu.
Right-click Level and uncheck Subtotal on the context menu.
Close the Property Toolbox and compare your results to Figure 27.
Figure 27 The modified PivotTable list.
Select the entire PivotTable list again, right-click to open the context menu, and select Property Toolbox.
While we don't need to display empty rows in our report, many financial and accounting uses dictate that, even though something is zero, we might want to see it (say within a P&L statement, where a revenue line went from a million to nothing over a year). The next several steps help to show that zero-value items are still there, whether they appear or not; and that we can display them with a simple setpoint change.
In the PivotTable Property Toolbox, click the Display Empty Items section to expand it.
Select the Row check box, and then close the PivotTable Property Toolbox.
The PivotTable list now appears with all empty items shown.
Select the entire PivotTable list again, right-click to display the context menu, and select Property Toolbox.
The PivotTable Property Toolbox appears.
Uncheck the Row check box in the Display Empty Items section.
Figure 28 displays the Property Toolbox setpoint.
Figure 28 The PivotTable list with Display Empty Items Off.
Click the Field List button.
Drag the Employee Salary measure from the PivotTable field list to the data area of the PivotTable list.
Drop the measure immediately to the right of either Count measure column.
Notice that the Employee Salary measure appears in both Years' columns, to show a breakout over time as specified. The Office PivotTable list exposes a property for the control of the measures' placement (or orientation, as it's called in the PivotTable Property Toolbox). This is accomplished differently in an Excel PivotTable report, where multiple measures result in the creation of new data dimensions. In addition, measures are referred to as totals in the Office PivotTable list, representing another terminology difference in the two components.
Right-click the Employee Salary label.
The associated Property Toolbox appears, with a slightly different Format section than those we've seen up to this point.
Select Currency for Number Format (see Figure 29).
Figure 29 Property Toolbox for measures.
Change the Caption to Salary(000), to make sure that the salaries make sense to the potentially unwitting information consumer. (The caption should appear as shown in Figure 29.)
Close the Property Toolbox.
Select the entire PivotTable list again, right-click to open the context menu, select Property Toolbox, and expand the Totals section, if necessary.
Select the Total All Items check box.
Close the Property Toolbox. Figure 30 shows the final view of the PivotTable list.
Figure 30 Final view of the first Office PivotTable list.
While differing in many ways from the Excel PivotTable report, the Office PivotTable list offers more flexibility in certain areas, including the ability to more directly control totals.
After closing the browser used to display and manipulate the PivotTable list, notice that all modifications are lost, with the PivotTable list defaulting to the originally published display. The next section addresses the design of a PivotTable list using Microsoft FrontPage 2000, where you can save your changes at the design level.