Creating Models in SQL Server Analysis Services

This section guides you through the process of creating various types of models within SQL Server Analysis Services (SSAS). SSAS supports both Multidimensional and Tabular models, each offering different advantages depending on your data analysis needs.

Choosing Your Model Type

Before you begin creating a model, it's crucial to understand the differences between the two primary model types:

Tip: For new projects, especially those integrating with Power BI, Tabular models are often the recommended choice due to their simplicity and performance. Multidimensional models remain powerful for complex, established OLAP scenarios.

Creating a Multidimensional Model

Creating a multidimensional model typically involves using SQL Server Data Tools (SSDT) for Visual Studio. The process generally includes:

1. Creating a New Analysis Services Project

Open Visual Studio and create a new Analysis Services Multidimensional Project.

2. Connecting to Data Sources

Define the connections to your underlying relational databases (e.g., SQL Server, Oracle) that will serve as the source for your model.

-- Example T-SQL for Data Source View
SELECT
    CustomerID,
    FirstName,
    LastName,
    OrderDate,
    ProductCategory,
    SalesAmount
FROM
    Sales.Orders AS o
JOIN
    Sales.Customers AS c ON o.CustomerID = c.CustomerID;

3. Designing the Data Source View (DSV)

The DSV acts as a logical representation of your data. You'll select tables and define relationships, hiding unnecessary complexity from end-users.

4. Creating Dimensions

Dimensions represent the business perspectives (e.g., Time, Geography, Product, Customer). You'll define attributes, hierarchies, and relationships within each dimension.

5. Creating Cubes

Cubes are the core of a multidimensional model. They are built upon dimensions and fact tables (containing measures). You'll define:

6. Deploying the Model

After designing and processing the model, you deploy it to an Analysis Services server.

Creating a Tabular Model

Tabular models can also be created using SSDT or, for more modern workflows, directly within SQL Server Management Studio (SSMS) for certain versions or using Visual Studio with the Azure Analysis Services or Power BI Dataset projects.

1. Creating a New Analysis Services Tabular Project (SSDT)

Select the Tabular project template in Visual Studio.

2. Connecting to Data Sources

Similar to multidimensional models, you'll establish connections to your data sources.

3. Importing Data

Unlike multidimensional models where you design a DSV, in tabular models, you typically import tables directly into the model's memory store.

4. Creating Relationships

Define relationships between tables to establish how data is connected, mirroring your relational schema.

5. Adding Calculations and Measures

Use DAX (Data Analysis Expressions) to create calculated columns and measures that aggregate and transform your data.

-- Example DAX Measure
Total Sales = SUM(Sales[SalesAmount])

-- Example DAX Calculated Column
Profit = Sales[SalesAmount] - Sales[CostAmount]

6. Deploying the Model

Deploy your tabular model to an SSAS Tabular instance or Azure Analysis Services.

Note: The tools and specific steps may vary slightly depending on the version of SQL Server Analysis Services and the IDE (Visual Studio versions, SSDT, SSMS) you are using.

Best Practices for Model Creation