Chapter 6. Creating Dimensions

This is possibly the most important chapter in the book. Although measures are what we're after, dimensions are the framework on which we'll build our cubes. Dimension names give us the nomenclature we'll use to break down our data, attributes will give us additional information about the members, and the members themselves provide the semantic points against which our measure data will be arrayed. Finally, well-designed dimension and attribute relationships will ensure the scalability of our cube solutions.

Dimensional Analysis

Before we can start designing dimensions, we have to figure out what dimensions we need. What problem are we trying to solve? In my opinion, this is a driving foundation of a successful business intelligence effort—identifying the problem domain.

Many BI initiatives start as "we need a data warehouse" without real direction. This is akin to someone standing in Madison, Wisconsin and declaring one day that she wants to visit every country. A wise traveler will then buy a bunch of maps, identify locations, and start working on solving the traveling salesman problem. It should soon become apparent that a huge amount of analysis is necessary—even more so if our traveler has never actually been on a train, airplane, or boat. In this research, the traveler will find that she needs a passport, luggage, and various supplies depending on the country she visits. She also needs visas. But wait. What visa she needs for a country depends on which border she's using to enter the country (and some borders can't be crossed!).

This is certainly a huge problem, and will take a very long time to plan out properly. However, all the time she spends planning is time she's not traveling. Meanwhile, she has bills to pay and a life to live, and because she hasn't actually gone anywhere, over time she'll just lose interest in the whole project.

Now what if, instead, our traveler decides that what she really wants to do is visit Europe, and specifically the Eiffel Tower? It's much easier to plan a short trip to Paris, find a cheap round-trip flight, book a hotel, figure out the visa situation, and so on. Soon she's on her way to Paris, enjoys her trip, and she's home again. Now she decides to visit Japan, and so does some more research—but this time the research doesn't take nearly as long, because she can build on what she learned on the last trip, and add in her personal experiences with what worked and what didn't.

My analogy is probably too thin, but hopefully will make the point. Don't try to sit down and design the be-all, end-all ultra data warehouse that will answer any question anyone could possibly ask. Instead, identify smaller business problems that can be solved with smaller cubes. Build a collection of cubes, and grow the solution iteratively. In this way, your users get value from what you've already built, and each project draws from the experience the team gained on the previous problem. With that in mind, let's look at some concepts behind dimensions that will serve our analysis, and then how we'll build them in Analysis Services.

Review of the Dimension Concept

Let's look at our notional "cube" again, represented by spreadsheets. In Figure 6-1, Order Date, Country, and Product are each dimensions. Alice Mutton, Aniseed Syrup, Boston Crab Meat, and so on are members of the Product dimension. We use dimensions to organize collections of attributes into logical groupings (just as we have products, country, and time). You can see that the collection of dimensions effectively defines the collection of measures that make up our cube. In SSAS, the concept of a dimension actually exists independent of a cube. Dimensions can be the result of a single cube design, but they can also be in a database solution with no cubes. A single dimension can be used in multiple cubes, or even linked between multiple databases.

Notional cube structure

Figure 6.1. Notional cube structure

In our dimensional analysis, after identifying a problem domain, we'll have to figure out what types of questions users are likely to ask and how they will seek answers. I won't go into requirements analysis here. If you're interested in methods for gathering requirements in the data warehouse world, I recommend The Data Warehouse Lifecycle Toolkit, by Ralph Kimball, Margy Ross, Warren Thornthwaite, Joy Mundy, and Bob Becker (Wiley, 2008) or The Microsoft Data Warehouse Toolkit: With SQL Server 2005 and the Microsoft Business Intelligence Toolset by Joy Mundy and Warren Thornthwaite (Wiley, 2006). There is one big technical decision we need to make, however: do we want a star schema or a snowflake?

Star or Snowflake?

We generally have two options when creating a cube: a star or a snowflake schema. To review, a star schema has a single fact table with every dimension table linked directly to it (Figure 6-2).

A star schema

Figure 6.2. A star schema

Compare this to a snowflake schema, which keeps the tables more normalized, similar to Figure 6-3.

A snowflake schema

Figure 6.3. A snowflake schema

A snowflake schema will likely give way to what is often termed a multisnowflake schema, which has multiple fact tables. From here we can see a creeping problem that adds fact tables, dimension tables, supporting tables, and so on. You can see a similar result in the AdventureWorks schema in Figure 6-4, which I've annotated with arrows pointing to each fact table.

The AdventureWorks schema

Figure 6.4. The AdventureWorks schema

The primary advantage of a star schema is that it keeps development focused on a simple approach—one fact table, and every dimension linked to the fact table. It's important when creating a cube to keep focused on end-user usability, especially because ease of use for our analyst end user is a major reason we're building these cubes in the first place.

The Advantage of Simplicity

As an example of how a complex schema can defeat end-user usability, consider the pick list for measures and dimensions we see if we open the AdventureWorks cube in Excel (Figure 6-5).

Measures and dimensions from the AdventureWorks cube in Excel

Figure 6.5. Measures and dimensions from the AdventureWorks cube in Excel

Perhaps our analyst wants to examine the effectiveness of an ad campaign on in-store buyers based on their geographic region. So it seems logical to examine reseller sales by customer location, right? Let's continue down that path. My argument will be easier to follow if you build the report yourself. So let's build a quick Excel report in Exercise 6-1.

Note

You'll need the AdventureWorks 2008 demo cube installed and processed for this exercise. See Appendix A.

Well, it's a safe bet that those six countries didn't sell exactly the same amount of product (down to the penny), so it looks like our Customer Geography dimension isn't splitting the measure data. Why is this? A little examination of the cube structure will show us why. First we note from the pivot table picker in Excel (Figure 6-10 in the exercise) that we used the Customer Geography hierarchy from the Customer dimension.

If we open up the AdventureWorks project in BIDS, we want to look at the AdventureWorks cube. Once in the cube, we're interested in the Dimension Usage tab (Figure 6-12). Note that we have measure groups across the top, and dimensions down the left side. If we track Reseller Sales and look where it intersects the Customer dimension, we see something interesting.

Relationship between the Reseller Sales measure group and the Customer dimension

Figure 6.12. Relationship between the Reseller Sales measure group and the Customer dimension

They—the sales and customer dimensions—have no relationship defined. So any use of the Customer dimension against the Reseller Sales measure group won't slice the underlying data, which is the behavior that we saw in Exercise 6-1. At this stage, there most likely doesn't exist any way to identify customers from the reseller data we have. If that turns out to be a critical business need, an analyst will have to go back to the data warehouse group and have that data added to the cubes, if it even exists (the resellers may not report customer data back through the supply chain).

So we see that a complex cube structure can lead to confused and frustrated end users. That is one of the key reasons for preferring a star schema—to easily ensure that every dimension does in fact link to the fact table.

Note

The Enterprise Edition of Analysis Services offers a powerful feature called Perspectives that allows us to address this potential complexity without creating numerous additional cubes. You'll look at this feature in Chapter 7.

Now that you have a basic understanding of where dimensions fit in the grand scheme of things, let's dive down and start looking at working with dimensions in Analysis Services, specifically focusing on building dimensions in BIDS.

Dimensions in SSAS

You can create a dimension at any time in BIDS just by right-clicking the Dimensions folder and selecting New Dimension, which will open the Dimension Wizard. Alternatively, you can link a dimension, which enables you to create a pointer to a dimension defined in another database. By using linked dimensions, you can maintain "standard" dimension definitions in a database, and then link to them from other cubes as necessary. Finally, dimensions can be implicitly created when you run the cube wizard (you'll look at this in Chapter 7).

Creating a Dimension

Dimensions can either be defined from the data in a data warehouse, or they can be designed in the Analysis Services database solution. In the latter case, the dimension and its attributes are laid out in BIDS, and then the schema generation wizard will create the underlying data tables to support the dimension. (The next step will be to design the ETL to move data from the data sources into the designed schema.) Follow along in Exercise 6-2 and create a dimension that you'll use later in this chapter.

In this exercise, we talked a lot about attributes and hierarchies. Let's take a deeper look at what they are and how they factor into cube design.

Analysis Management Objects (AMO) Warnings

In Exercise 6-2, we see a little blue squiggle in a hierarchy. When we mouse over it, we see a warning (Figure 6-21). This is an Analysis Management Objects (AMO) warning, a new feature in BIDS 2008. AMO warnings are best-practice recommendations to aid in design of Analysis Services cubes. In this case, the warning is pointing out that there is no relationship defined between the Type and Promotion attributes (more on this in the "Attributes" section later in this chapter).

An AMO warning in BIDS

Figure 6.21. An AMO warning in BIDS

BIDS has dozens of design warning rules that it runs against OLAP designs as you work. The warnings will show up as you work. AMO warnings won't keep you from saving or processing cubes or dimensions. You can choose to ignore warnings, either on a case-by-case basis, or you can dismiss a warning globally.

To dismiss a warning, open the Error List pane (View menu

An AMO warning in BIDS
Dismissing an AMO warning

Figure 6.22. Dismissing an AMO warning

To view the status of warnings in a database, right-click the database name (the project in the Solution Explorer) and select Edit Database. In the designer that opens, click the Warnings tab (Figure 6-23).

Reviewing AMO warnings

Figure 6.23. Reviewing AMO warnings

The top section lists the design warning rules available. They're grouped by type of object (Cube, Data Source, and so on), and ranked by importance. You can come in and deselect rules that you don't want enforced. In the lower window are the warnings you've dismissed for the current database (including comments you made when you dismissed them). You can highlight a dismissed warning and click the Re-enable button to put the warning back in place.

Dimension Properties

Now that you've built a dimension, let's dig into the features and properties. These are accessible by right-clicking on the dimension name in the attributes pane on the left, in Visual Studio, and selecting Properties. The following subsections describe each of the properties that you see.

Dimension Type

You can flag a dimension with a type—the default is Regular. For the most part, the dimension type is an indicator for client applications on how to treat a dimension. For example, if a dimension is the Customer type, a client application may provide a way to map the dimension to contact cards or a personnel selector-type control. Note that Account, Currency, and Time dimension types do have special handling built into SSAS—we'll look at them separately.

The dimension types are as follows:

Account:

This dimension represents a chart of accounts (revenues, losses, profits, expenses, and so forth). An Account dimension type can be managed such that specific account types are positive or negative solely based on the account definition.

Bill of Materials:

A Bill of Materials type will contain manufacturing or inventory information (unit of measure, cost, packaging).

Channel:

Used in retail sales, a Channel dimension will indicate the sales channel used (wholesale, retail, partners).

Currency:

The Currency dimension is designed to reflect the financial requirements of dealing with international transactions. SSAS has a currency-conversion feature to manage these transactions.

Customer:

A Customer dimension will have standard attributes for customers and contact information.

Geography:

If you want to designate attributes as addresses, cities, and zip codes, then set the dimension type as Geography. You can also have spatial data types in a Geography dimension type.

Organization:

Employee names, positions, offices, and branches can all be defined in an Organization dimension.

Product:

A Product dimension will have attribute types for brands, SKUs, and product categories. You can also add attributes for product start and end dates.

Promotion:

If you need to group facts by the type of deal the buyer got, you can use a Promotion dimension type, including minimum and maximum quantities, start and end dates, percentage discounts, and so on.

Quantitative:

Quantitative is more a general description than an actual dimension type, and more of a collection of measurement-oriented attributes (volume, weight, color, maximum, minimum, and so forth) than anything else.

Rates:

Generally a dimension for measuring exchange rates.

Scenario:

Scenarios are a fascinating capability of an OLAP solution. Because any dimension can "slice" the fact data into exclusive collections (sales in Europe, North America, or Asia), we can create a dimension solely for creating scenarios. For example, a scenario may have members for "5 percent growth," "No growth," and "5 percent decline." Selecting each member then groups the data for that scenario. You'll revisit the concept of scenarios when you look at writeback in Chapter 7.

Time:

A Time dimension represents a calendar—days, weeks, months, quarters, years. The Time dimension is very special, as we've seen previously, and we'll cover time dimension types specifically later in the chapter.

Utility:

A Utility dimension is basically a catchall for some aspect of the data that may not be reflected in the business rules.

Each of these dimension types has a host of matching attribute types (Figure 6-24). In general, you can "mix and match" attribute types with dimension types, though some of the special types can be used only in their matching dimension type. If you mismatch types, you'll get an AMO warning on the dimension.

Selecting attribute types

Figure 6.24. Selecting attribute types

After you've set a dimension type and assigned attribute types, OLAP client applications can leverage known dimension types in business logic. For example, a sales and marketing analysis tool could pull promotion and channel dimensions from your cubes and align them with the analysis system.

I mentioned that Account, Currency, and Time dimension types are special. In addition to being able to be leveraged by client applications, each of these dimensions can be specified within SSAS to work in special ways. Let's open AdventureWorks and look at the Account dimension (Figure 6-25). Note that the table in the data source view is self-referential. It has a field that is a foreign key for the table's primary key, to indicate the parent account. This creates the recursive hierarchy of accounts in the dimension.

The Account dimension in AdventureWorks

Figure 6.25. The Account dimension in AdventureWorks

Now let's look at the dimension browser (Figure 6-26). You might not notice at first, but various accounts have plus or minus signs on their icons in the browser. That's because the DBA set up account business intelligence on the dimension. When you run the Add Business Intelligence Wizard (Dimension menu), it walks you through mapping an accounts table to built-in logic for standard accounts. In addition, the UnaryOperatorColumn was set to the Operator column of the Account table. In a parent-child hierarchy dimension, setting the Unary Operator on the parent attribute indicates to Analysis Services to use that column to determine how to aggregate that member.

Browsing the Account dimension

Figure 6.26. Browsing the Account dimension

Currency dimensions have similar logic that can be added via the business intelligence wizard. The wizard is pretty straightforward. You will want a table of exchange rates by time period to handle the automatic currency conversion. One aspect you will have to know is your preferred method of handling local currencies. SSAS will want one of the following three scenarios:

Many-to-many:

All transactions are recorded in the local currency. Currency conversion is applied at the cube level and can target many currencies.

Many-to-one:

All transactions are recorded in the local currency. Conversions are applied at the cube level to the corporate standard currency.

One-to-many:

All transactions are recorded in a single currency. The conversion is applied at the cube level with multiple target currencies.

So if all your sales are reported in the local currency, you can set up a currency dimension and conversion rate table, apply the business intelligence wizard, and you can roll up aggregated sales figures with conversions automatically applied.

ErrorConfiguration

This section of properties refers to how Analysis Services should handle errors that crop up while processing the dimension. Think of a dimension as a lookup table—one thing that's necessary is a primary key value to link the dimension and subordinate attributes to records in the cube. So when processing the dimension (reading in the data, parsing it for attributes and relationships, and then caching the dimension data), if multiple records have the same key value, SSAS will throw an error.

You can indicate how to handle the error here. The default action is to ignore the error and continue processing. You can see how this may cause problems, so you might want to change this to either ReportAndContinue or ReportAndStop if you have a data source where you expect you may get duplicates. Both IgnoreError and ReportAndContinue will leverage the KeyErrorAction setting—either converting the key to an Unknown catchall value or discarding the record.

MdxMissingMemberMode

This setting indicates how Analysis Services should handle queries or calculations that reference a member that doesn't exist in the dimension. The default setting is Default, which means the error will be handled in accordance with the settings in Analysis Services and the cube. You can also specifically set this to error out or ignore the error.

Processing

These options govern how the dimension is processed. You should generally leave the setting for ProcessingGroup at the default value of ByAttribute. ByTable is used for a small subset of cases generally involving very large dimensions (millions of rows). Setting ProcessingMode to LazyAggregations will make the dimension available for use while it's still being processed, but as a result, processing will take longer.

ProcessingPriority allows you to prioritize the order in which dimensions are processed. You might want certain dimensions (such as Time) available sooner, for example, while other less-used dimensions are processed afterward.

Storage

There are two major sections here: StorageMode and ProactiveCaching. Recall the discussion about MOLAP and ROLAP; in Analysis Services you can specify the storage setting for each dimension and measure partition. The two settings here are MOLAP and ROLAP, reflecting the two major options for where dimensions are stored—either in the multidimensional repository or in the relational database.

Where is HOLAP? Well the "hybrid" part of the equation is where the proactive caching comes in. Remember that MOLAP stores the dimension data in the Analysis Services cube, while ROLAP stores the data in the relational store. However, with MOLAP we can also specify proactive caching. With proactive caching, SSAS rebuilds the dimension either when the source data changes, when signaled by a client application, or on scheduled intervals.

If you click the builder button [...] next to the ProactiveCaching setting, you'll open the Dimension Storage Settings dialog box (Figure 6-27). Here you can choose either one of the standard settings or a custom setting. The custom options give you some granular control over the cache, and then allow you to control how SSAS should be notified of changes in the underlying data.

Setting dimension storage settings

Figure 6.27. Setting dimension storage settings

The options for notification are as follows:

SQL Server:

SSAS simply sets a trace on the necessary tables in SQL Server and tracks for data changes. You can select the Specify Tracking Tables check box and explicitly list the tables SSAS should track for changes (remember, all that will happen is that SSAS will rebuild the dimension if any changes to the data in the indicated tables are detected). If you don't specify the tables, Analysis Services will try to determine from the dimension structure which tables to track.

Note

If you select the SQL Server option, the account that connects to the data sources tables must have ALTER TRACE permissions on the database.

Client Initiated:

This is pretty close to regular MOLAP—a client calls for the processing to occur.

Scheduled Polling:

Specify a polling interval, and SSAS will query the data source for changes; if the data has changed, SSAS will rebuild the dimension. You can also specify incremental updates if you need to process only part of a dimension based on data changes.

Let's take a look at how dimension storage works in Exercise 6-3.

UnknownMember

The UnknownMember is effectively a catchall where any measures that don't match members in this dimension will be assigned. You have the option as to whether to have an unknown member and whether it's visible. You can also give the member a specific name (for example, Unassigned Sales or Respondents Didn't Answer).

WriteEnabled

While most of the time OLAP cubes are used for read-only analysis, Analysis Services does have the ability to edit cubes and dimensions directly. However, only parent-child dimensions can be write-enabled.

We talked a lot about attributes earlier. Let's take a closer look at them.

Attributes

If dimension members are nouns, attributes are adjectives. Let's look back at our Promotion dimension (Figure 6-34). The dimension has attributes for the percentage discount, start and end date, maximum and minimum quantities, promotion category, type, and name. Each of these is amplifying information for each promotion in the dimension.

Attributes on the Promotion dimension

Figure 6.34. Attributes on the Promotion dimension

Attributes are often called containers for dimension members. I find the adjective concept easier to grasp. However, you can see how that approach works—take all the Promotion categories, and each one is something of a "bucket" for the promotions that have that category. However, not every attribute is really a "container"—for example, a Product dimension might have a Price attribute, but grouping by price ($12.95, $13.15, $14.75) wouldn't be that productive.

In addition to enabling drill-down or reporting, attributes are also useful for querying. For example, you can select for all blue bicycles, or use an MDX query like the following, to show sales by product for all products with a list price over $1,000.00. We'll dive into MDX in Chapter 9.

WITH
MEMBER Measures.[List Price] AS [Product].[List Price].CurrentMember.MemberValue

SELECT
{[Date].[Fiscal].[Fiscal Quarter].Members}
ON COLUMNS,

Filter([Product].[Product].Members, (Measures.[List Price]>1000))
ON ROWS

FROM [Adventure Works]
WHERE ([Measures].[Internet Sales Amount])

In the dimension structure, attributes are generally defined by dragging a field from the data source view over to the dimension (Figure 6-35).

Creating an attribute from the dimension data source view

Figure 6.35. Creating an attribute from the dimension data source view

For the most part, a dimension consisting of members and attributes is similar to a database table with rows and columns. In fact, you can view the dimension with its attributes as a table: in the browser, selecting Member Properties from the Dimension menu will show all the attributes for the dimension in a table (Figure 6-36).

Showing all attribute values for a dimension

Figure 6.36. Showing all attribute values for a dimension

To really get value out of the collection of attributes in a dimension, we want to build hierarchies and set attribute relationships. Because our users will generally use various attributes in different ways, defining attribute relationships aids the user in seeing relationships in the dimension structure, as well as optimizing performance by defining how attributes are related within the data and by business rule. Let's dig into attribute relationships.

Attribute Relationships

Every attribute in a dimension is related to the key attribute of the dimension, either directly or indirectly (via a relationship with another attribute). By default, when you create a dimension in BIDS, each attribute in the table with the key attribute (in a star schema this would be the only table in the dimension; in a snowflake schema it's the main dimension table) is directly related to the key attribute. The attribute in foreign-key tables bound to the foreign key is also directly related to the key attribute. Finally, attributes based on fields in the foreign-key tables are directly related to the foreign-key attribute (Figure 6-37).

Attribute relationships on a snowflake schema

Figure 6.37. Attribute relationships on a snowflake schema

In Figure 6-37, we're looking at the default attribute relationships for a dimension built from the Product, Subcategory, and Category tables. Note that the English Product Subcategory Name and English Product Category Name are each related to the attributes bound to the foreign key in their table, which are related to the Product Key—the key attribute for the dimension.

Attribute relationships should always be built to represent natural hierarchies. A natural hierarchy is simply a one-to-many relationship. Be wary of creating "unnatural hierarchies" with attribute relationships, because these will significantly affect query performance and can even result in inaccurate results.

Note

Also be sure to validate your data; even though a business rule may indicate that data is one-to-many, the actual data may violate the restriction. This is a potential problem with star schemas; with snowflakes, one-to-many relationships can be enforced with database constraints. If you have a star schema and all the attributes for a hierarchy are fields in a table, you could easily end up with many-to-many relationships in the data. So be sure to review your entire BI infrastructure and ensure that checks are in place to validate that the data will do what you think it does.

Building an attribute relationship in the dimension prompts Analysis Services to structure indexes to reflect that relationship. Another thing attribute relationships do is help SSAS understand which indexes not to build. For example, looking back at Figure 6-37, any relationship between category and product can be inferred from the relationships between product and subcategory, then subcategory and category. No explicit relationship needs to be built between product and category.

Attribute relationships can be rigid or flexible. A flexible relationship indicates that the attribute relationship can change over time. When an attribute relationship is flexible, aggregations under that relationship are dropped and recomputed during incremental updates. If the relationship is rigid, the relationships won't be recomputed. Exercise 6-4 presents an example of creating a dimension with attribute relationships.

Warning

If the relationship between attributes with a rigid relationship actually changes, Analysis Services will throw an error during incremental processing.

Attribute Properties

Let's take a look at the properties for an attribute. Select an attribute and then view the Properties pane (right-click and then select Properties). Let's work down the Properties pane and look at some of the more significant properties. Here's the list:

AttributeHierarchyDisplayFolder:

This is a free-text value. Any value you type in here will create a folder in the list of attribute hierarchies available (see Figure 6-42).

Creating display folders for grouping attributes

Figure 6.42. Creating display folders for grouping attributes

AttributeHierarchyEnabled, AttributeHierarchyVisible:

The Enabled property indicates whether the attribute can be used at all for grouping measures. If an attribute is not visible but is enabled, it won't show up in client applications but can be used in MDX expressions.

DefaultMember:

Indicates which member is selected when the dimension is selected.

OrderBy, OrderByAttribute:

OrderBy indicates what to use to sort the attribute values (the attribute's key, name, or the key or name of another attribute). If you select AttributeKey or AttributeName, you will also have to enter the name of another attribute to use for sorting.

We'll cover the properties in the "Parent-Child Dimensions" section that follows.

Parent-Child Dimensions

If you have to deal with employees in a company, or records in a file system, you're probably familiar with the concept of recursive data structures. Basically, in these structures, one of the fields annotates parent or owner, and the structure links to itself. Traversing a structure like this gives you a traditional tree or organizational chart type arrangement (see Figure 6-43).

A parent-child structure

Figure 6.43. A parent-child structure

As you can tell, this kind of structure invites interesting challenges. However, Analysis Services handles it very easily. When you create a dimension that has a self-referring relationship, Analysis Services automatically creates a parent-child hierarchy in the dimension. That attribute is marked as a parent attribute type, and has an icon as seen in Figure 6-44.

A parent-child attribute in a dimension

Figure 6.44. A parent-child attribute in a dimension

There are five specific properties relating to parent-child dimensions:

MembersWithData:

Here you can select whether nonleaf data will be hidden or visible. The leaf members are the members that have no children (at the "bottom" of the hierarchy). Generally in an OLAP measure, all the values are at the leaf level; nonleaf members have values that are the result of aggregating the leaf values. For example, subcategory sales are the result of adding together the sales of all the products in the subcategory; nobody actually sells a subcategory. However, in parent-child dimensions, often nonleaf members will have values of their own. In a sales organization hierarchy, sales managers may also make sales. So how do you show both the rollup of the manager's subordinates and the manager's sales? If you indicate NonLeafDataVisible, SSAS deals with this by creating a "data member" that is a leaf member directly under the manager, containing the data for the manager.

MembersWithDataCaption:

Here you can give a template for the data member used when you indicate that nonleaf data is visible in a hierarchy. You can type any string—an asterisk will be replaced with the name of the member above. See Figure 6-45.

Data members for nonleaf members in a parent-child hierarchy

Figure 6.45. Data members for nonleaf members in a parent-child hierarchy

NamingTemplate:

If you look back to Figure 6-43, note that there are four levels in the hierarchy. In a normal SSAS hierarchy, you would annotate each level by the attribute name (Categories, Subcategories, Products). However, in a parent-child hierarchy, there are no natural names—every level is Employees. So Analysis Services creates a dynamic name based on this template. You can enter multiple terms separated by semicolons. When you process the dimension, Analysis Services will assign the terms starting at the first level. When SSAS runs out of terms, it will keep using the last term but appending index numbers: 1, 2, 3, and so on.

RootMemberIf:

If you think about the way this hierarchy is built, one thing to wonder is how to find where it starts. That's what this setting is about. You can establish the root member by setting its parent ID to itself, leaving the value blank, or leaving it undefined. With this setting, you can choose which method to use, or if all three are acceptable.

UnaryOperatorColumn:

Remember our Account dimension? Each level had an indicator as to whether it should be added or subtracted to the aggregation. This property is where you indicate which column to use that holds those operators (see Figure 6-46).

Native account table data showing the Operator column at far right

Figure 6.46. Native account table data showing the Operator column at far right

If you choose to use parent-child dimensions, be sure that your intended client applications handle them gracefully. You definitely want to keep them in the first round of requirements and test to verify that everything works as you expect. Now let's move on to our final special case for dimensions, and perhaps the most important—the Time dimension.

The Time Dimension

The Time dimension is a special case in OLAP technology. If you think about a calendar as a dimension, there are several facts about it that differentiate it from other dimensions:

  • There are specific directions for forward (newer) and back (older).

  • The members create a continuous range (1–31 January, 1–28 February, and so forth).

  • When semiadditive measures calculate different dimensions in different ways, the Time dimension is usually the one dimension that is different from the others (inventory levels are added in other dimensions, and averaged in the Time dimension).

  • Rolling averages over time have meaning (rolling averages by product do not).

  • The concept of to date exists, which allows analysis of time periods not yet ended (year to date, quarter to date).

As a result, OLAP engines are designed to recognize Time dimensions and work with them. And SQL Server Analysis Services is no different. A basic Time dimension will be based on a table with date data—a date field, which will be a normal DateTime value, then a number of additional fields to enable Analysis Services to create hierarchies as well as perform various kinds of date math. The data source view table will then contain additional calculated fields to build out the full definition of a date model (see Figure 6-47).

A date table in the data source view

Figure 6.47. A date table in the data source view

Date dimensions can have multiple calendars. In addition to the standard calendar, you can also have the following:

Fiscal calendar:

Many companies have financial reporting years that end on dates other than January 1. The fiscal calendar reflects the position in the fiscal year. For example, the US federal government has a fiscal year that starts on October 1. So October/November/December of 2008 is the first fiscal quarter of fiscal year 2009 (Q1FY09).

Reporting calendar:

A reporting calendar follows a standard quarterly structure in which two months in the quarter have four weeks, and the other month has five. You can indicate which month has five weeks by selecting the month pattern (445, 454, or 544).

Manufacturing calendar:

This calendar has thirteen "months" of four weeks each, divided into four quarters (three quarters with three months, one with four). You can set when the calendar starts as well as which quarter has the extra "month."

ISO 8601 calendar:

This calendar follows the ISO standard calendar, which establishes a fixed number of seven-day weeks within a year, and establishes the start date of the year, based on the Gregorian calendar.

Being able to use and combine these calendars can provide a powerful new analytic capability to the end users, who may need to relate financial data to manufacturing data, or calendar data to reporting data.

You have several methods of creating time tables in BIDS:

Generate a time table in the data source:

Using the new Dimension Wizard, this will create a Time dimension mapped to a data source view. If you generate the schema, it will also generate the table in the data source, optionally fill it with date data, and map it in the data source view.

Generate a time table on the server:

This will generate the time table on the SSAS server, in the event you don't have permissions to create a table on the data source server.

Roll your own:

Perhaps you already have a table populated with every date, or need to build your own for some other reason. It's possible, but painful.

Note

There is no limit on the number of Time dimensions you can have in a cube.

The resulting structure of a Date dimension is shown in Figure 6-48.

A Date dimension in the designer

Figure 6.48. A Date dimension in the designer

The easiest way to understand dimensions is to create one, so let's embark on our last exercise. Exercise 6-5 shows how to create Date dimensions for use in analyzing time-based data.

Summary

So that's our tour of dimensions in SQL Server 2008 Analysis Services. Remember that defining your dimensional space is the key to developing a solid OLAP solution. Dimensions are like the tent poles, and in Chapter 7, we'll look at the fabric of the tent—that is to say, measures.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.166.149