Click Finish to exit the wizard

Một phần của tài liệu Pro SQL server 2012 BI solutions (Trang 441 - 456)

in this exercise, you created a basic cube. Next, we review the cube and make any required configurations.

We begin by processing the cube and examining its contents. Let’s delve into this topic now!

Processing the Cube

Like dimensions, you must build, deploy, and process a cube before it can be browsed. Also like dimensions, the act of building adds the XML code you have just created using the wizard to the master .asdatabase XML file.

Deploying uploads this master XML file to the SSAS server, and processing copies data from the fact tables in your data warehouse to the SSAS folders.

The easiest way to process your cube is to right-click the cube in Solution Explorer and select Process from the context menu. Once you do this, Visual Studio gives a warning indicating that the SSAS server is not synchronized with the changes to your project and offers to build and deploy it for you (Figure 11-9). If you want to process your data with the new cube, you have to click Yes to continue.

Note

■ Visual Studio may ask for the password again. if so, enter your password and click oK to continue.

Once the deployment is successful, Visual Studio presents the Process Cube dialog window, as shown in Figure 11-10. This dialog window is almost identical to the Process Dimension and Process Database dialog windows. Leaving the options as they are and clicking Run at the bottom of the dialog window starts the processing.

Figure 11-9. Visual Studio offers to build and deploy for you

Figure 11-10. The Process Cube window

Within a few seconds a second dialog window appears displaying processing messages (Figure 11-11).

The messages vary, because Visual Studio may not need to reprocess dimensions or measures that remain unchanged from previous processing.

Eventually the processing messages stop as processing completes. If there are errors, they require troubleshooting, but if all succeeds, you can then close the dialog windows.

Configuring Cubes

After the cube has been created, the cube needs to be configured and validated. Configuring a cube means modifying the cube to fit your needs, whereas validating a cube means verifying that the cube’s configuration is viable.

The cube designer has various tabs that enable you to configure your cube. We describe the tabs in Table 11-1.

Table 11-1. The Tabs of the Cube Designer

Name Description

Cube Structure Sets the properties for measures and measure groups

Dimension Usage Maps connections between each dimension and measure group Calculations Adds additional MDX calculations to your cube

KPIs Adds key performance indicator measures to your cube

Actions Adds additional actions such as drillthrough and hyperlinks

Partitions Divides measures and dimensions for fine-tuning aggregations to be stored on the hard drive

Aggregations Finds which aggregations should be stored on the hard drive Perspectives Defines SQL view–like structures for your cube

Translations Adds additional natural languages to the captions of your cube

Browser Browses the cube from the development environment

As you advance in your BI solution developing abilities, you will find that each of these tabs holds something of interest. The tabs we discuss in this chapter are Browser, Cube Structure, Dimension Usage, Calculations, and KPIs. These first five tabs will keep us plenty busy. We discuss the other five tabs in Chapter 12.

The Browser Tab

The Browser tab is used for validating your cube configurations. To get to the Browser tab, access the cube designer window and navigate to the last tab. Depending on your screen resolution, you may see only a few letters with an ellipsis (. . .) indicating that the rest of the title is hidden (Figure 11-12).

reFreShING the BrOWSer

To use the browser tab, the dimensions must have already been uploaded to your Analysis Server and the cube processed. it does not work if the XML files have been generated only in Visual Studio. After processing the cube, you need to manually reconnect to SSAS to see the latest version. Do so by clicking the Reconnect button on the browser’s toolbar to refresh the browser (circled in Figure 11-12). oddly, you do not use the Refresh button as you might expect! Throughout this chapter, we make several changes and reprocess the cube. This means you click the Reconnect button a number of times.

When the Browser tab is open, its treeview is visible on the left side of the screen. Measures and dimensions can be dragged from this treeview to the center for viewing. The interface is very similar to working with a pivot table in Excel, but most developers find it to be rather unintuitive.

Begin by selecting an item from the treeview. It is best to start with a measure, such as the Sales Quantity measure shown in Figure 11-12. Drag and drop the measure to the middle of the viewing pane where it says

“Drag levels or measures here to add to the query.” The query referred to here is the MDX query that will be invisibly written for you by Visual Studio.

Figure 11-12. The Browser tab

and drop something from one of the dimensions into the viewing pane as well. The trick is to drag and drop it just to the left of where the measures are being displayed. Figure 11-13 has this area circled.

Figure 11-13. Dragging and dropping to add items to the results

When you grab an attribute, such as the Title attribute, and drag it into this location, you are able to see the results of your query with the sales quantities broken into subtotals based upon the individual titles, as shown in Figure 11-14.

Keep in mind that these tools are not made for the end user. Instead, the end user will use something like an Excel spreadsheet or a Reporting Server report to view the data. This function is simply a convenience for the developer who has just finished creating a cube and wants to review and validate the cube’s design. Expect to configure, process, and browse the cube repeatedly as you go through the development cycle.

Before you complete your validations, you should view the cube using a common reporting application like Microsoft Excel. In SQL 2012, Microsoft has conveniently included a way to open an Excel spreadsheet from the cube’s Browser tab. The button is next to the language dropdown box and has the icon that is used for older versions of Excel. You can see it circled in Figure 11-14. Clicking this button launches Excel and presents you with a pivot table report, as shown in Figure 11-15. We discuss Excel pivot tables in Chapter 15, but for now let’s look at some of the other tabs in the cube designer.

Figure 11-15. An Excel pivot table generated with the cube Browser tab

Validate the Measures

When checking your work in the browser, we recommend starting with the measures. One reason for this is that attempting to use the dimensions in the browser without a measure may not give you any useful results.

Drag and drop a measure to the view pane. You will see the grand total for that measure. In Figure 11-16, you can see that we have dragged all of the measures into the viewing pane and now are seeing the grand total for each one.

With our first look, the values are readily apparent. For example, the Fact Sales count indicates that there are 21 rows in the Fact Sales table (Figure 11-16). The Sales Quantity measure indicates that the grand quantity of sales is 493. But, the Author Order measure is showing that there are 34 “somethings”—but this is nonsensical data.

As it turns out, Author Order indicates the order in which each author appears on a title’s cover—first, second, or third. Because the default behavior of a measure summarizes the values, the grand total of the sum of 1, 2, and 3 for all the rows in the Author Order is apparently 34. Now that we see this value, we know that the Author Order requires configuring before it is useful.

Similarly, the Fact Titles Authors Count indicates that there are 25 rows in the FactTitlesAuthors table. At first this may seem somewhat useless, but when combined with a specific title or a specific author, we can tell how many titles are associated with the authors using this measure. So, this measure also needs to be configured before it is useful.

Review the Dimensions

Next, let’s add some dimension values to get a clearer picture of our measures. Drag the title into the viewing pane. Figure 11-17 shows an example of the results.

Figure 11-16. Browsing the cube measures

From these results we can see that the “Computer Phobic . . . ” title has been sold one time with a total quantity of 20 units and that there are two authors associated with this title. So far so good, but why does the Author Order report a 3? Oh, that’s because it is adding the author order numbers of 1 and 2 and displaying their sum. We make a note of this and continue verifying other results.

Validating the Results

To further verify your results, you should run SQL statements on your data warehouse to validate the numbers a second time. Listing 11-1 shows some SQL code that will do that for you.

Listing 11-1. Validating the Development Report Use DWPubsSales

Go Select * From DimTitles

Where TitleName Like 'Computer Phobic %' -- Results in 14

Select TitleKey

,SalesQuantity = Sum(SalesQuantity) ,[SalesCount] = Count(*)

From FactSales Where TitleKey = '14' Group By TitleKey

-- Results in SalesQuantity = 20 and SalesCount = 1 *Good*

Select TitleKey

,[AuthorCount] = Count(*) From FactTitlesAuthors Where TitleKey = '14' Group By TitleKey

-- Results in AuthorCount = 2 *Good*

Tip

■ in the real world, the calculations involved in your cubes can be quite complex. You may have to ask for proofs from the data analysts or accounting team members. This is an important and time-consuming step in validating your cube, and you need to plan accordingly.

In our example, the results of the SQL code confirm the results we see in the Visual Studio cube browser.

We continue to examine and validate the dimensions and measures using the cube browser and SQL code until we have verified that all of the information is correct. Wherever we find a problem, we note it and change the configurations to resolve it.

The Cube Structure Tab

Modifying the properties of your measures is accomplished using the Cube Structure tab. Begin by highlighting a measure in the Measures pane, as shown in Figure 11-18. Access the Properties window by right-clicking the measure and choosing Properties from the context menu.

Table 11-2. Commonly Used Property Settings

Property Description

Aggregate Function Allows you to select how the measure will be aggregated Format String Allows you to indicate how the measure will be formatted

Name Allows you to specify the name of the measure

Visible Allows you decide whether most clients will be able to see the measure Figure 11-18. Accessing the properties of a measure

Common Measure Properties

Although a number of properties are available for each measure, you will use only a few of them on a regular basis.

Table 11-2 describes the commonly used property settings.

The first property in the Properties window is AggregateFunction. Here you can change the aggregation settings from the default to the other selections available in the dropdown box. Figure 11-19 shows the options with the dropdown box expanded.

Figure 11-19. Setting the AggregationFunction property

While Sum is the default and most commonly used option, other options are useful on occasion. Table 11-3 briefly describes what they do (Table 11-3).

Table 11-3. A Description of the AggregationFunction Settings Aggregation Function Description

Sum Adds values for all individual measure values into a total.

Count Provides a count of all individual measure values.

Min Returns the lowest value of all individual measure values.

Max Returns the highest value of all individual measure values.

DistinctCount Returns a count of all unique individual measure values.

None No aggregation is performed, and null is used for places where subtotals would normally display. (It is useful for items such as the Author Order in our example.) ByAccount Calculates the aggregation according to an assigned custom aggregation

function. (Used only for special account dimensions.)

AverageOfChildren Returns an average of values for all nonempty individual measure values.

FirstChild Returns the value of the first child member under a given parent. (For example, an inventory count measure on January 1 would be the first child under the parent January. So, you would see the inventory count for the first day of that January but not the total of all the other days.)

LastChild Returns the value of the last child member under a given parent.

FirstNonEmpty Retrieves the value of the first nonempty child member under a given parent. For example, if January 1 had no inventory values but January 2 did, you would see the value for the second day of January.

LastNonEmpty Retrieves the value of the last nonempty child member under a given parent.

The FormatString property uses the same style of format notation as Excel spreadsheets. In this property, you can specify how you want the data to display to the client. Most client software will respect this, but some may not. In those cases, the formatting will have to be reapplied at the report level. In Figure 11-20, we show the list of predefined options, but you can type in your own as well.

Type in a name to set the Name property. For our example, we choose to keep the names consistent with our other naming conventions by removing any spaces. We also change the name of the measure to better represent the data, such as changing Author Order to AuthorListingOrder (Figure 11-21).

Visibility is controlled by the Visible property setting. The default is set to True, but it can be changed to False if you prefer your clients to ignore it. This is a convenient feature if you believe that a specific measure may be confusing to some users yet you want to have it available for power users or for additional calculations that may be performed with MDX code. In our example, we might choose to hide both measures in the Fact Titles Authors measure group, because they are useful from the context of authors and titles dimension members but have no context in regard to dates or stores.

Note

■ Even when a measure is hidden, they are still accessible using MDX code. Some client applications do not check to see whether the visible setting is set to True; therefore, they still show up anyway.

Measure Group Properties

Measure groups are logical ways of grouping one or more measures. They make it easier for report users to find what they need. Measure groups are based on which fact table the data is coming from. By default each measure group will have the same name as the fact table. If you want to change this, you can do so by highlighting the measure group in the Measures pane and adjusting the property accordingly. For example, we have changed the measure names and the measure group names in Figure 11-22.

Figure 11-21. Setting the Name property

The Dimension Usage Tab

The Dimension Usage tab provides a grid layout that indicates how a dimension and measure group are associated with each other (Figure 11-23). The Cube Wizard is able to determine most associations, but you may still need to configure some of the associations by hand. At the very least, you will want to review this tab as part of your cube validation.

Figure 11-23. The Dimension Usage tab

Figure 11-22. Changing the names of the measure groups

In Figure 11-24, you can see the different relationship choices. Regular is the wizard default, and it is also the most common relationship type. In our example, this is not the correct choice, because the Order Numbers

The grid displays dimensions on the left side of the window and measure groups across the top. Each intersecting cell represents a relationship. Cells that are grayed out indicate that there is no relationship defined between that measure group and that particular dimension. In Figure 11-23, you can see that the DimStores dimension is related to the FactSales measure group based on the Store attribute. But it is not related to the other fact table, FactTitleAuthors. This is indicated by the cell beneath the FactTitleAuthors measure group and across from DimStores displaying as blank.

Configuring a Relationship

If you need to make an adjustment, click the cell you want to configure, and the ellipsis (. . .) button will appear.

When you click the ellipsis, a new dialog window appears displaying the logic that defines the relationship. As you can see in Figure 11-24, it consists of a dropdown box at the top of the window that allows you to select the relationship type you want to use.

Figure 11-24. The Define Relationship dialog window

Figure 11-25. Selecting a relationship type

Table 11-4. Relationship Types Relationship Type Description

No Relationship Defines a cell as not having any relationship.

Regular Defines a cell as having a regular relationship where there is a standard star or snowflake dimension associated with that measure group.

Fact Defines a cell as having a fact relationship where all the dimensional attributes are within the fact table.

Referenced Defines a cell as having a reference relationship where you reference a table through another table (for example, choosing to reference the publishers table through the titles table, skipping over titles completely).

Many-to-Many Defines a cell as having a many-to-many relationship where a bridge table is used to indirectly associate a dimension table with the central fact table. (In our example, this is how DimAuthors is constructed.)

Data Mining Defines a cell as having a data mining relationship. If you have created a data mining object with any project and allow it to create a data mining dimension for you, it can be associated in the cube by the setting.

Table 11-4 describes each relationship type.

The reference and data mining relationship types are less common than the others. We will see an example of how the more common ones are used in the following exercise.

Tip

■ occasionally the Dimension Usage tab, as well as some of the other tabs, may not refresh correctly.

Unfortunately, there is no refresh button on these tabs; therefore, the way to refresh them is to close the cube designer window and reopen it. You can reopen the cube designer window by right-clicking the cube in Solution Explorer and choosing View Designer from the context menu.

Một phần của tài liệu Pro SQL server 2012 BI solutions (Trang 441 - 456)

Tải bản đầy đủ (PDF)

(823 trang)