Tutorial Analysis Service Tabular Model
Tutorial Analysis Service Tabular Model
Tutorial Analysis Service Tabular Model
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
This tutorial provides lessons on how to create and deploy a tabular model at the 1400 compatibility level. If you're
new to Analysis Services and tabular modeling, completing this tutorial is the quickest way to learn how to create
and deploy a basic tabular model by using Visual Studio. Once you have the prerequisites in-place, it should take
two to three hours to complete.
Prerequisites
To complete this tutorial, you need:
An Azure Analysis Services server or a SQL Server 2017 Analysis Services server in Tabular mode. Sign up
for a free Azure Analysis Services trial and create a server or download a free SQL Server 2017 Developer
Edition.
An Azure SQL Data Warehouse with the sample AdventureWorksDW database, or an on-premises SQL
Server Data Warehouse with an AdventureWorksDW sample database. When installing an
AdventureWorksDW database to an on-premises SQL Server Data Warehouse, use the sample database
version that corresponds with your server version.
Important: If you install the sample database to an on-premises SQL Server Data Warehouse, and deploy
your model to an Azure Analysis Services server, an On-premises data gateway is required.
The latest version of SQL Server Data Tools (SSDT). Or, if you already have Visual Studio 2017, you can
download and install Microsoft Analysis Services Projects (VSIX) package. For this tutorial, references to
SSDT and Visual Studio are synonymous.
The latest version of SQL Server Management Studio (SSMS ).
A client application such as Power BI Desktop or Excel.
Scenario
This tutorial is based on Adventure Works Cycles, a fictitious company. Adventure Works is a large, multinational
manufacturing company that produces and distributes bicycles, parts, and accessories for commercial markets in
North America, Europe, and Asia. The company employs 500 workers. Additionally, Adventure Works employs
several regional sales teams throughout its market base. Your project is to create a tabular model for sales and
marketing users to analyze Internet sales data in the AdventureWorksDW database.
To complete the tutorial, you must complete various lessons. In each lesson, there are tasks. Completing each task
in order is necessary for completing the lesson. While in a particular lesson there may be several tasks that
accomplish a similar outcome, but how you complete each task is slightly different. This method shows there is
often more than one way to complete a task, and to challenge you by using skills you've learned in previous
lessons and tasks.
The purpose of the lessons is to guide you through authoring a basic tabular model by using many of the features
included in SSDT. Because each lesson builds upon the previous lesson, you should complete the lessons in order.
This tutorial does not provide lessons about managing a server in Azure portal, managing a server or database by
using SSMS, or using a client application to browse model data.
Lessons
This tutorial includes the following lessons:
13 - Deploy 5 minutes
Supplemental lessons
These lessons are not required to complete the tutorial, but can be helpful in better understanding advanced
tabular model authoring features.
Next steps
To get started, see Lesson 1: Create a new tabular model project.
Create a tabular model project
3/8/2019 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you use Visual Studio with SQL Server Data Tools (SSDT) or Visual Studio 2017 with Microsoft
Analysis Services Projects VSIX to create a new tabular model project at the 1400 compatibility level. Once your
new project is created, you can begin adding data and authoring your model. This lesson also gives you a brief
introduction to the tabular model authoring environment in Visual Studio.
Estimated time to complete this lesson: 10 minutes
Prerequisites
This article is the first lesson in a tabular model authoring tutorial. To complete this lesson, there are several
prerequisites you need to have in-place. To learn more, see Analysis Services - Adventure Works tutorial.
Click the Solution Explorer tab. Here, you see your Model.bim file. If you don't see the designer window to the
left (the empty window with the Model.bim tab), in Solution Explorer, under AW Internet Sales Project,
double-click the Model.bim file. The Model.bim file contains the metadata for your model project.
Click Model.bim. In the Properties window, you see the model properties, most important of which is the
DirectQuery Mode property. This property specifies if the model is deployed in In-Memory mode (Off) or
DirectQuery mode (On). For this tutorial, you author and deploy your model in In-Memory mode.
When you create a model project, certain model properties are set automatically according to the Data Modeling
settings that can be specified in the Tools menu > Options dialog box. Data Backup, Workspace Retention, and
Workspace Server properties specify how and where the workspace database (your model authoring database) is
backed up, retained in-memory, and built. You can change these settings later if necessary, but for now, leave these
properties as they are.
In Solution Explorer, right-click AW Internet Sales (project), and then click Properties. The AW Internet
Sales Property Pages dialog box appears. You set some of these properties later when you deploy your model.
When you installed SSDT, several new menu items were added to the Visual Studio environment. Click the Model
menu. From here, you can import data, refresh workspace data, browse your model in Excel, create perspectives
and roles, select the model view, and set calculation options. Click the Table menu. From here, you can create and
manage relationships, specify date table settings, create partitions, and edit table properties. If you click the
Column menu, you can add and delete columns in a table, freeze columns, and specify sort order. SSDT also adds
some buttons to the bar. Most useful is the AutoSum feature to create a standard aggregation measure for a
selected column. Other toolbar buttons provide quick access to frequently used features and commands.
Explore some of the dialogs and locations for various features specific to authoring tabular models. While some
items are not yet active, you can get a good idea of the tabular model authoring environment.
What's next?
Lesson 2: Get data.
Get data
4/25/2019 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you use Get Data to connect to the AdventureWorksDW sample database, select data, preview and
filter, and then import into your model workspace.
Under the hood, Get Data is Power Query, which provides a vast array of tools for connecting to and reshaping
data for modeling and analysis. To learn more, see Power Query Documentation.
NOTE
Tasks and images in this tutorial show connecting to an AdventureWorksDW2014 database on an on-premises server. In
some cases, an AdventureWorksDW database on Azure SQL Data Warehouse may show different objects; however, they are
fundamentally the same.
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 1: Create a new tabular model project.
Create a connection
To create a connection to the AdventureWorksDW database
1. In Tabular Model Explorer, right-click Data Sources > Import from Data Source.
This launches Get Data, which guides you through connecting to a data source. If you don't see Tabular
Model Explorer, in Solution Explorer, double-click Model.bim to open the model in the designer.
2. In Get Data, click Database > SQL Server Database > Connect.
3. In the SQL Server Database dialog, in Server, type the name of the server where you installed the
AdventureWorksDW database, and then click Connect.
4. When prompted to enter credentials, you need to specify the credentials Analysis Services uses to connect to
the data source when importing and processing data. In Impersonation Mode, select Impersonate
Account, then enter credentials, and then click Connect. It's recommended you use an account where the
password doesn't expire.
NOTE
Using a Windows user account and password provides the most secure method of connecting to a data source.
5. In Navigator, select the AdventureWorksDW database, and then click OK. This creates the connection to
the database.
6. In Navigator, select the check box for the following tables: DimCustomer, DimDate, DimGeography,
DimProduct, DimProductCategory, DimProductSubcategory, and FactInternetSales. After selecting
the tables, click Edit.
After you click Edit, Query Editor opens. In the next section, you select only the data you want to import.
TIP
If you make a mistake, you can backup by deleting a step in APPLIED STEPS.
3. Filter the remaining tables by removing the following columns in each table:
DimDate
COLUMN
DateKey
SpanishDayNameOfWeek
FrenchDayNameOfWeek
SpanishMonthName
FrenchMonthName
DimGeography
COLUMN
SpanishCountryRegionName
FrenchCountryRegionName
IpAddressLocator
DimProduct
COLUMN
SpanishProductName
FrenchProductName
FrenchDescription
ChineseDescription
ArabicDescription
HebrewDescription
ThaiDescription
GermanDescription
JapaneseDescription
TurkishDescription
DimProductCategory
COLUMN
SpanishProductCategoryName
FrenchProductCategoryName
DimProductSubcategory
COLUMN
SpanishProductSubcategoryName
FrenchProductSubcategoryName
FactInternetSales
No columns removed.
2. Click Close.
What's next?
Lesson 3: Mark as Date Table.
Mark as Date Table
3/8/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In Lesson 2: Get data, you imported a dimension table named DimDate. While in your model this table is named
DimDate, it can also be known as a Date table, in that it contains date and time data.
Whenever you use DAX time-intelligence functions, like when you create measures later, you must specify
properties which include a Date table and a unique identifier Date column in that table.
In this lesson, you mark the DimDate table as the Date table and the Date column (in the Date table) as the Date
column (unique identifier).
Before you mark the date table and date column, it's a good time to do a little housekeeping to make your model
easier to understand. Notice in the DimDate table a column named FullDateAlternateKey. This column contains
one row for every day in each calendar year included in the table. You use this column a lot in measure formulas
and in reports. But, FullDateAlternateKey isn't really a good identifier for this column. You rename it to Date,
making it easier to identify and include in formulas. Whenever possible, it's a good idea to rename objects like
tables and columns to make them easier to identify in SSDT and client reporting applications.
Estimated time to complete this lesson: Three minutes
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 2: Get data.
To rename the FullDateAlternateKey column
1. In the model designer, click the DimDate table.
2. Double-click the header for the FullDateAlternateKey column, and then rename it to Date.
To set Mark as Date Table
1. Select the Date column, and then in the Properties window, under Data Type, make sure Date is selected.
2. Click the Table menu, then click Date, and then click Mark as Date Table.
3. In the Mark as Date Table dialog box, in the Date listbox, select the Date column as the unique identifier.
It's usually selected by default. Click OK.
What's next?
Lesson 4: Create relationships.
Create relationships
3/8/2019 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you verify the relationships that were created automatically when you imported data and add new
relationships between different tables. A relationship is a connection between two tables that establishes how the
data in those tables should be correlated. For example, the DimProduct table and the DimProductSubcategory
table have a relationship based on the fact that each product belongs to a subcategory. To learn more, see
Relationships.
Estimated time to complete this lesson: 10 minutes
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 3: Mark as Date Table.
Include as many of the tables as possible by using minimap controls in the lower-right corner of the model
designer. You can also click and drag tables to different locations, bringing tables closer together, or putting
them in a particular order. Moving tables does not affect the relationships between the tables. To view all
the columns in a particular table, click and drag on a table edge to expand or make it smaller.
2. Click the solid line between the DimCustomer table and the DimGeography table. The solid line between
these two tables shows this relationship is active, that is, it is used by default when calculating DAX
formulas.
Notice the GeographyKey column in the DimCustomer table and the GeographyKey column in the
DimGeography table now both each appear within a box. These columns are used in the relationship. The
relationship's properties now also appear in the Properties window.
TIP
You can also use the Manage Relationships dialog box to show the relationships between all tables in a table format.
In Tabular Model Explorer, right-click Relationships > Manage Relationships.
3. Verify the following relationships were created when each of the tables were imported from the
AdventureWorksDW database:
If any of the relationships are missing, verify your model includes the following tables: DimCustomer,
DimDate, DimGeography, DimProduct, DimProductCategory, DimProductSubcategory, and
FactInternetSales. If tables from the same datasource connection are imported at separate times, any
relationships between those tables are not be created and must be created manually. If no relationships
appear, it means there are no relationships at the datasource. You can create them manually in the data
model.
Take a closer look
In Diagram View, notice an arrow, an asterisk, and a number on the lines that show the relationship between
tables.
The arrow shows the filter direction. The asterisk shows this table is the many side in the relationship's cardinality,
and the one shows this table is the one side of the relationship. If you need to edit a relationship; for example,
change the relationship's filter direction or cardinality, double-click the relationship line to open the Edit
Relationship dialog.
These features are meant for advanced data modeling and are outside the scope of this tutorial. To learn more, see
Bi-directional cross filters for tabular models in Analysis Services.
In some cases, you may need to create additional relationships between tables in your model to support certain
business logic. For this tutorial, you need to create three additional relationships between the FactInternetSales
table and the DimDate table.
To add new relationships between tables
1. In the model designer, in the FactInternetSales table, click, and hold on the OrderDate column, then drag
the cursor to the Date column in the DimDate table, and then release.
A solid line appears showing you have created an active relationship between the OrderDate column in
the Internet Sales table, and the Date column in the Date table.
NOTE
When creating relationships, the cardinality and filter direction between the primary table and the related lookup
table is automatically selected.
2. In the FactInternetSales table, click and hold on the DueDate column, then drag the cursor to the Date
column in the DimDate table, and then release.
A dotted line appears showing you have created an inactive relationship between the DueDate column in
the FactInternetSales table, and the Date column in the DimDate table. You can have multiple
relationships between tables, but only one relationship can be active at a time. Inactive relationships can be
made active to perform special aggregations in custom DAX expressions.
3. Finally, create one more relationship. In the FactInternetSales table, click and hold on the ShipDate
column, then drag the cursor to the Date column in the DimDate table, and then release.
What's next?
Lesson 5: Create calculated columns.
Create calculated columns
4/25/2019 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you create data in your model by adding calculated columns. You can create calculated columns (as
custom columns) when using Get Data, by using the Query Editor, or later in the model designer like you do here.
To learn more, see Calculated columns.
You create five new calculated columns in three different tables. The steps are slightly different for each task
showing there are several ways to create columns, rename them, and place them in various locations in a table.
This lesson is also where you first use Data Analysis Expressions (DAX). DAX is a special language for creating
highly customizable formula expressions for tabular models. In this tutorial, you use DAX to create calculated
columns, measures, and role filters. To learn more, see DAX in tabular models.
Estimated time to complete this lesson: 15 minutes
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 4: Create relationships.
Values are then populated for all the rows in the calculated column. If you scroll down through the table,
you see rows can have different values for this column, based on the data in each row.
5. Rename this column to MonthCalendar.
The MonthCalendar calculated column provides a sortable name for Month.
Create a DayOfWeek calculated column in the DimDate table
1. With the DimDate table still active, click the Column menu, and then click Add Column.
2. In the formula bar, type the following formula:
When you've finished building the formula, press ENTER. The new column is added to the far right of the
table.
3. Rename the column to DayOfWeek.
4. Click the column heading, and then drag the column between the EnglishDayNameOfWeek column and
the DayNumberOfMonth column.
TIP
Moving columns in your table makes it easier to navigate.
The DayOfWeek calculated column provides a sortable name for the day of week.
Create a ProductSubcategoryName calculated column in the DimProduct table
1. In the DimProduct table, scroll to the far right of the table. Notice the right-most column is named Add
Column, click the column heading.
2. In the formula bar, type the following formula:
=RELATED('DimProductSubcategory'[EnglishProductSubcategoryName])
=RELATED('DimProductCategory'[EnglishProductCategoryName])
=[SalesAmount]-[TotalProductCost]
The Margin calculated column is used to analyze profit margins for each sale.
What's next?
Lesson 6: Create measures.
Create measures
3/8/2019 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you create measures to be included in your model. Similar to the calculated columns you created, a
measure is a calculation created by using a DAX formula. However, unlike calculated columns, measures are
evaluated based on a user selected filter. For example, a particular column or slicer added to the Row Labels field
in a PivotTable. A value for each cell in the filter is then calculated by the applied measure. Measures are powerful,
flexible calculations that you want to include in almost all tabular models to perform dynamic calculations on
numerical data. To learn more, see Measures.
To create measures, you use the Measure Grid. By default, each table has an empty measure grid; however, you
typically do not create measures for every table. The measure grid appears below a table in the model designer
when in Data View. To hide or show the measure grid for a table, click the Table menu, and then click Show
Measure Grid.
You can create a measure by clicking an empty cell in the measure grid, and then typing a DAX formula in the
formula bar. When you click ENTER to complete the formula, the measure then appears in the cell. You can also
create measures using a standard aggregation function by clicking a column, and then clicking the AutoSum
button (∑) on the toolbar. Measures created using the AutoSum feature appear in the measure grid cell directly
beneath the column, but can be moved.
In this lesson, you create measures by both entering a DAX formula in the formula bar, and by using the AutoSum
feature.
Estimated time to complete this lesson: 30 minutes
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 5: Create calculated columns.
Create measures
To create a DaysCurrentQuarterToDate measure in the DimDate table
1. In the model designer, click the DimDate table.
2. In the measure grid, click the top-left empty cell.
3. In the formula bar, type the following formula:
Notice the top-left cell now contains a measure name, DaysCurrentQuarterToDate, followed by the
result, 92. The result is not relevant at this point because no user filter has been applied.
Unlike calculated columns, with measure formulas you can type the measure name, followed by a colon,
followed by the formula expression.
To create a DaysInCurrentQuarter measure in the DimDate table
1. With the DimDate table still active in the model designer, in the measure grid, click the empty cell below
the measure you created.
2. In the formula bar, type the following formula:
When creating a comparison ratio between one incomplete period and the previous period. The formula
must calculate the proportion of the period that has elapsed and compare it to the same proportion in the
previous period. In this case, [DaysCurrentQuarterToDate]/[DaysInCurrentQuarter] gives the proportion
elapsed in the current period.
To create an InternetDistinctCountSalesOrder measure in the FactInternetSales table
1. Click the FactInternetSales table.
2. Click the SalesOrderNumber column heading.
3. On the toolbar, click the down-arrow next to the AutoSum (∑) button, and then select DistinctCount.
The AutoSum feature automatically creates a measure for the selected column using the DistinctCount
standard aggregation formula.
4. In the measure grid, click the new measure, and then in the Properties window, in Measure Name,
rename the measure to InternetDistinctCountSalesOrder.
To create additional measures in the FactInternetSales table
1. By using the AutoSum feature, create and name the following measures:
2. By clicking an empty cell in the measure grid, and by using the formula bar, create, the following custom
measures in order:
InternetPreviousQuarterMargin:=CALCULATE([InternetTotalMargin],PREVIOUSQUARTER('DimDate'[Date]))
InternetCurrentQuarterMargin:=TOTALQTD([InternetTotalMargin],'DimDate'[Date])
InternetPreviousQuarterMarginProportionToQTD:=[InternetPreviousQuarterMargin]*
([DaysCurrentQuarterToDate]/[DaysInCurrentQuarter])
InternetPreviousQuarterSales:=CALCULATE([InternetTotalSales],PREVIOUSQUARTER('DimDate'[Date]))
InternetCurrentQuarterSales:=TOTALQTD([InternetTotalSales],'DimDate'[Date])
InternetPreviousQuarterSalesProportionToQTD:=[InternetPreviousQuarterSales]*
([DaysCurrentQuarterToDate]/[DaysInCurrentQuarter])
Measures created for the FactInternetSales table can be used to analyze critical financial data such as sales, costs,
and profit margin for items defined by the user selected filter.
What's next?
Lesson 7: Create Key Performance Indicators.
Create Key Performance Indicators
4/29/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you create Key Performance Indicators (KPIs). KPIs are used to gauge performance of a value
defined by a Base measure, against a Target value also defined by a measure, or by an absolute value. In reporting
client applications, KPIs can provide business professionals a quick and easy way to understand a summary of
business success or to identify trends. To learn more, see KPIs
Estimated time to complete this lesson: 15 minutes
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 6: Create measures.
InternetCurrentQuarterSalesPerformance :=IF([InternetPreviousQuarterSalesProportionToQTD]<>0,
([InternetCurrentQuarterSales]-
[InternetPreviousQuarterSalesProportionToQTD])/[InternetPreviousQuarterSalesProportionToQTD],BLANK())
InternetCurrentQuarterMarginPerformance :=IF([InternetPreviousQuarterMarginProportionToQTD]<>0,
([InternetCurrentQuarterMargin]-
[InternetPreviousQuarterMarginProportionToQTD])/[InternetPreviousQuarterMarginProportionToQTD],BLANK())
What's next?
Lesson 8: Create perspectives.
Create perspectives
3/8/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you create an Internet Sales perspective. A perspective defines a viewable subset of a model that
provides focused, business-specific, or application-specific viewpoints. When a user connects to a model by using
a perspective, they see only those model objects (tables, columns, measures, hierarchies, and KPIs) as fields
defined in that perspective. To learn more, see Perspectives.
The Internet Sales perspective you create in this lesson excludes the DimCustomer table object. When you create a
perspective that excludes certain objects from view, that object still exists in the model. However, it is not visible in
a reporting client field list. Calculated columns and measures either included in a perspective or not can still
calculate from object data that is excluded.
The purpose of this lesson is to describe how to create perspectives and become familiar with the tabular model
authoring tools. If you later expand this model to include additional tables, you can create additional perspectives
to define different viewpoints of the model, for example, Inventory and Sales.
Estimated time to complete this lesson: Five minutes
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 7: Create Key Performance Indicators.
Create perspectives
To create an Internet Sales perspective
1. Click the Model menu > Perspectives > Create and Manage.
2. In the Perspectives dialog box, click New Perspective.
3. Double-click the New Perspective column heading, and then rename Internet Sales.
4. Select the all the tables except DimCustomer.
In a later lesson, you use the Analyze in Excel feature to test this perspective. The Excel PivotTable Fields List
includes each table except the DimCustomer table.
What's next?
Lesson 9: Create hierarchies.
Create hierarchies
3/8/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you create hierarchies. Hierarchies are groups of columns arranged in levels. For example, a
Geography hierarchy might have sublevels for Country, State, County, and City. Hierarchies can appear separate
from other columns in a reporting client application field list, making them easier for client users to navigate and
include in a report. To learn more, see Hierarchies
To create hierarchies, use the model designer in Diagram View. Creating and managing hierarchies is not
supported in Data View.
Estimated time to complete this lesson: 20 minutes
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 8: Create perspectives.
Create hierarchies
To create a Category hierarchy in the DimProduct table
1. In the model designer (diagram view), right-click the DimProduct table > Create Hierarchy. A new
hierarchy appears at the bottom of the table window. Rename the hierarchy Category.
2. Click and drag the ProductCategoryName column to the new Category hierarchy.
3. In the Category hierarchy, right-click ProductCategoryName > Rename, and then type Category.
NOTE
Renaming a column in a hierarchy does not rename that column in the table. A column in a hierarchy is just a
representation of the column in the table.
4. Click and drag the ProductSubcategoryName column to the Category hierarchy. Rename it
Subcategory.
5. Right-click the ModelName column > Add to hierarchy, and then select Category. Rename it Model.
6. Finally, add EnglishProductName to the Category hierarchy. Rename it Product.
To create hierarchies in the DimDate table
1. In the DimDate table, create a hierarchy named Calendar.
2. Add the following columns in-order:
CalendarYear
CalendarSemester
CalendarQuarter
MonthCalendar
DayNumberOfMonth
3. In the DimDate table, create a Fiscal hierarchy. Include the following columns in-order:
FiscalYear
FiscalSemester
FiscalQuarter
MonthCalendar
DayNumberOfMonth
4. Finally, in the DimDate table, create a ProductionCalendar hierarchy. Include the following columns in-
order:
CalendarYear
WeekNumberOfYear
DayNumberOfWeek
What's next?
Lesson 10: Create partitions.
Create partitions
3/8/2019 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you create partitions to divide the FactInternetSales table into smaller logical parts that can be
processed (refreshed) independent of other partitions. By default, every table you include in your model has one
partition, which includes all the table's columns and rows. For the FactInternetSales table, we want to divide the
data by year; one partition for each of the table's five years. Each partition can then be processed independently. To
learn more, see Partitions.
Estimated time to complete this lesson: 15 minutes
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 9: Create Hierarchies.
Create partitions
To create partitions in the FactInternetSales table
1. In Tabular Model Explorer, expand Tables, and then right-click FactInternetSales > Partitions.
2. In Partition Manager, click Copy, and then change the name to FactInternetSales2010.
Because you want the partition to include only those rows within a certain period, for the year 2010, you
must modify the query expression.
3. Click Design to open Query Editor, and then click the FactInternetSales2010 query.
4. In preview, click the down arrow in the OrderDate column heading, and then click Date/Time Filters >
Between.
5. In the Filter Rows dialog box, in Show rows where: OrderDate, leave is after or equal to, and then in the
date field, enter 1/1/2010. Leave the And operator selected, then select is before, then in the date field,
enter 1/1/2011, and then click OK.
Notice in Query Editor, in APPLIED STEPS, you see another step named Filtered Rows. This filter is to
select only order dates from 2010.
6. Click Import.
In Partition Manager, notice the query expression now has an additional Filtered Rows clause.
This statement specifies this partition should include only the data in those rows where the OrderDate is in
the 2010 calendar year as specified in the filtered rows clause.
To create a partition for the 2011 year
1. In the partitions list, click the FactInternetSales2010 partition you created, and then click Copy. Change
the partition name to FactInternetSales2011.
You do not need to use Query Editor to create a new filtered rows clause. Because you created a copy of the
query for 2010, all you need to do is make a slight change in the query for 2011.
2. In Query Expression, in-order for this partition to include only those rows for the 2011 year, replace the
years in the Filtered Rows clause with 2011 and 2012, respectively, like:
let
Source = #"SQL/localhost;AdventureWorksDW2014",
dbo_FactInternetSales = Source{[Schema="dbo",Item="FactInternetSales"]}[Data],
#"Removed Columns" = Table.RemoveColumns(dbo_FactInternetSales,{"OrderDateKey", "DueDateKey",
"ShipDateKey"}),
#"Filtered Rows" = Table.SelectRows(#"Removed Columns", each [OrderDate] >= #datetime(2011, 1, 1,
0, 0, 0) and [OrderDate] < #datetime(2012, 1, 1, 0, 0, 0))
in
#"Filtered Rows"
Process partitions
In Partition Manager, notice the Last Processed column for each of the new partitions you created shows these
partitions have never been processed. When you create partitions, you should run a Process Partitions or Process
Table operation to refresh the data in those partitions.
To process the FactInternetSales partitions
1. Click OK to close Partition Manager.
2. Click the FactInternetSales table, then click the Model menu > Process > Process Partitions.
3. In the Process Partitions dialog box, verify Mode is set to Process Default.
4. Select the checkbox in the Process column for each of the five partitions you created, and then click OK.
If you're prompted for Impersonation credentials, enter the Windows user name and password you
specified in Lesson 2.
The Data Processing dialog box appears and displays process details for each partition. Notice that a
different number of rows for each partition are transferred. Each partition includes only those rows for the
year specified in the WHERE clause in the SQL Statement. When processing is finished, go ahead and close
the Data Processing dialog box.
What's next?
Go to the next lesson: Lesson 11: Create Roles.
Create roles
3/8/2019 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you create roles. Roles provide model database object and data security by limiting access to only
those users that are role members. Each role is defined with a single permission: None, Read, Read and Process,
Process, or Administrator. Roles can be defined during model authoring by using Role Manager. After a model
has been deployed, you can manage roles by using SQL Server Management Studio (SSMS ). To learn more, see
Roles.
NOTE
Creating roles is not necessary to complete this tutorial. By default, the account you are currently logged in with has
Administrator privileges on the model. However, for other users in your organization to browse by using a reporting client,
you must create at least one role with Read permissions and add those users as members.
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 10: Create partitions.
Create roles
To create a Sales Manager user role
1. In Tabular Model Explorer, right-click Roles > Roles.
2. In Role Manager, click New.
3. Click the new role, and then in the Name column, rename the role to Sales Manager.
4. In the Permissions column, click the dropdown list, and then select the Read permission.
5. Optional: Click the Members tab, and then click Add. In the Select Users or Groups dialog box, enter the
Windows users or groups from your organization you want to include in the role.
To create a Sales Analyst US user role
1. In Role Manager, click New.
2. Rename the role to Sales Analyst US.
3. Give this role Read permission.
4. Click the Row Filters tab, and then for the DimGeography table only, in the DAX Filter column, type the
following formula:
=DimGeography[CountryRegionCode] = "US"
A Row Filter formula must resolve to a Boolean (TRUE/FALSE ) value. With this formula, you are specifying
that only rows with the Country Region Code value of "US" are visible to the user.
5. Optional: Click the Members tab, and then click Add. In the Select Users or Groups dialog box, enter the
Windows users or groups from your organization you want to include in the role.
To create an Administrator user role
1. Click New.
2. Rename the role to Administrator.
3. Give this role Administrator permission.
4. Optional: Click the Members tab, and then click Add. In the Select Users or Groups dialog box, enter the
Windows users or groups from your organization you want to include in the role.
What's next?
Lesson 12: Analyze in Excel.
Analyze in Excel
4/10/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you use the Analyze in Excel feature to open Microsoft Excel, automatically create a connection to
the model workspace, and automatically add a PivotTable to the worksheet. The Analyze in Excel feature is meant
to provide a quick and easy way to test the efficacy of your model design prior to deploying your model. You do
not perform any data analysis in this lesson. The purpose of this lesson is to familiarize you, the model author, with
the tools you can use to test your model design.
To complete this lesson, Excel must be installed on the same computer as Visual Studio.
Estimated time to complete this lesson: 5 minutes
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 11: Create roles.
What's next?
Go to the next lesson: Lesson 13: Deploy.
Deploy
3/8/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you configure deployment properties; specifying a server to deploy to and a name for the model.
You then deploy the model to the server. After your model is deployed, users can connect to it by using a reporting
client application. To learn more, see Deploy to Azure Analysis Services and Tabular model solution deployment.
Estimated time to complete this lesson: 5 minutes
Prerequisites
This article is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 12: Analyze in Excel.
IMPORTANT
If deploying to Azure Analysis Services, you must have Administrator permissions on the serever.
IMPORTANT
If you installed the AdventureWorksDW sample database on an on-premises SQL Server, and you're deploying your model
to an Azure Analysis Services server, an On-premises data gateway is required.
Conclusion
Congratulations! You're finished authoring and deploying your first Analysis Services Tabular model. This tutorial
has helped guide you through completing the most common tasks in creating a tabular model. Now that your
Adventure Works Internet Sales model is deployed, you can use SQL Server Management Studio to manage the
model; create process scripts and a backup plan. Users can also now connect to the model using a reporting client
application such as Microsoft Excel or Power BI.
What's next?
Connect with Power BI Desktop
Supplemental Lesson - Dynamic security
Supplemental Lesson - Detail rows
Supplemental Lesson - Ragged hierarchies
Supplemental lesson - Detail Rows
3/8/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this supplemental lesson, you use the DAX Editor to define a custom Detail Rows Expression. A Detail Rows
Expression is a property on a measure, providing end-users more information about the aggregated results of a
measure.
Estimated time to complete this lesson: 10 minutes
Prerequisites
This supplemental lesson article is part of a tabular modeling tutorial. Before performing the tasks in this
supplemental lesson, you should have completed all previous lessons or have a completed Adventure Works
Internet Sales sample model project.
3. In the PivotTable, double-click an aggregated value for a year and a region name. Here we double-clicked
the value for Australia and the year 2014. A new sheet opens containing data, but not useful data.
What we want to see here is a table containing columns and rows of data that contribute to the aggregated result
of the InternetTotalSales measure. To do that, we can add a Detail Rows Expression as a property of the measure.
SELECTCOLUMNS(
FactInternetSales,
"Sales Order Number", FactInternetSales[SalesOrderNumber],
"Customer First Name", RELATED(DimCustomer[FirstName]),
"Customer Last Name", RELATED(DimCustomer[LastName]),
"City", RELATED(DimGeography[City]),
"Order Date", FactInternetSales[OrderDate],
"Internet Total Sales", [InternetTotalSales]
)
This expression specifies names, columns, and measure results from the FactInternetSales table and related
tables are returned when a user double-clicks an aggregated result in a PivotTable or report.
4. Back in Excel, delete the sheet created in Step 3, then double-click an aggregated value. This time, with a
Detail Rows Expression property defined for the measure, a new sheet opens containing a lot more useful
data.
See also
SELECTCOLUMNS Function (DAX)
Supplemental lesson - Dynamic security
Supplemental lesson - Ragged hierarchies
Supplemental lesson - Dynamic security
4/25/2019 • 9 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this supplemental lesson, you create an additional role that implements dynamic security. Dynamic security
provides row-level security based on the user name or login id of the user currently logged on.
To implement dynamic security, you add a table to your model containing the user names of those users that can
connect to the model and browse model objects and data. The model you create using this tutorial is in the context
of Adventure Works; however, to complete this lesson, you must add a table containing users from your own
domain. You do not need the passwords for the user names that are added. To create an EmployeeSecurity table,
with a small sample of users from your own domain, you use the Paste feature, pasting employee data from an
Excel spreadsheet. In a real-world scenario, the table containing user names would typically be a table from an
actual database as a data source; for example, a real DimEmployee table.
To implement dynamic security, you use two DAX functions: USERNAME Function (DAX) and LOOKUPVALUE
Function (DAX). These functions, applied in a row filter formula, are defined in a new role. By using the
LOOKUPVALUE function, the formula specifies a value from the EmployeeSecurity table. The formula then passes
that value to the USERNAME function, which specifies the user name of the user logged on belongs to this role.
The user can then browse only data specified by the role's row filters. In this scenario, you specify that sales
employees can only browse Internet sales data for the sales territories in which they are a member.
Those tasks that are unique to this Adventure Works tabular model scenario, but would not necessarily apply to a
real-world scenario are identified as such. Each task includes additional information describing the purpose of the
task.
Estimated time to complete this lesson: 30 minutes
Prerequisites
This supplemental lesson article is part of a tabular modeling tutorial, which should be completed in order. Before
performing the tasks in this supplemental lesson, you should have completed all previous lessons.
|EmployeeId|SalesTerritoryId|FirstName|LastName|LoginId|
|---------------|----------------------|--------------|-------------|------------|
|1|2|<user first name>|<user last name>|\<domain\username>|
|1|3|<user first name>|<user last name>|\<domain\username>|
|2|4|<user first name>|<user last name>|\<domain\username>|
|3|5|<user first name>|<user last name>|\<domain\username>|
3. Replace the first name, last name, and domain\username with the names and login ids of three users in
your organization. Put the same user on the first two rows, for EmployeeId 1, showing this user belongs to
more than one sales territory. Leave the EmployeeId and SalesTerritoryId fields as they are.
4. Save the worksheet as SampleEmployee.
5. In the worksheet, select all the cells with employee data, including the headers, then right-click the selected
data, and then click Copy.
6. In SSDT, click the Edit menu, and then click Paste.
If Paste is grayed out, click any column in any table in the model designer window, and try again.
7. In the Paste Preview dialog box, in Table Name, type EmployeeSecurity.
8. In Data to be pasted, verify the data includes all the user data and headers from the SampleEmployee
worksheet.
9. Verify Use first row as column headers is checked, and then click Ok.
A new table named EmployeeSecurity with employee data copied from the SampleEmployee worksheet is
created.
NOTE
The Sales Employees by Territory role you create in this lesson restricts members to browse (or query) only sales data for the
sales territory to which they belong. If you add a user as a member to the Sales Employees by Territory role that also exists
as a member in a role created in Lesson 11: Create Roles, you get a combination of permissions. When a user is a member of
multiple roles, the permissions, and row filters defined for each role are cumulative. That is, the user has the greater
permissions determined by the combination of roles.
This formula specifies that all columns resolve to the false Boolean condition. No columns for the
EmployeeSecurity table can be queried by a member of the Sales Employees by Territory user role.
9. For the DimSalesTerritory table, type the following formula:
='DimSalesTerritory'[SalesTerritoryKey]=LOOKUPVALUE('EmployeeSecurity'[SalesTerritoryId],
'EmployeeSecurity'[LoginId], USERNAME(),
'EmployeeSecurity'[SalesTerritoryId], 'DimSalesTerritory'[SalesTerritoryKey])
In this formula, the LOOKUPVALUE function returns all values for the
DimEmployeeSecurity[SalesTerritoryId] column, where the EmployeeSecurity[LoginId] is the same as the
current logged on Windows user name, and EmployeeSecurity[SalesTerritoryId] is the same as the
DimSalesTerritory[SalesTerritoryId].
The set of sales territory IDs returned by LOOKUPVALUE is then used to restrict the rows shown in the
DimSalesTerritory table. Only rows where the SalesTerritoryID for the row is in the set of IDs returned by
the LOOKUPVALUE function are displayed.
10. In Role Manager, click Ok.
See Also
USERNAME Function (DAX)
LOOKUPVALUE Function (DAX)
CUSTOMDATA Function (DAX)
Supplemental lesson - Ragged hierarchies
3/8/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2017 Analysis Services and later Azure Analysis Services Power BI
Premium
In this supplemental lesson, you resolve a common problem when pivoting on hierarchies that contain blank
values (members) at different levels. For example, an organization where a high-level manager has both
departmental managers and non-managers as direct reports. Or, geographic hierarchies composed of Country-
Region-City, where some cities lack a parent State or Province, such as Washington D.C., Vatican City. When a
hierarchy has blank members, it often descends to different, or ragged, levels.
Tabular models at the 1400 compatibility level have an additional Hide Members property for hierarchies. The
Default setting assumes there are no blank members at any level. The Hide blank members setting excludes
blank members from the hierarchy when added to a PivotTable or report.
Estimated time to complete this lesson: 20 minutes
Prerequisites
This supplemental lesson article is part of a tabular modeling tutorial. Before performing the tasks in this
supplemental lesson, you should have completed all previous lessons or have a completed Adventure Works
Internet Sales sample model project.
If you've created the AW Internet Sales project as part of the tutorial, your model does not yet contain any data or
hierarchies that are ragged. To complete this supplemental lesson, you first have to create the problem by adding
some additional tables, create relationships, calculated columns, a measure, and a new Organization hierarchy.
That part takes about 15 minutes. Then, you get to solve it in just a few minutes.
=PATH([EmployeeKey],[ParentEmployeeKey])
FullName
=[FirstName] & " " & [MiddleName] & " " & [LastName]
Level1
=LOOKUPVALUE(DimEmployee[FullName],DimEmployee[EmployeeKey],PATHITEM([Path],1,1))
Level2
=LOOKUPVALUE(DimEmployee[FullName],DimEmployee[EmployeeKey],PATHITEM([Path],2,1))
Level3
=LOOKUPVALUE(DimEmployee[FullName],DimEmployee[EmployeeKey],PATHITEM([Path],3,1))
Level4
=LOOKUPVALUE(DimEmployee[FullName],DimEmployee[EmployeeKey],PATHITEM([Path],4,1))
Level5
=LOOKUPVALUE(DimEmployee[FullName],DimEmployee[EmployeeKey],PATHITEM([Path],5,1))
6. In the DimEmployee table, create a hierarchy named Organization. Add the following columns in-order:
Level1, Level2, Level3, Level4, Level5.
7. In the FactResellerSales table, create the following measure:
ResellerTotalSales:=SUM([SalesAmount])
As you can see in the PivotTable, the hierarchy displays rows that are ragged. There are many rows where
blank members are shown.
See Also
Lesson 9: Create hierarchies
Supplemental Lesson - Dynamic security
Supplemental Lesson - Detail rows
Adventure Works Internet Sales tutorial (1200)
5/9/2019 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
This tutorial provides lessons on how to create an Analysis Services tabular model at the 1200 compatibility level
by using SQL Server Data Tools (SSDT), and deploy your model to an Analysis Services server on-premises or in
Azure.
If you're using SQL Server 2017 or Azure Analysis Services, and you want to create your model at the 1400
compatibility level, use the Tabular modeling (1400 compatibility level). This updated version uses the modern Get
Data feature to connect and import source data, uses the M language to configure partitions, and includes
additional supplemental lessons.
IMPORTANT
You should create your tabular models at the latest compatibility level supported by your server. Later compatibility level
models provide improved performance, additional features, and will upgrade to future compatibility levels more seamlessly.
Scenario
This tutorial is based on Adventure Works Cycles, a fictitious company. Adventure Works is a large, multinational
manufacturing company that produces bicycles, parts, and accessories for commercial markets in North America,
Europe, and Asia. With headquarters in Bothell, Washington, the company employs 500 workers. Additionally,
Adventure Works employs several regional sales teams throughout its market base.
To better support the data analysis needs of sales and marketing teams and of senior management, you are tasked
with creating a tabular model for users to analyze Internet sales data in the AdventureWorksDW sample database.
In order to complete the tutorial, and the Adventure Works Internet Sales tabular model, you must complete a
number of lessons. In each lesson is a number of tasks; completing each task in order is necessary for completing
the lesson. While in a particular lesson there may be several tasks that accomplish a similar outcome, but how you
complete each task is slightly different. This is to show that there is often more than one way to complete a
particular task, and to challenge you by using skills you've learned in previous tasks.
The purpose of the lessons is to guide you through authoring a basic tabular model running in In-Memory mode
by using many of the features included in SSDT. Because each lesson builds upon the previous lesson, you should
complete the lessons in order. Once you've completed all of the lessons, you have authored and deployed the
Adventure Works Internet Sales sample tabular model on an Analysis Services server.
This tutorial does not provide lessons or information about managing a deployed tabular model database by using
SQL Server Management Studio, or using a reporting client application to connect to a deployed model to browse
model data.
Prerequisites
In order to complete this tutorial, you need the following prerequisites:
The latest version of SSDT.
The latest version of SQL Server Management Studio. Get the latest version.
A client application such as Power BI Desktop or Excel.
A SQL Server instance with the Adventure Works DW sample database. This sample database includes the
data necessary to complete this tutorial. Get the latest version.
An Azure Analysis Services or SQL Server 2016 or later Analysis Services instance to deploy your model
to. Sign up for a free Azure Analysis Services trial.
Lessons
This tutorial includes the following lessons:
Supplemental lessons
This tutorial also includes Supplemental Lessons. Topics in this section are not required to complete the tutorial,
but can be helpful in better understanding advanced tabular model authoring features.
Next steps
To begin the tutorial, continue to the first lesson: Lesson 1: Create a New Tabular Model Project.
Lesson 1: Create a New Tabular Model Project
5/7/2019 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you will create a new, blank tabular model project in SQL Server Data Tools (SSDT). Once your new
project is created, you can begin adding data by using the Table Import Wizard. This lesson also gives you a brief
introduction to the tabular model authoring environment in SSDT.
Estimated time to complete this lesson: 10 minutes
Prerequisites
This topic is the first lesson in a tabular model authoring tutorial. To complete this lesson, you must have the
AdventureWorksDW sample database installed on a SQL Server instance. To learn more, see Tabular Modeling
(Adventure Works Tutorial).
Click the Solution Explorer tab. Here, you'll see your Model.bim file. If you don't see the designer window to the
left (the empty window with the Model.bim tab), in Solution Explorer, under AW Internet Sales Project,
double-click the Model.bim file. The Model.bim file contains all of the metadata for your model project.
Let's look at the model properties. Click Model.bim. In the Properties window, you'll see the model properties,
most important of which is the DirectQuery Mode property. This property specifies whether or not the model is
deployed in In-Memory mode (Off) or DirectQuery mode (On). For this tutorial, you will author and deploy your
model in In-Memory mode.
When you create a new model, certain model properties are set automatically according to the Data Modeling
settings that can be specified in the Tools > Options dialog box. Data Backup, Workspace Retention, and
Workspace Server properties specify how and where the workspace database (your model authoring database) is
backed up, retained in-memory, and built. You can change these settings later if necessary, but for now, just leave
these properties as they are.
In Solution Explorer, right-click AW Internet Sales (project), and then click Properties. The AW Internet
Sales Property Pages dialog box appears. These are the advanced project properties. You will set some of these
properties later when you are ready to deploy your model.
When you installed SSDT, several new menu items were added to the Visual Studio environment. Let's look at
those specific to authoring tabular models. Click on the Model menu. From here, you can launch the Table Import
Wizard, view and edit existing connections, refresh workspace data, browse your model in Excel with the Analyze
in Excel feature, create perspectives and roles, select the model view, and set calculation options.
Click on the Table menu. Here, you can create and manage relationships between tables, create and manage,
specify date table settings, create partitions, and edit table properties.
Click on the Column menu. Here, you can add and delete columns in a table, freeze columns, and specify sort
order. You can also use the AutoSum feature to create a standard aggregation measure for a selected column.
Other toolbar buttons provide quick access to frequently used features and commands.
Explore some of the dialogs and locations for various features specific to authoring tabular models. While some
items will not yet be active, you can get a good idea of the tabular model authoring environment.
Additional resources
To learn more about the different types of tabular model projects, see Tabular Model Projects. To learn more about
the tabular model authoring environment, see Tabular Model Designer.
What's next?
Go to the next lesson: Lesson 2: Add data.
Lesson 2: Add Data
5/7/2019 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you'll use the Table Import Wizard in SSDT to connect to the AdventureWorksDW SQL sample
database, select data, preview and filter the data, and then import the data into your model workspace.
By using the Table Import Wizard, you can import data from a variety of relational sources: Access, SQL, Oracle,
Sybase, Informix, DB2, Teradata, and more. The steps for importing data from each of these relational sources are
very similar to what is described below. Data can also be selected using a stored procedure. To learn more about
importing data and the different types of data sources you can import from, see Data Sources.
Estimated time to complete this lesson: 20 minutes
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 1: Create a New Tabular Model Project.
Create a connection
To create a connection to a the AdventureWorksDW2014 database
1. In Tabular Model Explorer, right-click Data Sources > Import from Data Source.
This launches the Table Import Wizard, which guides you through setting up a connection to a data source.
If you don't see Tabular Model Explorer, double click Model.bim in Solution Explorer to open the model
in the designer.
Note: If you're creating your model at the 1400 compatibility level, you'll see the new Get Data experience
instead of the Table Import Wizard. The dialogs will appear a little different from the steps below, but you'll
still be able to follow along.
2. In the Table Import Wizard, under Relational Databases, click Microsoft SQL Server > Next.
3. In the Connect to a Microsoft SQL Server Database page, in Friendly Connection Name, type
Adventure Works DB from SQL.
4. In Server name, type the name of the server where you installed the AdventureWorksDW database.
5. In the Database name field, select AdventureWorksDW, and then click Next.
6. In the Impersonation Information page, you need to specify the credentials Analysis Services will use to
connect to the data source when importing and processing data. Verify Specific Windows user name
and password is selected, and then in User Name and Password, enter your Windows logon credentials,
and then click Next.
NOTE
Using a Windows user account and password provides the most secure method of connecting to a data source. For
more information, see Impersonation.
7. In the Choose How to Import the Data page, verify Select from a list of tables and views to choose
the data to import is selected. You want to select from a list of tables and views, so click Next to display a
list of all the source tables in the source database.
8. In the Select Tables and Views page, select the check box for the following tables: DimCustomer,
DimDate, DimGeography, DimProduct, DimProductCategory, DimProductSubcategory, and
FactInternetSales.
DO NOT click Finish.
Since the values for these columns are not relevant to Internet sales analysis, there is no need to import
these columns. Eliminating unnecessary columns will make your model smaller and more efficient.
3. Verify that all other columns are checked, and then click OK.
Notice the words Applied filters are now displayed in the Filter Details column in the DimCustomer
row; if you click on that link you'll see a text description of the filters you just applied.
4. Filter the remaining tables by clearing the checkboxes for the following columns in each table:
DimDate
COLUMN
DateKey
SpanishDayNameOfWeek
FrenchDayNameOfWeek
SpanishMonthName
FrenchMonthName
DimGeography
COLUMN
SpanishCountryRegionName
FrenchCountryRegionName
IpAddressLocator
DimProduct
COLUMN
SpanishProductName
FrenchProductName
FrenchDescription
ChineseDescription
ArabicDescription
HebrewDescription
ThaiDescription
GermanDescription
JapaneseDescription
TurkishDescription
DimProductCategory
COLUMN
SpanishProductCategoryName
FrenchProductCategoryName
DimProductSubcategory
COLUMN
SpanishProductSubcategoryName
FrenchProductSubcategoryName
FactInternetSales
COLUMN
OrderDateKey
DueDateKey
ShipDateKey
TIP
To see the relationships that were automatically created between the imported tables, on the Data preparation row,
click Details.
2. Click Close.
The wizard closes and the model designer now shows your imported tables.
What's next?
Go to the next lesson: Lesson 3: Mark as Date Table.
Lesson 3: Mark as Date Table
5/7/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In Lesson 2: Add Data, you imported a dimension table named DimDate. While in your model this table is named
DimDate, it can also be known as a Date table, in that it contains date and time data.
Whenever you use DAX time-intelligence functions in calculations, as you'll do when you create measures a little
later, you must specify date table properties, which include a Date table and a unique identifier Date column in
that table.
In this lesson, you'll mark the DimDate table as the Date table and the Date column (in the Date table) as the Date
column (unique identifier).
Before we mark the date table and date column, we need to do a little housekeeping to make our model easier to
understand. You'll notice in the DimDate table a column named FullDateAlternateKey. It contains one row for
every day in each calendar year included in the table. We'll be using this column a lot in measure formulas and in
reports. But, FullDateAlternateKey is not really a good identifier for this column. We'll rename it to Date, making it
easier to identify and include in formulas. Whenever possible, it's a good idea to rename objects like tables and
columns to make them easier to identify in client reporting applications like Power BI and Excel.
Estimated time to complete this lesson: 3 minutes
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 2: Add data.
To rename the FullDateAlternateKey column
1. In the model designer, click the DimDate table.
2. Double click the header for the FullDateAlternateKey column, and then rename it to Date.
To set Mark as Date Table
1. Select the Date column, and then in the Properties window, under Data Type, make sure Date is selected.
2. Click the Table menu, then click Date, and then click Mark as Date Table.
3. In the Mark as Date Table dialog box, in the Date listbox, select the Date column as the unique identifier.
It will usually be selected by default. Click OK.
What's next?
Go to the next lesson: Lesson 4: Create Relationships.
Lesson 4: Create Relationships
5/7/2019 • 4 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you will verify the relationships that were created automatically when you imported data and add
new relationships between different tables. A relationship is a connection between two tables that establishes how
the data in those tables should be correlated. For example, the DimProduct table and the DimProductSubcategory
table have a relationship based on the fact that each product belongs to a subcategory. To learn more, see
Relationships.
Estimated time to complete this lesson: 10 minutes
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 3: Mark as Date Table.
Use the minimap controls in the lower-right corner of the model designer to adjust the view to include as
many of the tables as possible. You can also click, and drag tables to different locations, bringing tables
closer together, or putting them in a particular order. Moving tables does not affect the relationships already
between the tables. To view all of the columns in a particular table, click, and drag on a table edge to expand
or make it smaller.
2. Click the solid line between the DimCustomer table and the DimGeography table. The solid line between
these two tables show this relationship is active, that is, it is used by default when calculating DAX formulas.
Notice the GeographyKey column in the DimCustomer table and the GeographyKey column in the
DimGeography table now both each appear within a box. This show these are the columns used in the
relationship. The relationship's properties now also appear in the Properties window.
TIP
In addition to using the model designer in diagram view, you can also use the Manage Relationships dialog box to
show the relationships between all tables in a table format. Right-click Relationships in Tabular Model Explorer, and
then click Manage Relationships. The Manage Relationships dialog box show the relationships that were
automatically created when you imported data.
3. Use the model designer in diagram view, or the Manage Relationships dialog box, to verify the following
relationships were created when each of the tables were imported from the AdventureWorksDW database:
If any of the relationships in the table above are missing, verify that your model includes the following
tables: DimCustomer, DimDate, DimGeography, DimProduct, DimProductCategory,
DimProductSubcategory, and FactInternetSales. If tables from the same data source connection are
imported at separate times, any relationships between those tables will not be created and must be created
manually.
Take a closer look
In Diagram View, you'll notice an arrow, an asterisk, and a number on the lines that show the relationship between
tables.
The arrow shows the filter direction, the asterisk shows this table is the many side in the relationship's cardinality,
and the 1 shows this table is the one side of the relationship. If you need to edit a relationship; for example, change
the relationship's filter direction or cardinality, double-click the relationship line in Diagram View to open the Edit
Relationship dialog.
Most likely, you will never need to edit a relationship. These features are meant for advanced data modeling and
are outside the scope of this tutorial. To learn more, see Bi-directional cross filters for tabular models in SQL
Server 2016 Analysis Services.
In some cases, you may need to create additional relationships between tables in your model to support certain
business logic. For this tutorial, you need to create three additional relationships between the FactInternetSales
table and the DimDate table.
To add new relationships between tables
1. In the model designer, in the FactInternetSales table, click, and hold on the OrderDate column, then drag
the cursor to the Date column in the DimDate table, and then release.
A solid line appears showing you have created an active relationship between the OrderDate column in the
Internet Sales table and the Date column in the Date table.
NOTE
When creating relationships, the cardinality and filter direction between the primary table and the related lookup
table is automatically selected.
2. In the FactInternetSales table, click, and hold on the DueDate column, then drag the cursor to the Date
column in the DimDate table, and then release.
A dotted line appears showing you have created an inactive relationship between the DueDate column in
the FactInternetSales table and the Date column in the DimDate table. You can have multiple
relationships between tables, but only one relationship can be active at a time.
3. Finally, create one more relationship; in the FactInternetSales table, click, and hold on the ShipDate
column, then drag the cursor to the Date column in the DimDate table, and then release.
What's next?
Go to the next lesson: Lesson 5: Create Calculated Columns.
Lesson 5: Create Calculated Columns
5/7/2019 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you will create new data in your model by adding calculated columns. A calculated column is based
on data that already exists in the model. To learn more, see Calculated Columns.
You will create five new calculated columns in three different tables. The steps are slightly different for each task.
This is to show you there are several ways to create new columns, rename them, and place them in various
locations in a table.
Estimated time to complete this lesson: 15 minutes
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 4: Create Relationships.
Values are then populated for all the rows in the calculated column. If you scroll down through the table,
you will see that rows can have different values for this column, based on the data that is in each row.
5. Rename this column to MonthCalendar.
When you've finished building the formula, press ENTER. The new column is added to the far right of the
table.
3. Rename the column to DayOfWeek.
4. Click on the column heading, and then drag the column between the EnglishDayNameOfWeek column
and the DayNumberOfMonth column.
TIP
Moving columns in your table makes it easier to navigate.
The DayOfWeek calculated column provides a sortable name for the day of week.
Create a ProductSubcategoryName calculated column in the DimProduct table
1. In the DimProduct table, scroll to the far right of the table. Notice the right-most column is named Add
Column (italicized), click the column heading.
2. In the formula bar, type the following formula.
=RELATED('DimProductSubcategory'[EnglishProductSubcategoryName])
=RELATED('DimProductCategory'[EnglishProductCategoryName])
The Margin calculated column is used to analyze profit margins for each sale.
What's next?
Go to the next lesson: Lesson 6: Create Measures.
Lesson 6: Create Measures
5/7/2019 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you will create measures to be included in your model. Similar to the calculated columns you
created in the previous lesson, a measure is a calculation created by using a DAX formula. However, unlike
calculated columns, measures are evaluated based on a user selected filter; for example, a particular column or
slicer added to the Row Labels field in a PivotTable. A value for each cell in the filter is then calculated by the
applied measure. Measures are powerful, flexible calculations that you will want to include in almost all tabular
models to perform dynamic calculations on numerical data. To learn more, see Measures.
To create measures, you will use the Measure Grid. By default, each table has an empty measure grid; however, you
typically will not create measures for every table. The measure grid appears below a table in the model designer
when in Data View. To hide or show the measure grid for a table, click the Table menu, and then click Show
Measure Grid.
You can create a measure by clicking on an empty cell in the measure grid, and then typing a DAX formula in the
formula bar. When you click ENTER to complete the formula, the measure will then appear in the cell. You can also
create measures using a standard aggregation function by clicking on a column, and then clicking on the AutoSum
button (∑) on the toolbar. Measures created using the AutoSum feature will appear in the measure grid cell
directly beneath the column, but can be moved.
In this lesson, you will create measures by both entering a DAX formula in the formula bar and by using the
AutoSum feature.
Estimated time to complete this lesson: 30 minutes
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 5: Create Calculated Columns.
Create measures
To create a DaysCurrentQuarterToDate measure in the DimDate table
1. In the model designer, click the DimDate table.
2. In the measure grid, click the top-left empty cell.
3. In the formula bar, type the following formula:
Notice the top-left cell now contains a measure name, DaysCurrentQuarterToDate, followed by the
result, 92.
Unlike calculated columns, with measure formulas you can type the measure name, followed by a comma,
followed by the formula expression.
To create a DaysInCurrentQuarter measure in the DimDate table
1. With the DimDate table still active in the model designer, in the measure grid, click the empty cell below
the measure you just created.
2. In the formula bar, type the following formula:
When creating a comparison ratio between one incomplete period and the previous period; the formula
must take into account the proportion of the period that has elapsed, and compare it to the same
proportion in the previous period. In this case, [DaysCurrentQuarterToDate]/[DaysInCurrentQuarter] gives
the proportion elapsed in the current period.
To create an InternetDistinctCountSalesOrder measure in the FactInternetSales table
1. Click the FactInternetSales table.
2. Click on the SalesOrderNumber column heading.
3. On the toolbar, click the down-arrow next to the AutoSum (∑) button, and then select DistinctCount.
The AutoSum feature automatically creates a measure for the selected column using the DistinctCount
standard aggregation formula.
4. In the measure grid, click the new measure, and then in the Properties window, in Measure Name,
rename the measure to InternetDistinctCountSalesOrder.
To create additional measures in the FactInternetSales table
1. By using the AutoSum feature, create and name the following measures:
2. By clicking on an empty cell in the measure grid, and by using the formula bar, create and name the
following measures in order:
InternetPreviousQuarterMargin:=CALCULATE([InternetTotalMargin],PREVIOUSQUARTER('DimDate'[Date]))
InternetCurrentQuarterMargin:=TOTALQTD([InternetTotalMargin],'DimDate'[Date])
InternetPreviousQuarterMarginProportionToQTD:=[InternetPreviousQuarterMargin]*
([DaysCurrentQuarterToDate]/[DaysInCurrentQuarter])
InternetPreviousQuarterSales:=CALCULATE([InternetTotalSales],PREVIOUSQUARTER('DimDate'[Date]))
InternetCurrentQuarterSales:=TOTALQTD([InternetTotalSales],'DimDate'[Date])
InternetPreviousQuarterSalesProportionToQTD:=[InternetPreviousQuarterSales]*
([DaysCurrentQuarterToDate]/[DaysInCurrentQuarter])
Measures created for the FactInternetSales table can be used to analyze critical financial data such as sales, costs,
and profit margin for items defined by the user selected filter.
What's next?
Go to the next lesson: Lesson 7: Create Key Performance Indicators.
Lesson 7: Create Key Performance Indicators
5/7/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you will create Key Performance Indicators (KPIs). KPIs are used to gauge performance of a value,
defined by a Base measure, against a Target value, also defined by a measure or by an absolute value. In reporting
client applications, KPIs can provide business professionals a quick and easy way to understand a summary of
business success or to identify trends. To learn more, see KPIs.
Estimated time to complete this lesson: 15 minutes
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 6: Create Measures.
InternetCurrentQuarterSalesPerformance
:=IFERROR([InternetCurrentQuarterSales]/[InternetPreviousQuarterSalesProportionToQTD],BLANK())
This measure will serve as the Base measure for the KPI.
4. Right-click InternetCurrentQuarterSalesPerformance > Create KPI.
5. In the Key Performance Indicator (KPI) dialog box, in Target select Absolute Value, and then type 1.1.
6. In the left (low) slider field, type 1, and then in the right (high) slider field, type 1.07.
7. In Select Icon Style, select the diamond (red), triangle (yellow), circle (green) icon type.
TIP
Notice the expandable Descriptions label below the available icon styles. Use this to enter descriptions for the
various KPI elements to make them more identifiable in client applications.
InternetCurrentQuarterMarginPerformance :=IF([InternetPreviousQuarterMarginProportionToQTD]<>0,
([InternetCurrentQuarterMargin]-
[InternetPreviousQuarterMarginProportionToQTD])/[InternetPreviousQuarterMarginProportionToQTD],BLANK())
What's next?
Go to the next lesson: Lesson 8: Create Perspectives.
Lesson 8: Create Perspectives
5/7/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you will create an Internet Sales perspective. A perspective defines a viewable subset of a model that
provides focused, business-specific, or application-specific viewpoints. When a user connects to a model by using
a perspective, they see only those model objects (tables, columns, measures, hierarchies, and KPIs) as fields
defined in that perspective.
The Internet Sales perspective you create in this lesson will exclude the DimCustomer table object. When you
create a perspective that excludes certain objects from view, that object still exists in the model; however, it is not
visible in a reporting client field list. Calculated columns and measures either included in a perspective or not can
still calculate from object data that is excluded.
The purpose of this lesson is to describe how to create perspectives and become familiar with the tabular model
authoring tools. If you later expand this model to include additional tables, you can create additional perspectives
to define different viewpoints of the model, for example, Inventory and Sales. To learn more, see Perspectives.
Estimated time to complete this lesson: 5 minutes
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 7: Create Key Performance Indicators.
Create perspectives
To create an Internet Sales perspective
1. Click the Model menu > Perspectives > Create and Manage.
2. In the Perspectives dialog box, click New Perspective.
3. Double-click the New Perspective column heading, and then rename Internet Sales.
4. Select the all of the tables except DimCustomer.
In a later lesson, you will use the Analyze in Excel feature to test this perspective. The Excel PivotTable Fields
List will include each table except the DimCustomer table.
What's next?
Go to the next lesson: Lesson 9: Create Hierarchies.
Lesson 9: Create Hierarchies
5/7/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you will create hierarchies. Hierarchies are groups of columns arranged in levels; for example, a
Geography hierarchy might have sub-levels for Country, State, County, and City. Hierarchies can appear separate
from other columns in a reporting client application field list, making them easier for client users to navigate and
include in a report. To learn more, see Hierarchies.
To create hierarchies, you'll use the model designer in Diagram View. Creating and managing hierarchies is not
supported in Data View.
Estimated time to complete this lesson: 20 minutes
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 8: Create Perspectives.
Create hierarchies
To create a Category hierarchy in the DimProduct table
1. In the model designer (diagram view), right-click the DimProduct table > Create Hierarchy. A new
hierarchy appears at the bottom of the table window. Rename the hierarchy Category.
2. Click and drag the ProductCategoryName column to the new Category hierarchy.
3. In the Category hierarchy, right-click the ProductCategoryName > Rename, and then type Category.
NOTE
Renaming a column in a hierarchy does not rename that column in the table. A column in a hierarchy is just a
representation of the column in the table.
4. Click and drag the ProductSubcategoryName column to the Category hierarchy. Rename it
Subcategory.
5. Right-click the ModelName column > Add to hierarchy, and then select Category. Do the same for
EnglishProductName. Rename these columns in the hierarchy Model and Product.
To create hierarchies in the DimDate table
1. In the DimDate table, create a new hierarchy named Calendar.
2. Add the following columns in-order:
CalendarYear
CalendarSemester
CalendarQuarter
MonthCalendar
DayNumberOfMonth
3. In the DimDate table, create a Fiscal hierarchy. Include the following columns:
FiscalYear
FiscalSemester
FiscalQuarter
MonthCalendar
DayNumberOfMonth
4. Finally, in the DimDate table, create a ProductionCalendar hierarchy. Include the following columns:
CalendarYear
WeekNumberOfYear
DayNumberOfWeek
What's next?
Go to the next lesson: Lesson 10: Create Partitions.
Lesson 10: Create Partitions
5/7/2019 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you will create partitions to divide the FactInternetSales table into smaller logical parts that can be
processed (refreshed) independent of other partitions. By default, every table you include in your model has one
partition which includes all of the table's columns and rows. For the FactInternetSales table, we want to divide the
data by year; one partition for each of the table's five years. Each partition can then be processed independently. To
learn more, see Partitions.
Estimated time to complete this lesson: 15 minutes
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 9: Create Hierarchies.
Create partitions
To create partitions in the FactInternetSales table
1. In Tabular Model Explorer, expand Tables, right-click FactInternetSales > Partitions.
2. In the Partition Manager dialog box, click Copy.
3. In Partition Name, change the name to FactInternetSales2010.
TIP
Notice the column names in the Table Preview window display those columns included in the model table (checked)
with the column names from the source. This is because the Table Preview window displays columns from the source
table, not from the model table.
4. Select the SQL button just above the right side of the preview window to open the SQL Statement editor.
Because you want the partition to include only those rows within a certain period, you must include a
WHERE clause. You can only create a WHERE clause by using a SQL Statement.
5. In the SQL Statement field, replace the existing statement by copying and pasting the following statement:
SELECT
[dbo].[FactInternetSales].[ProductKey],
[dbo].[FactInternetSales].[CustomerKey],
[dbo].[FactInternetSales].[PromotionKey],
[dbo].[FactInternetSales].[CurrencyKey],
[dbo].[FactInternetSales].[SalesTerritoryKey],
[dbo].[FactInternetSales].[SalesOrderNumber],
[dbo].[FactInternetSales].[SalesOrderLineNumber],
[dbo].[FactInternetSales].[RevisionNumber],
[dbo].[FactInternetSales].[OrderQuantity],
[dbo].[FactInternetSales].[UnitPrice],
[dbo].[FactInternetSales].[ExtendedAmount],
[dbo].[FactInternetSales].[UnitPriceDiscountPct],
[dbo].[FactInternetSales].[DiscountAmount],
[dbo].[FactInternetSales].[ProductStandardCost],
[dbo].[FactInternetSales].[TotalProductCost],
[dbo].[FactInternetSales].[SalesAmount],
[dbo].[FactInternetSales].[TaxAmt],
[dbo].[FactInternetSales].[Freight],
[dbo].[FactInternetSales].[CarrierTrackingNumber],
[dbo].[FactInternetSales].[CustomerPONumber],
[dbo].[FactInternetSales].[OrderDate],
[dbo].[FactInternetSales].[DueDate],
[dbo].[FactInternetSales].[ShipDate]
FROM [dbo].[FactInternetSales]
WHERE (([OrderDate] >= N'2010-01-01 00:00:00') AND ([OrderDate] < N'2011-01-01 00:00:00'))
This statement specifies the partition should include all of the data in those rows where the OrderDate is
for the 2010 calendar year as specified in the WHERE clause.
6. Click Validate.
To create a partition for the 2011 year
1. In the partitions list, click the FactInternetSales2010 partition you just created, and then click Copy.
2. In Partition Name, type FactInternetSales2011.
3. In the SQL Statement, in-order for the partition to include only those rows for the 2011 year, replace the
WHERE clause with the following:
WHERE (([OrderDate] >= N'2011-01-01 00:00:00') AND ([OrderDate] < N'2012-01-01 00:00:00'))
WHERE (([OrderDate] >= N'2012-01-01 00:00:00') AND ([OrderDate] < N'2013-01-01 00:00:00'))
WHERE (([OrderDate] >= N'2013-01-01 00:00:00') AND ([OrderDate] < N'2014-01-01 00:00:00'))
WHERE (([OrderDate] >= N'2014-01-01 00:00:00') AND ([OrderDate] < N'2015-01-01 00:00:00'))
Delete the FactInternetSales partition
Now that you have partitions for each year, you can delete the FactInternetSales partition. This prevents overlap
when choosing Process all when processing partitions.
To delete the FactInternetSales partition
Click the FactInternetSales partition, and then click Delete.
Process partitions
In Partition Manager, notice the Last Processed column for each of the new partitions you just created shows
these partitions have never been processed. When you create new partitions, you should run a Process Partitions
or Process Table operation to refresh the data in those partitions.
To process the FactInternetSales partitions
1. Click OK to close the Partition Manager dialog box.
2. Click the FactInternetSales table, then click the Model menu > Process > Process Partitions.
3. In the Process Partitions dialog box, verify Mode is set to Process Default.
4. Select the checkbox in the Process column for each of the five partitions you created, and then click OK.
If you're prompted for Impersonation credentials, enter the Windows user name and password you
specified in Lesson 2.
The Data Processing dialog box appears and displays process details for each partition. Notice that a
different number of rows for each partition are transferred. This is because each partition includes only
those rows for the year specified in the WHERE clause in the SQL Statement. When processing is finished,
go ahead and close the Data Processing dialog box.
What's next?
Go to the next lesson: Lesson 11: Create Roles.
Lesson 11: Create Roles
5/7/2019 • 3 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you will create roles. Roles provide model database object and data security by limiting access to
only those Windows users which are role members. Each role is defined with a single permission: None, Read,
Read and Process, Process, or Administrator. Roles can be defined during model authoring by using Role
Manager. After a model has been deployed, you can manage roles by using SQL Server Management Studio. To
learn more, see Roles.
NOTE
Creating roles is not necessary to complete this tutorial. By default, the account you are currently logged in with will have
Administrator privileges on the model. However, to allow other users in your organization to browse the model by using a
reporting client, you must create at least one role with Read permissions and add those users as members.
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 10: Create Partitions.
Create roles
To create a Sales Manager user role
1. In Tabular Model Explorer, right-click Roles > Roles.
2. In Role Manager, click New.
3. Click on the new role, and then in the Name column, rename the role to Sales Manager.
4. In the Permissions column, click the dropdown list, and then select the Read permission.
5. Optional: Click the Members tab, and then click Add. In the Select Users or Groups dialog box, enter the
Windows users or groups from your organization you want to include in the role.
To create a Sales Analyst US user role
1. In Role Manager, click New.
2. Rename the role to Sales Analyst US.
3. Give this role Read permission.
4. Click on the Row Filters tab, and then for the DimGeography table only, in the DAX Filter column, type the
following formula:
=DimGeography[CountryRegionCode] = "US"
A Row Filter formula must resolve to a Boolean (TRUE/FALSE ) value. With this formula, you are specifying
that only rows with the Country Region Code value of "US" be visible to the user.
5. Optional: Click on the Members tab, and then click Add. In the Select Users or Groups dialog box, enter
the Windows users or groups from your organization you want to include in the role.
To create an Administrator user role
1. Click New.
2. Rename the role to Administrator.
3. Give this role Administrator permission.
4. Optional: Click on the Members tab, and then click Add. In the Select Users or Groups dialog box, enter
the Windows users or groups from your organization you want to include in the role.
What's next?
Go to the next lesson: Lesson 12: Analyze in Excel.
Lesson 12: Analyze in Excel
5/7/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you will use the Analyze in Excel feature in SSDT to open Microsoft Excel, automatically create a
data source connection to the model workspace, and automatically add a PivotTable to the worksheet. The Analyze
in Excel feature is meant to provide a quick and easy way to test the efficacy of your model design prior to
deploying your model. You will not perform any data analysis in this lesson. The purpose of this lesson is to
familiarize you, the model author, with the tools you can use to test your model design. Unlike using the Analyze in
Excel feature, which is meant for model authors, end-users will use client reporting applications like Excel or Power
BI to connect to and browse deployed model data.
In order to complete this lesson, Excel must be installed on the same computer as SSDT. To learn more, see
Analyze in Excel.
Estimated time to complete this lesson: 20 minutes
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 11: Create Roles.
What's next?
Go to the next lesson: Lesson 13: Deploy.
Lesson 13: Deploy
5/7/2019 • 2 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this lesson, you will configure deployment properties; specifying an on-premises or Azure server instance, and a
name for the model. You'll then deploy the model to that instance. After your model is deployed, users can connect
to it by using a reporting client application. To learn more about deploying, see Tabular model solution deployment
and Deploy to Azure Analysis Services.
Estimated time to complete this lesson: 5 minutes
Prerequisites
This topic is part of a tabular modeling tutorial, which should be completed in order. Before performing the tasks
in this lesson, you should have completed the previous lesson: Lesson 12: Analyze in Excel.
IMPORTANT
You must have Administrator permissions on the remote Analysis Services instance in-order to deploy to it.
Conclusion
Congratulations! You're finished authoring and deploying your first Analysis Services Tabular model. This tutorial
has helped guide you through completing the most common tasks in creating a tabular model. Now that your
Adventure Works Internet Sales model is deployed, you can use SQL Server Management Studio to manage the
model; create process scripts and a backup plan. Users can also now connect to the model using a reporting client
application such as Microsoft Excel or Power BI.
See also
DirectQuery Mode
Configure default data modeling and deployment properties
Tabular Model Databases
What's next?
Supplemental Lesson - Implement Dynamic Security by Using Row Filters.
Supplemental Lesson - Configure Reporting Properties for Power View Reports.
Supplemental Lesson - Implement Dynamic Security
by Using Row Filters
5/7/2019 • 10 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this supplemental lesson, you will create an additional role that implements dynamic security. Dynamic security
provides row-level security based on the user name or login id of the user currently logged on. To learn more, see
Roles.
To implement dynamic security, you must add a table to your model containing the Windows user names of those
users that can create a connection to the model as a data source and browse model objects and data. The model
you create using this tutorial is in the context of Adventure Works Corp.; however, in order to complete this lesson,
you must add a table containing users from your own domain. You will not need the passwords for the user names
that will be added. To create an EmployeeSecurity table, with a small sample of users from your own domain, you
will use the Paste feature, pasting employee data from an Excel spreadsheet. In a real-world scenario, the table
containing user names you add to a model would typically use a table from an actual database as a data source; for
example, a real DimEmployee table.
In order to implement dynamic security, you will use two new DAX functions: USERNAME Function (DAX) and
LOOKUPVALUE Function (DAX). These functions, applied in a row filter formula, are defined in a new role. Using
the LOOKUPVALUE function, the formula specifies a value from the EmployeeSecurity table and then passes that
value to the USERNAME function, which specifies the user name of the user logged on belongs to this role. The
user can then browse only data specified by the role's row filters. In this scenario, you will specify that sales
employees can only browse Internet sales data for the sales territories in which they are a member.
In order to complete this supplemental lesson, you will complete a series of tasks. Those tasks that are unique to
this Adventure Works tabular model scenario, but would not necessarily apply to a real-world scenario are
identified as such. Each task includes additional information describing the purpose of the task.
Estimated time to complete this lesson: 30 minutes
Prerequisites
This supplemental lesson topic is part of a tabular modeling tutorial, which should be completed in order. Before
performing the tasks in this supplemental lesson, you should have completed all previous lessons.
|EmployeeId|SalesTerritoryId|FirstName|LastName|LoginId|
|---------------|----------------------|--------------|-------------|------------|
|1|2|<user first name>|<user last name>|\<domain\username>|
|1|3|<user first name>|<user last name>|\<domain\username>|
|2|4|<user first name>|<user last name>|\<domain\username>|
|3|5|<user first name>|<user last name>|\<domain\username>|
3. Replace the first name, last name, and domain\username with the names and login ids of three users in
your organization. Put the same user on the first two rows, for EmployeeId 1. This will show this user
belongs to more than one sales territory. Leave the EmployeeId and SalesTerritoryId fields as they are.
4. Save the worksheet as SampleEmployee.
5. In the worksheet, select all of the cells with employee data, including the headers, then right-click the
selected data, and then click Copy.
6. In SSDT, click the Edit menu, and then click Paste.
If Paste is grayed out, click any column in any table in the model designer window, and try again.
7. In the Paste Preview dialog box, in Table Name, type EmployeeSecurity.
8. In Data to be pasted, verify the data includes all of the user data and headers from the SampleEmployee
worksheet.
9. Verify Use first row as column headers is checked, and then click Ok.
A new table named EmployeeSecurity with employee data copied from the SampleEmployee worksheet is
created.
Create relationships between FactInternetSales, DimGeography, and
DimSalesTerritory table
The FactInternetSales, DimGeography, and DimSalesTerritory table all contain a common column,
SalesTerritoryId. The SalesTerritoryId column in the DimSalesTerritory table contains values with a different Id for
each sales territory.
To create relationships between the FactInternetSales, DimGeography, and the DimSalesTerritory table
1. In the model designer, in Diagram View, in the DimGeography table, click and hold on the
SalesTerritoryId column, then drag the cursor to the SalesTerritoryId column in the DimSalesTerritory
table, and then release.
2. In the FactInternetSales table, click and hold on the SalesTerritoryId column, then drag the cursor to the
SalesTerritoryId column in the DimSalesTerritory table, and then release.
Notice the Active property for this relationship is False, meaning it's inactive. This is because the
FactInternetSales table already has another active relationship that is used in measures.
NOTE
The Sales Employees by Territory role you create in this lesson restricts members to browse (or query) only sales data for the
sales territory to which they belong. If you add a user as a member to the Sales Employees by Territory role that also exists
as a member in a role created in Lesson 11: Create Roles, you will get a combination of permissions. When a user is a
member of multiple roles, the permissions, and row filters defined for each role are cumulative. That is, the user will have the
greater permissions determined by the combination of roles.
=FALSE()
This formula specifies that all columns resolve to the false Boolean condition; therefore, no columns for the
EmployeeSecurity table can be queried by a member of the Sales Employees by Territory user role.
9. For the DimSalesTerritory table, type the following formula.
In this formula, the LOOKUPVALUE function returns all values for the
DimEmployeeSecurity[SalesTerritoryId] column, where the EmployeeSecurity[LoginId] is the same as the
current logged on Windows user name, and EmployeeSecurity[SalesTerritoryId] is the same as the
DimSalesTerritory[SalesTerritoryId].
The set of sales territory IDs returned by LOOKUPVALUE is then used to restrict the rows shown in the
DimSalesTerritory table. Only rows where the SalesTerritoryID for the row is in the set of IDs returned by
the LOOKUPVALUE function are displayed.
10. In Role Manager, click Ok.
See Also
USERNAME Function (DAX)
LOOKUPVALUE Function (DAX)
CUSTOMDATA Function (DAX)
Supplemental Lesson - Configure Reporting
Properties for Power View Reports
5/7/2019 • 9 minutes to read • Edit Online
APPLIES TO: SQL Server 2016 Analysis Services and later Azure Analysis Services Power BI
Premium
In this supplemental lesson, you will set reporting properties for the AW Internet Sales project. Reporting
properties make it easier for users to select and display model data in Power View. You will also set properties to
hide certain columns and tables, and create new data for use in charts.
Estimated time to complete this lesson: 30 minutes
Prerequisites
This supplemental lesson is part of a tabular modeling tutorial, which should be completed in order. Before
performing the tasks in this supplemental lesson, you should have completed all previous lessons.
In order to complete this particular supplemental lesson, you must also have the following:
The AW Internet Sales project (completed through this tutorial) ready to be deployed or already deployed to an
Analysis Services server.
Year Quarter =[Calendar Year] & " Q" & [Calendar Quarter]
Table behavior
By using Table Behavior properties, you can change the default behavior for different visualization types and
grouping behavior for tables used in Power View reports. This allows better default placement of identifying
information such as names, images, or titles in tile, card, and chart layouts.
For detailed information about Table Behavior properties, see Configure Table Behavior Properties for Power View
Reports.
To set table behavior
1. In the model designer, click the Customer table (tab).
2. In the Properties window, in the Table Behavior property, click Click to edit, to open the Table Behavior
dialog box.
3. In the Table Behavior dialog box, in the Row IDentifier dropdown list box, select the Customer ID
column.
4. In the Keep Unique Rows list box, select First Name and Last Name.
This property setting specifies these columns provide values that should be treated as unique even if they
are duplicates, for example, when two or more employees share the same name.
5. In the Default Label dropdown list box, select the Last Name column.
This property setting specifies this column provides a display name to represent row data.
6. Repeat these steps for the Geography table, selecting the Geography ID column as the Row IDentifier,
and the City column in the Keep Unique Rows list box. You do not need to set a Default Label for this
table.
7. Repeat these steps, for the Product table, selecting the Product ID column as the Row IDentifier, and the
Product Name column in the Keep Unique Rows list box. For Default Label, select Product Alternate
ID.
Date
NOTE
Because the Date table was selected as the models date table by using the Mark as Date Table setting, in Lesson 7:
Mark as Date Table, and the Date column in the Date table as the column to be used as the unique identifier, the
Row IDentifier property for the Date column will automatically be set to True, and cannot be changed. When using
time-intelligence functions in DAX formulas, you must specify a date table. In this model, you created a number of
measures using time-intelligence functions to calculate sales data for various periods such as previous and current
quarters, and also for use in KPIs. For more information about specifying a date table, see Specify Mark as Date Table
for use with Time Intelligence.
Geography
Product
Internet Sales
Decimal Places 0
COLUMN PROPERT Y VALUE
Next steps
You can now use Excel to visualize data from the model. Ensure the Analysis Services and Reporting Services
accounts on the SharePoint site have read permissions to the Analysis Services instance where you deployed your
model.