Tài liệu Pro SQL Server 2008 Analysis Services- P9 docx

50 428 0
Tài liệu Pro SQL Server 2008 Analysis Services- P9 docx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

CHAPTER 14  USER INTERFACES 381 Figure 14-12. Nesting hierarchies Pivot Table Ribbons The easiest way to work with a pivot table is with the PivotTable Tools ribbons, which appear when you click inside the pivot table. There are two ribbons—one for general options and one for design, as shown in Figures 14-13 and 14-14. The ribbons are fairly self-explanatory, but I strongly recommend browsing through them as you start working with pivot tables, as it can be easy to forget they’re there and get frustrated trying to work with the pivot table itself. For example, selecting a pivot table to move it in a workbook is nontrivial, but straightforward with the Move PivotTable button on the Options ribbon. Figure 14-13. The pivot table options ribbon The most notable function on the Options tab is the ability to rename the pivot table. If you work with Excel named ranges a lot, you may find yourself a bit baffled as to how to name the pivot table by selecting a range on the worksheet. The easy answer is to just click inside the table and rename it on the Options tab. You can also select fields (column and row headers, value fields) and work with their settings, and expand or collapse them. With the Group Selection and Ungroup buttons you can select members from a hierarchy and create a custom grouping. For example, if you have all 50 states listed, you may want to group them into geographic regions. To do so, just select the states you want to group together and click the Group Selection button. Repeat to create additional groups—as you go, any ungrouped members will be swept into a group called Other. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 14  USER INTERFACES 382 Figure 14-14. The pivot table design ribbon The pivot table design ribbon is pretty descriptive—it provides the tools to change the appearance and layout of your pivot table. The drop-down buttons in the Layout section allow you to select whether to show grand totals and subtotals (for rows and/or columns), and whether to insert blank rows between items. The Report Layout selector offers compact, outline, or tabular layouts, as shown in Figure 14-15. Figure 14-15. Pivot table formats The checkboxes in the PivotTable Style Options section let you switch the styles for row and column headers on and off, and select whether to shade alternating rows or columns. Finally, the PivotTable Styles gallery provides a number of preformatted styles for pivot tables. You can preview how the style will affect your table by mousing over the styles without clicking on them. Also, you can drop down the gallery with the lower down-arrow to the right of the display, as shown in Figure 14-16. Figure 14-16. Opening the style gallery Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 14  USER INTERFACES 383 Formatting a Pivot Table Formatting the contents of a pivot table is as easy as highlighting the cells you want to change the format on and using the controls in the ribbon or the context menu. Note that you won’t be able to alter the structure of the pivot table—for example, trying to merge cells in a pivot table will raise an error prompting you with the options for what you’re trying to do. You can also use the Cell Styles drop-down, shown in Figure 14-17, for quick access to some standard styles and number formats. (I just discovered that there’s a quick style on there for Currency with no decimals. I’ve been doing that by hand.…) Figure 14-17. The Cell Styles gallery on the Home tab of the ribbon Another powerful option in Excel 2007 is to use conditional formatting for values. With conditional formatting, you can apply a specific style to cells based on the specific numeric value or the value in relation to other values, or even if it contains a specific text or is a date between certain dates. Conditional formatting is under the Conditional Formatting drop-down gallery in the Styles section of the Home tab on the ribbon. Figure 14-18 shows the Conditional Formatting gallery opened to the Highlight Cells Rules selection. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 14  USER INTERFACES 384 Figure 14-18. Conditional Formatting selectors Selecting New Rule near the bottom of the drop-down opens a dialog that provides a more fine- grained rule-editing capability. Ultimately you have the option of entering a formula to select which cells to format, and a custom format using any of the Excel cell formatting styles. One of my favorite format schemes is to apply data bars to a selection of cells, shown in Figure 14- 19. The bars behind the numbers give a quick visual indication of the relative magnitude of the values. It is important, however, to be careful not to include any subtotal or total rows, as those will obviously be far larger and dominate the layout. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 14  USER INTERFACES 385 Figure 14-19. Data bars in a pivot table Now that we understand how to create and format a pivot table, we also want to be able to use these values in other calculations (that’s a major reason we’re using Excel, right?). So let’s take a look at the ins and outs of using pivot table values in formulas. Formulas Using Pivot Table Values Let’s say you wanted to create a column next to your pivot table showing what the numbers would look like with 10% growth added on top. So you click in a cell, type an equal sign, and then click on a cell in the pivot table to reference it. You’ll end up with something looking like this: =GETPIVOTDATA("[Measures].[Internet Sales Amount]",$A$3, "[Product].[Product Categories]", "[Product].[Product Categories].[Product].&[374]") This is the function Excel puts in place to fetch the pivot table value, and it’s the reference you’ll get. This will work well enough—type “*110%” afterwards and you’ll see it calculates fine. The problem is when you copy that formula and try to paste it for all the values in the column. You’ll get the same value for every cell. Why is that? The GETPIVOTDATA function in this case has four arguments. These are the data field (Internet Sales Amount), a descriptor for the pivot table ($A$3, the cell reference for the table anchor), the field, and then the unique name for the specific cell. So when we copy and paste the cell reference, it keeps the unique name and we get the same value. Couldn’t we just type a cell reference for the value? Well, that would work, except that if either rows or columns contain a hierarchy, the user can expand and collapse the members of that hierarchy, giving Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 14  USER INTERFACES 386 us the result shown in Figure 14-20. Since the GETPIVOTDATA formula uses unique names to identify cells, then so long as the pointer to the pivot table is valid, the value will still work. Figure 14-20. The dangers of using cell references with pivot tables ■ Note One problem you can still run into is if the value you’re referencing gets hidden. For example, in Figure 14-20, if you were referencing a specific bike model and you then closed up the subcategory, the reference would break as well (but it would be valid again if the user opened that category again). Now that we have a feeling for putting our data together and formatting it in a pivot table, let’s create some visual displays of our data with pivot charts. Pivot Charts Being able to visualize data is every bit as important as actually viewing the data itself. In this section we’re going to create pivot charts in Excel to give a graphical view of the data in the pivot table. Figure 14-21 shows an example of such a chart. It’s important to remember that a pivot chart is always bound to a pivot table. When we talk about ProClarity and SQL Server Reporting Services charts later in the chapter, we’ll look at some very powerful charting capabilities as the result of linking directly to SSAS cubes. However, Excel pivot charts are limited to what’s in the pivot table. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 14  USER INTERFACES 387 Figure 14-21. A pivot chart showing sales by product category over twelve months There are three ways to create a pivot chart in Excel: • From the Insert tab on the ribbon, drop-down the PivotTable button and select PivotChart. You will be prompted to select either a table or range, or to use an external data source. Excel will automatically create a pivot table linked to the data source, and the pivot chart linked to the pivot table. • When you create a data connection, one of the options is to create a pivot chart with the pivot table. • If you’ve already created a pivot table, then while the table has focus, the Options tab under PivotTable Tools in the ribbon has a PivotChart button. There are many types of charts available in Excel, including bar charts, line charts, pie charts, and area charts. For each chart type there are various stylistic subtypes, as shown in Figure 14-22 for bar charts. Be careful not to spend too much time worrying about which type of chart to use—remember that the goal is to convey information, not win a beauty contest. For a more in-depth discussion about charting and chart types, I recommend Show Me the Numbers by Stephen Few (2004, Analytics Press). Figure 14-22. Selecting a bar chart type Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 14  USER INTERFACES 388 Each of the subtypes is generally a minor stylistic variation on the main chart type, but there are some significant standouts, most notably the stacked variations (where values are added together or presented as percentages). ■ Note When creating a chart from pivot table data, you can’t use an XY (scatter) chart, bubble chart, or stock chart, since these chart types require additional dimensions of data. Unfortunately, they’re not disabled in the chart-type selector, so you’ll get an error if you try to use them. As with the pivot table, when you create a pivot chart, Excel presents you with a number of new tabs on the ribbon to manage the chart, shown in Figure 14-23. This time we have four tabs: • Design: Here you can change the fundamentals of the chart—the chart type, data, rough layout (title and legend), and style. • Layout: This tab offers more specific layout options. There are selectors for the chart and axis titles, legend, data table (if there is one), axes, gridlines, plot area, and specific parts of the chart itself. You can also set the chart name here and insert objects into the chart. • Format: More finely-grained formatting for the chart objects. By selecting a chart item, e.g., the title or data labels, you can use the format galleries in the Format tab to apply a specific font, outline, fill, or other formatting. • Analyze: Here you’ll find the toggles for the field list and filters, as well as a button to refresh the pivot chart data and expand or collapse hierarchies, if used. Figure 14-23. The PivotChart Tools tabs in Excel Pivot charts really are fairly straightforward—since they’re bound to the underlying pivot table, most of your work will be done ensuring the data in that table is in the proper format for the chart. In Exercise 14-1 we’re going to use the AdventureWorks cube to create a pivot table and pivot chart so we can get a feel for how they work together. Exercise 14-1. Create an Excel PivotTable and PivotChart In this exercise we’ll walk through using Excel as a front end for an Analysis Services cube, including connecting to the cube, building a pivot table, configuring the pivot chart, and applying some Excel formatting. 1. Open Excel 2007. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 14  USER INTERFACES 389 2. Click the Data tab in the ribbon. 3. Click the From Other Sources button to drop-down the selector, and then click From Analysis Services, as shown in Figure 14-24. Figure 14-24. Creating an Analysis Services connection 4. This will open the Data Connection wizard, shown in Figure 14-25. Enter the name of your SSAS server (“localhost” if it’s on the same machine). Figure 14-25. The Data Connection Wizard 5. Click the Next button. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 14  USER INTERFACES 390 6. The next page allows you to select the database and cube that you want for the pivot table. Select Adventure Works DW 2008 (or whatever you named your AdventureWorks database) and then the Adventure Works cube, as shown in Figure 14-26. Figure 14-26. Selecting the SSAS database and cube 7. On the “Save Data Connection File and Finish” page, you can leave the defaults or edit the file name, friendly name, and description if you choose to. This step creates the data connection file in your file system (by default in $DOCUMENTS\My Data Sources\). 8. Click the Finish button. 9. Now you should see the Import Data dialog, which prompts whether you want to create a PivotTable, PivotTable and PivotChart, or just create the connection file (Figure 14-27). Select PivotTable Report and leave “Existing worksheet” selected for the location. Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. [...]... is, of course, SQL Server Analysis Services ■ Note Remember that SQL Server services can be run “a la carte.” Even if you have a significant investment in SQL Server 2005 as your data storage, you can still use SQL Server 2008 Reporting Services for reporting, and given the improvements in SSRS 2008, I highly recommend doing so Let’s take a look at some of the features of SSRS—paired with Analysis Services,... BIDS, create a new project (File New Project) 2 Select Report Server Project Wizard and give the project a name 3 Click the OK button to open the Report wizard 4 Ensure “New data source” is selected Name it SSAS DW 5 Select Microsoft SQL Server Analysis Services as the data source type 6 Click the Edit button In the Connection Properties dialog enter the server name for your SSAS server, and then select... starting with SQL Server Reporting Services SQL Server Reporting Services Another one of the BI services in the SQL Server platform is SQL Server Reporting Services Reporting Services is a web-based service for hosting and publishing reports Reports are natively published in HTML format, but can also be rendered as XML, in Excel, PDF, TIFF, or Word While Reporting Services runs as a SQL Server service,... lightweight overview of SQL Server Reporting Services For a more in-depth examination of the subject, I recommend Microsoft SQL Server 2008 Reporting Services by Brian Larson (McGrawHill, 2008) or Pro SQL Server 2008 Reporting Services by Landrum, McGehee, and Voytek (APress, 2008) Reports Between the new tablix control and advanced charting engine, Reporting Services is more powerful than ever Formatting... USER INTERFACES Figure 14-54 A chart in SQL Server Reporting Services 2008 To me, one of the best enhancements is access to properties In SSRS 2005, all charting properties were accessed through a single properties dialog, as shown in Figure 14-55 This was limiting to say the least—any little change or tweak to an axis or chart meant digging through pages of properties and hoping you had the right... SSRS 2008 called Tablix, which combines the best features of tables and matrices We’ll examine the new charting engine in Reporting Services, and finally take a quick look at the new Report Builder and how it enables self-service reporting ■ Note This is going to be a fairly lightweight overview of SQL Server Reporting Services For a more in-depth examination of the subject, I recommend Microsoft SQL Server. .. one shown in Figure 14-45 are possible Figure 14-45 A complex report using tablix in SQL Server Reporting Services 2008 Note that we have a matrix (products broken down by calendar quarter), but there’s also a yearover-year percentage and trend, a sparkline chart, total sales, and breakdown by top three regions Before 2008, a chart request like this would have meant a significant amount of code behind... numbers by product line (The cube actually has a hierarchy for Product Lines, but you get the idea.) 26 “Internet Gross Profit Margin” is a bit verbose, so let’s trim it a bit Right-click on one of the column headers, and then select Value Field Settings 27 For Custom Name, type Internet PM Note the other options available here for manipulating the display of the value field 28 Now we have Sales and Profit... a new project with a wizard or just an empty project Reports use data connections—either shared connections deployed to Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 401 CHAPTER 14 USER INTERFACES the server, or connections embedded in the report (The benefit of a shared connection is that it’s easy to modify it in either BIDS or SSMS—to point it at a different server, ... Reseller_Gross_Profit_Margin Note that BIDS has automatically inserted a SUM function on the field 34 In the text box properties, change the formatting for the profit margin text box to Percentage Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark 409 CHAPTER 14 USER INTERFACES 35 Click the Preview tab—you should see a report similar to Figure 14-53 Figure 14-53 The finished matrix with profit . =GETPIVOTDATA("[Measures].[Internet Sales Amount]",$A$3, "[Product].[Product Categories]", "[Product].[Product Categories].[Product].&[374]") This is the. a pivot chart is always bound to a pivot table. When we talk about ProClarity and SQL Server Reporting Services charts later in the chapter, we’ll look

Ngày đăng: 14/12/2013, 15:15

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan