Microsoft Developer Network

SQL Server Analysis Services - Multidimensional Modeling

Creating Calculations

This document details how to create and manage calculations within multidimensional models in SQL Server Analysis Services (SSAS). Calculations are essential for deriving new insights from your data, enabling complex business logic and advanced analytical scenarios.

Understanding Calculations

Calculations in SSAS are typically written using Multidimensional Expressions (MDX). MDX is a query language that allows you to manipulate and aggregate data from your cube. Calculations can be broadly categorized into:

Creating Calculated Measures

Calculated measures are created within the Measures dimension of your cube. They are often used to perform calculations like:

Steps to Create a Calculated Measure:

  1. In SQL Server Data Tools (SSDT), open your Analysis Services project.
  2. In Solution Explorer, right-click on the Measures folder within your cube and select New Measure.
  3. In the Measure Editor:
    • Provide a descriptive Name for your measure.
    • Select the Source (e.g., a measure or attribute from your data source).
    • Enter the MDX formula in the Expression box.
    • Configure formatting options such as Format String, Visible, and Aggregation Function.
  4. Click OK.

Creating Calculated Members

Calculated members are defined within a specific dimension, allowing you to group or derive data in new ways. For example, you might create a calculated member for "North America" by combining "USA" and "Canada" within a Geography dimension.

Steps to Create a Calculated Member:

  1. In SSDT, navigate to the dimension where you want to create the calculated member.
  2. Right-click on the dimension and select New Calculated Member.
  3. In the Calculated Member Editor:
    • Specify the Name.
    • Select the Parent Hierarchy.
    • Write the MDX Expression to define the member's value.
    • Set other properties like Format String and Visible.
  4. Click OK.

MDX Basics for Calculations

Familiarity with basic MDX concepts is crucial for effective calculation creation:

Best Practices

By mastering the creation of calculations, you can unlock the full analytical potential of your multidimensional models.