Measures represent the quantitative data that users typically want to analyze in a data warehouse. They are numeric values that are aggregated, such as sales amounts, quantities, or counts. In SQL Server Analysis Services (SSAS) multidimensional models, measures are stored in measure groups, which are typically derived from tables in the data source view.

Understanding Measures

Measures are the core of your analytical insights. They answer questions like "What are the total sales?" or "How many units were sold?". Measures are derived from columns in your fact tables. Common examples include:

Types of Measures

Measures in SSAS can be categorized based on how they are defined and processed:

Creating Measures

Measures are typically created within a Cube designer in Visual Studio or SQL Server Management Studio. When you create a cube and select fact tables, Analysis Services often automatically suggests measures based on the numeric columns in those tables.

When defining a measure, you specify:

  1. Name: A descriptive name for the measure (e.g., "Total Sales Amount").
  2. Source: The underlying column in the fact table.
  3. Aggregation Function: The function to use for aggregation (e.g., Sum, Count, Average).
  4. Format: How the measure should be displayed (e.g., currency, percentage).
  5. Description: Optional details about the measure.
Best Practice: Always define a clear and consistent naming convention for your measures. This significantly improves usability for end-users.

Measure Groups

Measures are organized into measure groups. A measure group is a collection of related measures that are typically sourced from the same fact table. For example, a "Sales" measure group might contain measures like "Sales Amount", "Quantity Sold", and "Discount Amount", all derived from a sales fact table.

MDX for Calculated Measures

Calculated measures are defined using MDX. This allows for powerful on-the-fly calculations. Here's an example of an MDX expression for a calculated measure that computes profit margin:


<Measure Name="Profit Margin">
  // Calculate Profit Margin as (Sum of Sales - Sum of Cost) / Sum of Sales
  WITH MEMBER MEASURES.[Profit Margin] AS
    (Sum( Measures.[Sales Amount] ) - Sum( Measures.[Cost Amount] )) / Sum( Measures.[Sales Amount] )
  MEMBER_CAPTION = "Profit Margin"
  VISIBLE = 1
</Measure>
                

In this example:

Tip: Understanding MDX is crucial for creating complex analytical scenarios and custom calculations within your SSAS multidimensional models.

Measure Formatting

Proper formatting of measures is essential for clear presentation. SSAS allows you to define currency formats, number formats, and percentage formats. This ensures that measures are displayed consistently and are easy for users to interpret.

For example, a "Sales Amount" measure might be formatted as currency ($1,234.56), while a "Discount Percentage" might be formatted as a percentage (10.5%).

By effectively defining and organizing measures, you empower users to perform powerful data analysis and gain actionable insights from your multidimensional cubes.