📚 Chapter 11 – Creating and Configuring SSAS Cubes
1️⃣ The Unified Dimensional Model (UDM)
In Microsoft SQL Server Analysis Services (SSAS), neither dimensions nor cubes interact directly with raw relational tables. Instead, both bind to an intermediate abstraction schema called the Data Source View (DSV) Microsoft refers to this combined dimensional and aggregation model as the Unified Dimensional Model (UDM).
2️⃣ Cube Wizard Architecture & Measures
Measure Group Identification
-
A Measure Group corresponds directly to a source fact table in the DSV.
-
In
PubsBICubes, two measure groups are created from the underlying warehouse:-
Fact Sales: Contains quantitative transaction metrics (Sales Quantity). -
Fact Titles Authors: Acts as the bridge table resolving the many-to-many relationship between titles and authors.
-
Automatic Row Count Measures
-
The Cube Wizard inspects fact table columns and automatically suggests row-count measures:
Fact Sales CountandFact Titles Authors Count. -
These provide pre-aggregated table row tallies (e.g., total transactions or total author-book associations) without executing table scan counts at runtime.
3️⃣ Configuring Measure Properties
Measures are configured on the Cube Structure tab:
| Property Name | Description & Functionality |
|---|---|
AggregateFunction |
Specifies the mathematical formula used to roll up atomic values (e.g., Sum, Count, Min, Max, DistinctCount, or None). |
FormatString |
Formats the numeric output for reporting tools using standard Excel formatting tokens (e.g., Standard, Currency, Percent). |
Name |
The user-facing label surfaced to client tools; best practice is to remove spaces and use camel/pascal casing (e.g., SalesQuantity, NumberOfSales). |
Visible |
When False, hides the measure from standard client field lists while keeping it available for background MDX expressions and calculations. |
4️⃣ Dimension Usage: Mapping Relationship Types
The Dimension Usage tab defines how each dimension joins to each individual measure group. The Cube Wizard detects direct relationships, but non-standard patterns must be configured manually:
| Relationship Type | Visual Symbol | Underlying Architecture & Use Case |
|---|---|---|
| Regular | Table $\rightarrow$ Fact | Standard direct join between a dimension table and the fact table (e.g., DimStores $\rightarrow$ FactSales). |
| Fact | Single entity | Used for degenerate/fact dimensions where dimensional attributes reside directly inside the fact table (e.g., DimOrders[OrderNumber] mapping to FactSales[OrderNumber]). |
| Many-to-Many | Dim $\rightarrow$ Bridge $\rightarrow$ Fact | Associates a dimension with a fact table through an intermediate bridge group (e.g., DimAuthors joining Sales through the intermediate group TitleAuthorInfo) Prevents metric double-counting. |
| Referenced | Dim $\rightarrow$ Dim $\rightarrow$ Fact | Snowflake reference where a dimension table joins the fact table indirectly through an intermediate dimension (e.g., Categories referencing Orders through Products). |
5️⃣ Calculations: Derived Measures vs. Calculated Measures
When creating custom metrics (such as TotalPrice = Price * Quantity), developers must choose between a Derived Measure (in the DSV via SQL) and a Calculated Measure (in SSAS via MDX)
| Metric Type | Definition Language | Evaluation Event | Storage & Performance Profile |
|---|---|---|---|
| Derived Measure | T-SQL | Evaluated at Processing Time. | Stored physically inside SSAS storage folders; maximizes query performance at runtime. |
| Calculated Measure | MDX | Evaluated at Query Time. | Computed on-the-fly dynamically; consumes no storage space, but requires CPU cycles on every client query. |
The Calculation Context Pitfall: Order of Operations
If a calculated measure is defined in MDX as:
[Measures].[CurrentStdPrice] * [Measures].[SalesQuantity]
-
The calculation multiplies the aggregated sum of prices by the aggregated sum of quantities, yielding mathematically incorrect totals when multiple rows are grouped (e.g., $43.80 \times 108 = 4730.40$ instead of the true total $$1,182.60$).
-
Solution: Use a Derived Measure inside a DSV Named Query (Price * SalesQuantity) so the multiplication occurs at the atomic row level before SSAS computes sums across dimensions.
6️⃣ Key Performance Indicators (KPIs)
-
A Key Performance Indicator (KPI) summarizes quantifiable metrics against a strategic goal, categorizing performance into a standard statistical scale from -1 to +1:
- -1 (Off Track / Red): Value falls significantly below acceptable thresholds.
- 0 (Warning / Yellow): Value meets minimum acceptable baseline.
- +1 (Target Exceeded / Green): Value exceeds target objective.
-
Core KPI Properties
- Value Expression: The MDX metric being measured (e.g., [Measures].[SalesQuantity]).
- Goal Expression: The target threshold description or numerical benchmark.
- Status Expression: An MDX CASE statement returning the discrete scale -1
CASE
WHEN [Measures].[SalesQuantity] < 25 OR ISEMPTY([Measures].[SalesQuantity]) THEN -1
WHEN [Measures].[SalesQuantity] >= 25 AND [Measures].[SalesQuantity] <= 50 THEN 0
WHEN [Measures].[SalesQuantity] > 50 THEN 1
END
- Status Indicator: Selects graphical glyphs (e.g., Road signs, Traffic lights, Gauge) rendered natively in Excel and reporting tools.
7️⃣ Walkthrough of Hands-On Exercises
Exercise 11-1: Creating the Base Cube (DWPubsSalesVer1)
- Open PubsBICubes in Visual Studio (Run as Administrator).
- Right-click Cubes > New Cube…
- Select Use existing tables and choose the DWPubsSalesTables DSV.
- Check both measure group tables: FactSales and FactTitlesAuthors.
- Select all default measures (Sales Quantity, Author Order, and both row counts).
- Include all 5 existing dimensions: DimAuthors, DimStores, DimDates, DimOrders, and DimTitles.
- Name the cube
DWPubsSalesVer1and click Finish.
Exercise 11-2: Configuring Structure & Dimension Usage
-
Cube Structure Tab:
- Rename Fact Sales measure group to Sales.
- Set Sales Quantity: Name = SalesQuantity, AggregateFunction = Sum, FormatString = Standard.
- Set Fact Sales Count: Name = NumberOfSales, AggregateFunction = Count, FormatString = Standard. Rename Fact Titles Authors measure group to TitleAuthorInfo.
- Set Author Order: Name = AuthorListingOrder, AggregateFunction = None, Visible = False.
- Set Fact Titles Authors Count: Name = NumberOfAuthors, AggregateFunction = Count, Visible = False.
-
Dimension Usage Tab:
- Locate DimOrders under the Sales measure group $\rightarrow$ click ellipsis (…) $\rightarrow$ change Relationship Type from Regular to Fact.
- Locate DimAuthors under the Sales measure group (currently blank) $\rightarrow$ click ellipsis (…) $\rightarrow$ select Many-to-Many and set Intermediate measure group to TitleAuthorInfo.
-
Deploy, Process, and Browse:
- Process the cube (Process Full), open the Browser tab, reconnect, and verify author-level sales quantities aggregate correctly.
Exercise 11-3: Resolving Row-Level Calculation Context
-
In the DWPubsSalesTables DSV, replace FactSales with a Named Query joining DimTitles on TitleKey to extract DimTitles.TitlePrice AS [CurrentStdPrice] and (DimTitles.TitlePrice * FactSales.SalesQuantity) AS [DerivedTotalPrice].
-
In DWPubsSalesVer1, add both new columns to the Sales measure group as measures.
-
Process the cube and browse against individual titles to verify that DerivedTotalPrice calculates correctly without the order-of-operation distortion seen in naive MDX multiplication.
Exercise 11-4: Adding the Sales Quantity KPI
-
Navigate to the KPIs tab $\rightarrow$ click New KPI.
- Configure settings:
- Name: SalesQty25To50KPI
- Associated measure group: Sales
- Value Expression: [Measures].[SalesQuantity]
- Goal Expression: “Total Sales of at least 25 to 50 units”
- Status indicator: Road signs
- Status expression: MDX CASE statement categorizing < 25 (-1), 25-50 (0), and > 50 (1).
- Reprocess the cube and verify in the KPI browser view.