Say that you want to see sales units and sales returns but across the full product dimension breakouts and full time dimension breakouts for the United States geographic region only.. Th
Trang 1If you want much more drill-up and drill-down visibility into your data, you could build
up a much more complicated representation in the data browser Say that you want to see
sales units and sales returns but across the full product dimension breakouts and full time
dimension breakouts for the United States geographic region only You also want to see all
dimension levels, totals by levels, and grand totals by dimension You start the same way
as you did earlier and expand out the measures object until you see all the detail measures
in the Comp Sales cube If you still have the previous example in your data browser, you
can simply locate the Clear Results icon in the data browser tab and clear the data browser
pane Then you drag Sales Units to the center of the lower portion of the data browsing
pane (into the Drop Totals or Detail Fields Here section in the lower right) You do the
same for the Sales Returns measure Then you drag the geography dimension to the upper
section called Select Dimensions or just highlight Select Dimensions and choose the
geog-raphy dimension This is the dimension-level filtering capability within the data browser
You now just select (via the drop-downs of each section within a filter specification) the
level and type of filtering you want to do for the dimension you are working with You
can specify any number of filters within any number of dimensions To just filter on
coun-tries within the geography dimension, you select Councoun-tries within the hierarchies list of
the geography dimension, and the operator you want is Equal, and the filter expression is
the data value that you want to filter on (the United States country value, in this case)
These are all drop-down lists that you can easily select by either clicking the entry or
indi-cating which ones to use via a check box entry Figure 51.48 shows the fully specified Geo
Dimension filter specified
FIGURE 51.48 Complex data browsing with full dimensions and filtering in the SMSS data
browser
Trang 2The data values you now see are only those of the United States You now drag the
product dimension object to the Drop Column Fields Here section (just above where the
data measures were dropped) You immediately see the data measure values being broken
out by the entire product dimension (you expand the plus sign of the product hierarchy
all the way out to the SKU level) Then you drag the time dimension object to the Drop
Row Fields Here section (just to the left of where the data measures were dropped) You
can choose to view the data at any level within either the time or product hierarchies, and
you can filter on any other dimension values You can also just add a dimension or
dimension level to the filter portion within the data browser or just drag off dimensions,
measures, or filters from the data browser if you don’t want to use them anymore This is
very easy indeed The cube browser shows you what your cube has in it and also illustrates
the utility of a dimensional database Users can easily analyze data in meaningful ways
SSAS allows you to browse individual dimension member data You just right-click any
dimension in the left pane of SSMS (for example, the time dimension) and choose Browse
As you can see in Figure 51.49, the dimension browser opens with All as the top node in
the dimension You simply expand the levels to see the actual member values within this
cube dimension Expanding each level gets you to more detailed information as you move
down the dimension hierarchy
FIGURE 51.49 Browsing the Time dimension using SSMS
Trang 3Delivering Data to Users
SSAS provides a great deal of flexibility for building scalable OLAP solutions, but how do
you present the data to users? The client-side components deliver much of the
functional-ity of SSAS, using the same code base for the dimensional calculation engine, caching,
and query processing You can use the Pivot Table Service to manage client/server
connec-tions, and this is the layer for user interfaces to access SSAS cubes through the OLE DB for
OLAP interface ADO MD provides an application-level programming interface for
devel-opment of OLAP applications Third-party tools and future versions of Microsoft Excel
(like 2007 and 2010) and other Microsoft Office products will use the Pivot Table Service
to access cubes
The underlying Pivot Table Service shares metadata with SSAS, so a request for data on the
client causes data and metadata to be downloaded to the client The Pivot Table Service
determines whether requests need to be sent to the server or can be satisfied at the client
with downloaded data If a user requests sales information for the first quarter of 2008 and
then later decides to query that data for the first quarter of 2007 for comparison, only the
request for 2007 data has to go to the server to get more data The 2008 data is cached on
the client
Slices of data that are retrieved to the client computer can also be saved locally for analysis
when the client computer is disconnected from the network Users can download the data
in which they are interested and analyze it offline The Pivot Table Service can also create
simple OLAP databases by accessing OLE DB–compliant data sources
With the ADO MD interface, developers will be able to access and manipulate objects in
an SSAS database, enabling web-based OLAP application development
Many independent software vendors, such as Brio, Cognos, Business Objects, Micro
Strategies, and Hyperion, are working with Microsoft to leverage the rich features of these
OLAP services They offer robust user interfaces that can access SSAS’s cubes Versions of
Microsoft Office include the Pivot Table Service to enable built-in analysis in tools such as
Excel It is getting easier and easier to bring OLAP to the masses
Multidimensional Expressions
The OLE DB for OLAP specification contains MDX syntax that is used to build datasets
from cubes and is used to define cubes themselves Developers of OLE DB OLAP providers
can map MDX syntax to SQL statements or native query languages of other OLAP servers,
depending on the storage techniques
MDX statements build datasets by using information about cubes from which the data
will be read This includes the number of axes to include, the dimensions on each axis
and the level of nesting, the members or member tuples and sort order of each dimension,
and the dimension members used to filter, or slice, the data (Tuples are combinations of
dimensions such as time and product time that present multidimensional data in a
two-dimensional dataset.)
An MDX statement has four basic parts:
Member scope information, using the WITH MEMBERclause
Trang 4Dimension, measure, and axis information in the SELECTclause
The source cube in the FROMclause
Dimension slicing in the WHEREclause
Expressions in an MDX statement operate on numbers, strings, members, tuples, and sets
Numbers and strings mean the same thing here as they do in other programming contexts.
Members are the values in a dimension, and levels are groups of members Sets are
collec-tions of tuple elements to further combine facts If the dimension were time, a particular
year, quarter, or month would be a member, and month values would belong to the
month level You use the dimension browser in SSAS to view members of a dimension
The following example shows an MDX SQL expression:
WITH MEMBER [Measures].[Total Sales Units]
AS ‘Sum([Measures].[Sales Units])’
SELECT
{[Measures].[Total Sales Units]} ON COLUMNS,
{Topcount([Product_Dimension].[SKU].members,100,
[Measures].[Total Sales Units])}
ON ROWS
FROM [Comp Sales]
WHERE ([Time_Dimension].[All Time])
You can download this simple query against the Comp Sales cube from Sams Publishing at
www.samspublishing.com, and it is on the CD for this book as well This query returns the
sums of the sales units for products for all time periods Figure 51.50 shows the full
execu-tion of this query within a query window of SSMS Notice that the metadata for the cube
is also made available in the center pane of SSMS, along with an MDX Functions tab that
provides all the MDX functions that can be used This feature is very helpful for building
valid MDS queries within this environment Also notice that the result set display area is
very specialized in order to display multidimensional results
This simple MDX statement shows the basic parts of a working query In this case,
measures are displayed in columns, and the product dimension members make up the
axes of this multidimensional query and are displayed in rows The display of multiple
dimensions in rows like this is how the term tuple is used in the context of SSAS.
Much more could be said about MDX syntax, and a complete discussion of MDX could fill
its own chapter For more information, see the OLE DB for OLAP Programmers Reference,
which is available on the Microsoft website at http://msdn2.microsoft.com/en-us/library/
ms145506.aspx It contains detailed information about MDX expressions and grammar
ADO MD
ADO MD is an easy-to-use access method for dimensional data via an OLE DB for OLAP
provider You can use ADO MD in Visual Basic, Visual C++, and Visual J++ Like ADO,
ADO MD offers a rich application development environment that can be used for
multi-tier client/server and web application development
Trang 5FIGURE 51.50 Comp Sales MDX query execution in SSMS
You can retrieve information about a cube, or metadata, and execute MDX statements by
using ADO MD to create cellsets to return interesting data to a user ADO MD is another
subject too broad to cover in detail in this chapter Specifications for OLE DB for OLAP
and ADO MD are available on the Microsoft website at http://msdn2.microsoft.com/en-us/
library/ms126037.aspx
Calculated Members (Calculations)
Remember from the Comp Sales requirements that there was an additional user need to
see the difference between sales units and sales returns (sales units minus sales returns) to
yield net sales One approach is to use the SSAS calculated members (calculations)
capabil-ity This creates an expression against existing measures that will be treated the same as a
measure Basically, you need to complete the requirements for the Comp Sales cube by
adding a calculation measure to this cube for net sales units
To create a calculation, you go back to Visual Studio and the cube designer Then you click
the Calculations tab and create a new calculation measure called Sales Units NET with the
calculation expression of (Sales Units - Sales Returns), as shown in Figure 51.51 Many
functions are available for use that should meet your individual calculation needs
This calculation fulfills the data measure requirements of Comp Sales All that is left to do
is to process the cube so others can use it The following sample MDX query uses the
newly created calculation measure:
WITH MEMBER [Measures].[Total Sales Units NET]
AS ‘Sum([Measures].[Sales Units NET])’
Trang 6FIGURE 51.51 A new calculation measure of Sales Units NET in the Visual Studio cube
designer
Figure 51.52 shows this new calculation measure listed in the cube’s metadata pane You
can see how easy it is to use in the cube data browser You might want to check the math,
however, to make sure the calculation is correct
Query Analysis and Optimization
In SSAS, you can look at query utilization and performance in a cube You can look at
queries by user, frequency, and execution time to determine how to better optimize
aggre-gations If a slow-running query is used frequently by many users, or by the CEO, it might
be a good candidate for individual tuning A usage-based analysis capability can be used
to change aggregations based on actual live queries that the cube must service This
adjusts aggregations based on a query to reduce response time You start this wizard by
right-clicking the cube’s partition Figure 51.53 shows the Usage-Based Optimization
Wizard splash page
The Usage-Based Optimization Wizard allows you to filter queries by user, frequency of
execution, time frame, and execution time You see a record for each query you have run
since the date you began, the number of times it was executed, and the average execution
time, in seconds This is like a SQL trace analysis of your OLAP queries
SELECT
{[Measures].[Total Sales Units NET]} ON COLUMNS,
{Topcount([Product_Dimension].[SKU].members,100,
[Measures].[Total Sales Units NET])}
ON ROWS
FROM [Comp Sales]
WHERE ([Time_Dimension].[All Time])
Trang 7FIGURE 51.52 Data browsing using the Sales Units NET calculation in the Visual Studio cube
designer data browser
FIGURE 51.53 The Usage-Based Optimization Wizard
Trang 8Because aggregations already exist, the wizard asks whether you want to replace them or
add new ones If you replace the existing aggregations, the cube is reprocessed with this
particular query in mind
Generating a Relational Database
The examples you have worked with up to this point have been from a dimensional
data-base that uses a star or snowflake schema (theCompSalesdatabase) Very often, however,
you create cubes based on requirements only and do not have an existing data source (or
sources) to draw on at design time After you complete your cube design, you can choose
to generate a relational schema that can be used to retain (that is, stage) the cube’s source
data or that can be a data warehouse/data mart unto itself Figure 51.54 shows the start
of the Schema Generation Wizard for building a data warehouse/staging database from
the top down
FIGURE 51.54 Generating a relational schema from the cube and dimension definitions
Trang 9NOTE
Designing dimensional databases is an art form and requires not only sound
dimen-sional modeling knowledge, but also knowledge of the business processes with which
you are dealing Data warehousing has several design approaches Regardless of
which approach you take, having a good understanding of the approach’s design
tech-niques is critical to the success of a data warehouse project Although Microsoft
pro-vides a powerful set of tools to implement data marts, astute execution of design
methods is critical to getting the correct data—the truly business-significant business
data—to the end users
Limitations of a Relational Database
Even using a tool such as SSAS, you face limitations when dealing with a normalized
data-base Using a view can often solve (or mask) these issues In some cases, however, more
complicated facts and dimensions might require denormalized tables or a dimensional
database in the storage component of the data warehouse to bring information together
Data cleansing and transformation are also major considerations before you attempt to
present decision makers with data from OLTP systems
Cube Perspectives
A new feature in SSAS is cube perspectives This is essentially a way to create working
views of a complex cube that is focused on just what a particular user or group of users
need They don’t need all the dimensions, calculations, levels, and key performance
indi-cators (KPIs) that would otherwise be visible as part of a complex SSAS cube Therefore,
you need a method to tailor or limit a larger cube environment to be just what the users
need and nothing more—hence, the cube perspective Figure 51.55 shows the Perspectives
tab in the cube designer It allows you to easily customize a view (perspective), which is
what will be deployed or referenced to a target user group In this example, you are
creat-ing a new perspective called Comp Sales wo Sales Price, which excludes the extremely
sensitive Sales Price data measure from any user given access to this perspective
You can have any number of perspectives on a cube Figure 51.56 shows what a cube user
sees when trying to browse (or access) cube data via a perspective
Using perspectives is a great way to simplify the user’s life in an already-complicated
OLAP world
KPIs
Figure 51.57 shows another new capability in SSAS: creating embedded KPIs Just like
calculations, KPIs allow you to define thresholds, goals, status indications, and trend
expressions that become part of an OLAP cube Each can then be graphically displayed in
a variety of ways (for example, gauges, thermometers, traffic lights, trend indications such
as up arrows, smiling faces) This is perfect for an executive dashboard or portal
imple-mentation that has its basis in an SSAS cube You can easily access KPIs via the cube
Trang 10FIGURE 51.55 Creating cube perspectives within SSAS in the cube designer
FIGURE 51.56 Browsing cube data via a perspective in the cube designer
designer’s KPIs tab What are you waiting for? It is pretty easyto create powerful KPIs with
this simple yet rich interface
Data Mining
With SSAS, a much more robust selection of capabilities for data mining is available
Data mining is the process of understanding potentially undiscovered characteristics or
distributions of data Data mining can be extremely useful for OLAP database design in
that patterns or values might define different hierarchy levels or dimensions that were not