SQL Server Analysis Services

Multidimensional Modeling Documentation

Defining Measures in Multidimensional Modeling

Measures are the numerical data points that users query in a cube. They represent the business metrics you want to analyze, such as sales amount, quantity sold, or profit. In SQL Server Analysis Services (SSAS), measures are typically derived from columns in your data source that contain numeric values. This document outlines the process of defining and configuring measures within your multidimensional model.

Understanding Measure Types

SSAS supports various measure types, each serving a specific purpose:

Steps to Define a Measure

  1. Locate the Fact Table: In Visual Studio's SSAS project, navigate to the "Data Source View" and identify the fact table that contains the numerical data you wish to expose as a measure.
  2. Create the Measure: Right-click on the desired numeric column within the fact table in the Data Source View and select "New Measure". Alternatively, you can navigate to the Cube Designer, select the "Measures" pane, and click "New Measure".
  3. Configure Measure Properties: A dialog box will appear allowing you to configure the measure's properties.
    • Name: Provide a user-friendly and descriptive name for the measure (e.g., "Total Sales Amount").
    • Source Column: If creating a standard measure, this will be pre-selected to the column you right-clicked.
    • Aggregation Function: Choose the appropriate aggregation function (e.g., SUM, COUNT, AVERAGE). For standard measures, this is crucial.
    • Format String: Define how the measure's value will be displayed (e.g., currency, percentage).
    • Description: Add a brief explanation of what the measure represents.
  4. Deployment: After defining your measures, deploy your SSAS project to make the cube and its measures available for querying.

Working with Aggregation Functions

The choice of aggregation function significantly impacts how your measure behaves. Common functions include:

Note: For measures derived from dimension tables (e.g., counting distinct products), you might need to use actions or MDX expressions in conjunction with dimension attributes to achieve accurate results.

Example: Defining "Total Sales" Measure

Let's assume you have a fact table named `FactSales` with a column `SalesAmount`.

  1. In Visual Studio, open your SSAS project and navigate to the Data Source View.
  2. Find and expand the `FactSales` table.
  3. Right-click on the `SalesAmount` column.
  4. Select "New Measure".
  5. In the Measure Editor:
    • Name: Total Sales
    • Source Column: FactSales.[SalesAmount]
    • Aggregation Function: SUM
    • Format String: $#,##0.00
    • Description: The sum of all sales amounts.
  6. Click OK.
Placeholder for Measure Definition Dialog
Figure 1: Example of a Measure Definition Dialog in Visual Studio.

Best Practices for Measures

By effectively defining measures, you empower users to explore and analyze critical business data, leading to better insights and decision-making.