Create a tabular model in Azure Analysis Services
This tutorial guides you through creating a tabular model in Azure Analysis Services. This model will be used to create interactive reports and dashboards.
- An Azure subscription.
- An Azure Analysis Services instance.
- SQL Server Data Tools (SSDT) installed.
Step 1: Create a New Tabular Project
Launch Visual Studio and select File > New > Project.
In the Create a new project dialog, search for "Analysis Services" and select the Tabular project template. Click Next.
Enter a Project name (e.g., SalesTabularModel) and choose a Location. Click Create.
In the Tabular Model Designer dialog:
- Target Designer Version: Select the latest available version.
- Model Source: Choose Tabular.
- Compatibility Level: Select a compatibility level appropriate for your Azure Analysis Services instance.
- Model Name: Enter a name for your model (e.g.,
SalesModel).
Click OK.
Step 2: Connect to a Data Source
In Solution Explorer, right-click on the Data Sources folder and select Add Data Source.
In the Table import wizard, select SQL Server as the data source type. Click Next.
Server name: Enter the name of your Azure Analysis Services server instance (e.g., yourservername.asazure.windows.net).
Database name: Enter the name of the database you want to connect to (e.g., a SQL database containing your sales data).
Select the appropriate Authentication method (e.g., Service Principal or SQL Authentication) and provide credentials. Click Next.
Verify the connection by clicking Test Connection. Click Next, then Finish.
Step 3: Import Tables
In the Table import wizard, you will see a list of tables and views from your selected database.
Select the tables that contain your sales data, such as SalesOrderHeader, SalesOrderDetail, Product, and Customer. Click Next.
Figure 1: Selecting tables in the Table import wizard.
You can optionally deselect columns you don't need. Click Finish.
The wizard will import the selected tables into your tabular model.
Step 4: Create Relationships
In Solution Explorer, double-click the Model.bim file to open the model designer.
Click the Diagram View icon at the bottom of the designer to see your tables.
Drag and drop the foreign key column from one table to the primary key column in another table to create a relationship. For example, drag SalesOrderID from SalesOrderDetail to SalesOrderID in SalesOrderHeader.
Ensure relationships are created between all related tables (e.g., Product to SalesOrderDetail, Customer to SalesOrderHeader).
Figure 2: Creating relationships between tables.
Step 5: Create Measures
In the Model Designer, right-click on the table where you want to create a measure (e.g., SalesOrderDetail) and select Add New Measure.
In the Measure Properties pane:
- Name: Enter a descriptive name, e.g.,
Total Sales Amount. - Table: Ensure it's set to the correct table.
- Description: Optionally add a description.
- Format: Set the format (e.g., Currency).
In the Formula box, enter a DAX (Data Analysis Expressions) formula. For example:
SUM(SalesOrderDetail[LineTotal])
Press Enter to save the measure.
Repeat the process to create other useful measures, such as:
- Order Count:
COUNTROWS(SalesOrderHeader) - Average Sale Amount:
AVERAGE(SalesOrderDetail[LineTotal])
Step 6: Deploy the Model
In Solution Explorer, right-click on the project name (e.g., SalesTabularModel) and select Properties.
In the Properties window, set the Server name to your Azure Analysis Services instance name (e.g., yourservername.asazure.windows.net).
Optionally, change the Database name if you want it to be different on the server.
Right-click on the project name in Solution Explorer and select Deploy.
Visual Studio will build and deploy the model to your Azure Analysis Services instance. Monitor the Output window for deployment progress and any errors.
Figure 3: Monitoring deployment progress in Visual Studio.
Once deployment is successful, you can connect to this model from tools like Power BI or Excel to create reports.
Next Steps
Now that you have created and deployed your tabular model, you can: