20768C-Developing SQL Data Models
20768C-Developing SQL Data Models
20768C
Developing SQL Data Models
MCT USE ONLY. STUDENT USE PROHIBITED
ii Developing SQL Data Models
Information in this document, including URL and other Internet Web site references, is subject to change
without notice. Unless otherwise noted, the example companies, organizations, products, domain names,
e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with
any real company, organization, product, domain name, e-mail address, logo, person, place or event is
intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the
user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in
or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical,
photocopying, recording, or otherwise), or for any purpose, without the express written permission of
Microsoft Corporation.
Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property
rights covering subject matter in this document. Except as expressly provided in any written license
agreement from Microsoft, the furnishing of this document does not give you any license to these
patents, trademarks, copyrights, or other intellectual property.
The names of manufacturers, products, or URLs are provided for informational purposes only and
Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding
these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a
manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links
may be provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not
responsible for the contents of any linked site or any link contained in a linked site, or any changes or
updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission
received from any linked site. Microsoft is providing these links to you only as a convenience, and the
inclusion of any link does not imply endorsement of Microsoft of the site or the products contained
therein.
© 2018 Microsoft Corporation. All rights reserved.
Released: 02/2018
MCT USE ONLY. STUDENT USE PROHIBITED
MICROSOFT LICENSE TERMS
MICROSOFT INSTRUCTOR-LED COURSEWARE
These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its
affiliates) and you. Please read them. They apply to your use of the content accompanying this agreement which
includes the media on which you received it, if any. These license terms also apply to Trainer Content and any
updates and supplements for the Licensed Content unless other terms accompany those items. If so, those terms
apply.
BY ACCESSING, DOWNLOADING OR USING THE LICENSED CONTENT, YOU ACCEPT THESE TERMS.
IF YOU DO NOT ACCEPT THEM, DO NOT ACCESS, DOWNLOAD OR USE THE LICENSED CONTENT.
If you comply with these license terms, you have the rights below for each license you acquire.
1. DEFINITIONS.
a. “Authorized Learning Center” means a Microsoft IT Academy Program Member, Microsoft Learning
Competency Member, or such other entity as Microsoft may designate from time to time.
b. “Authorized Training Session” means the instructor-led training class using Microsoft Instructor-Led
Courseware conducted by a Trainer at or through an Authorized Learning Center.
c. “Classroom Device” means one (1) dedicated, secure computer that an Authorized Learning Center owns
or controls that is located at an Authorized Learning Center’s training facilities that meets or exceeds the
hardware level specified for the particular Microsoft Instructor-Led Courseware.
d. “End User” means an individual who is (i) duly enrolled in and attending an Authorized Training Session
or Private Training Session, (ii) an employee of a MPN Member, or (iii) a Microsoft full-time employee.
e. “Licensed Content” means the content accompanying this agreement which may include the Microsoft
Instructor-Led Courseware or Trainer Content.
f. “Microsoft Certified Trainer” or “MCT” means an individual who is (i) engaged to teach a training session
to End Users on behalf of an Authorized Learning Center or MPN Member, and (ii) currently certified as a
Microsoft Certified Trainer under the Microsoft Certification Program.
g. “Microsoft Instructor-Led Courseware” means the Microsoft-branded instructor-led training course that
educates IT professionals and developers on Microsoft technologies. A Microsoft Instructor-Led
Courseware title may be branded as MOC, Microsoft Dynamics or Microsoft Business Group courseware.
h. “Microsoft IT Academy Program Member” means an active member of the Microsoft IT Academy
Program.
i. “Microsoft Learning Competency Member” means an active member of the Microsoft Partner Network
program in good standing that currently holds the Learning Competency status.
j. “MOC” means the “Official Microsoft Learning Product” instructor-led courseware known as Microsoft
Official Course that educates IT professionals and developers on Microsoft technologies.
k. “MPN Member” means an active Microsoft Partner Network program member in good standing.
MCT USE ONLY. STUDENT USE PROHIBITED
l. “Personal Device” means one (1) personal computer, device, workstation or other digital electronic device
that you personally own or control that meets or exceeds the hardware level specified for the particular
Microsoft Instructor-Led Courseware.
m. “Private Training Session” means the instructor-led training classes provided by MPN Members for
corporate customers to teach a predefined learning objective using Microsoft Instructor-Led Courseware.
These classes are not advertised or promoted to the general public and class attendance is restricted to
individuals employed by or contracted by the corporate customer.
n. “Trainer” means (i) an academically accredited educator engaged by a Microsoft IT Academy Program
Member to teach an Authorized Training Session, and/or (ii) a MCT.
o. “Trainer Content” means the trainer version of the Microsoft Instructor-Led Courseware and additional
supplemental content designated solely for Trainers’ use to teach a training session using the Microsoft
Instructor-Led Courseware. Trainer Content may include Microsoft PowerPoint presentations, trainer
preparation guide, train the trainer materials, Microsoft One Note packs, classroom setup guide and Pre-
release course feedback form. To clarify, Trainer Content does not include any software, virtual hard
disks or virtual machines.
2. USE RIGHTS. The Licensed Content is licensed not sold. The Licensed Content is licensed on a one copy
per user basis, such that you must acquire a license for each individual that accesses or uses the Licensed
Content.
2.1 Below are five separate sets of use rights. Only one set of rights apply to you.
2.2 Separation of Components. The Licensed Content is licensed as a single unit and you may not
separate their components and install them on different devices.
2.3 Redistribution of Licensed Content. Except as expressly provided in the use rights above, you may
not distribute any Licensed Content or any portion thereof (including any permitted modifications) to any
third parties without the express written permission of Microsoft.
2.4 Third Party Notices. The Licensed Content may include third party code tent that Microsoft, not the
third party, licenses to you under this agreement. Notices, if any, for the third party code ntent are included
for your information only.
2.5 Additional Terms. Some Licensed Content may contain components with additional terms,
conditions, and licenses regarding its use. Any non-conflicting terms in those conditions and licenses also
apply to your use of that respective component and supplements the terms described in this agreement.
a. Pre-Release Licensed Content. This Licensed Content subject matter is on the Pre-release version of
the Microsoft technology. The technology may not work the way a final version of the technology will
and we may change the technology for the final version. We also may not release a final version.
Licensed Content based on the final version of the technology may not contain the same information as
the Licensed Content based on the Pre-release version. Microsoft is under no obligation to provide you
with any further content, including any Licensed Content based on the final version of the technology.
b. Feedback. If you agree to give feedback about the Licensed Content to Microsoft, either directly or
through its third party designee, you give to Microsoft without charge, the right to use, share and
commercialize your feedback in any way and for any purpose. You also give to third parties, without
charge, any patent rights needed for their products, technologies and services to use or interface with
any specific parts of a Microsoft technology, Microsoft product, or service that includes the feedback.
You will not give feedback that is subject to a license that requires Microsoft to license its technology,
technologies, or products to third parties because we include your feedback in them. These rights
survive this agreement.
c. Pre-release Term. If you are an Microsoft IT Academy Program Member, Microsoft Learning
Competency Member, MPN Member or Trainer, you will cease using all copies of the Licensed Content on
the Pre-release technology upon (i) the date which Microsoft informs you is the end date for using the
Licensed Content on the Pre-release technology, or (ii) sixty (60) days after the commercial release of the
technology that is the subject of the Licensed Content, whichever is earliest (“Pre-release term”).
Upon expiration or termination of the Pre-release term, you will irretrievably delete and destroy all copies
of the Licensed Content in your possession or under your control.
MCT USE ONLY. STUDENT USE PROHIBITED
4. SCOPE OF LICENSE. The Licensed Content is licensed, not sold. This agreement only gives you some
rights to use the Licensed Content. Microsoft reserves all other rights. Unless applicable law gives you more
rights despite this limitation, you may use the Licensed Content only as expressly permitted in this
agreement. In doing so, you must comply with any technical limitations in the Licensed Content that only
allows you to use it in certain ways. Except as expressly permitted in this agreement, you may not:
• access or allow any individual to access the Licensed Content if they have not acquired a valid license
for the Licensed Content,
• alter, remove or obscure any copyright or other protective notices (including watermarks), branding
or identifications contained in the Licensed Content,
• modify or create a derivative work of any Licensed Content,
• publicly display, or make the Licensed Content available for others to access or use,
• copy, print, install, sell, publish, transmit, lend, adapt, reuse, link to or post, make available or
distribute the Licensed Content to any third party,
• work around any technical limitations in the Licensed Content, or
• reverse engineer, decompile, remove or otherwise thwart any protections or disassemble the
Licensed Content except and only to the extent that applicable law expressly permits, despite this
limitation.
5. RESERVATION OF RIGHTS AND OWNERSHIP. Microsoft reserves all rights not expressly granted to
you in this agreement. The Licensed Content is protected by copyright and other intellectual property laws
and treaties. Microsoft or its suppliers own the title, copyright, and other intellectual property rights in the
Licensed Content.
6. EXPORT RESTRICTIONS. The Licensed Content is subject to United States export laws and regulations.
You must comply with all domestic and international export laws and regulations that apply to the Licensed
Content. These laws include restrictions on destinations, end users and end use. For additional information,
see www.microsoft.com/exporting.
7. SUPPORT SERVICES. Because the Licensed Content is “as is”, we may not provide support services for it.
8. TERMINATION. Without prejudice to any other rights, Microsoft may terminate this agreement if you fail
to comply with the terms and conditions of this agreement. Upon termination of this agreement for any
reason, you will immediately stop all use of and delete and destroy all copies of the Licensed Content in
your possession or under your control.
9. LINKS TO THIRD PARTY SITES. You may link to third party sites through the use of the Licensed
Content. The third party sites are not under the control of Microsoft, and Microsoft is not responsible for
the contents of any third party sites, any links contained in third party sites, or any changes or updates to
third party sites. Microsoft is not responsible for webcasting or any other form of transmission received
from any third party sites. Microsoft is providing these links to third party sites to you only as a
convenience, and the inclusion of any link does not imply an endorsement by Microsoft of the third party
site.
10. ENTIRE AGREEMENT. This agreement, and any additional terms for the Trainer Content, updates and
supplements are the entire agreement for the Licensed Content, updates and supplements.
12. LEGAL EFFECT. This agreement describes certain legal rights. You may have other rights under the laws
of your country. You may also have rights with respect to the party from whom you acquired the Licensed
Content. This agreement does not change your rights under the laws of your country if the laws of your
country do not permit it to do so.
13. DISCLAIMER OF WARRANTY. THE LICENSED CONTENT IS LICENSED "AS-IS" AND "AS
AVAILABLE." YOU BEAR THE RISK OF USING IT. MICROSOFT AND ITS RESPECTIVE
AFFILIATES GIVES NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS. YOU MAY
HAVE ADDITIONAL CONSUMER RIGHTS UNDER YOUR LOCAL LAWS WHICH THIS AGREEMENT
CANNOT CHANGE. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT AND
ITS RESPECTIVE AFFILIATES EXCLUDES ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
14. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM
MICROSOFT, ITS RESPECTIVE AFFILIATES AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP
TO US$5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL,
LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.
It also applies even if Microsoft knew or should have known about the possibility of the damages. The
above limitation or exclusion may not apply to you because your country may not allow the exclusion or
limitation of incidental, consequential or other damages.
Please note: As this Licensed Content is distributed in Quebec, Canada, some of the clauses in this
agreement are provided below in French.
Remarque : Ce le contenu sous licence étant distribué au Québec, Canada, certaines des clauses
dans ce contrat sont fournies ci-dessous en français.
EXONÉRATION DE GARANTIE. Le contenu sous licence visé par une licence est offert « tel quel ». Toute
utilisation de ce contenu sous licence est à votre seule risque et péril. Microsoft n’accorde aucune autre garantie
expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection dues
consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties
implicites de qualité marchande, d’adéquation à un usage particulier et d’absence de contrefaçon sont exclues.
EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir d’autres droits
prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre
pays si celles-ci ne le permettent pas.
Acknowledgements
Microsoft Learning would like to acknowledge and thank the following for their contribution towards
developing this title. Their effort at various stages in the development has ensured that you have a good
classroom experience.
Contents
Module 1: Introduction to Business Intelligence and Data Modeling
Module Overview 1-1
Lesson 1: Overview of Business Intelligence and Data Models 1-2
Module 7: Implementing a Tabular Data Model by Using SQL Server Analysis Services
Module Overview 7-1
Lesson 1: Introduction to Tabular Data Models in SQL Server Analysis Services 7-2
Lab: Implementing a Tabular Data Model in SQL Server Analysis Services 7-26
Course Description
The focus of this 3-day instructor-led course is on creating managed enterprise BI solutions. It describes
how to implement both multidimensional and tabular data models and how to create cubes, dimensions,
measures, and measure groups.
Audience
The primary audience for this course are database professionals who need to fulfil BI Developer role to
create enterprise BI solutions. Primary responsibilities will include:
Creating tabular semantic data models for analysis by using SQL Server Analysis Services
The secondary audiences for this course are ‘power’ information workers.
Student Prerequisites
In addition to their professional experience, students who attend this training should already have the
following technical knowledge:
o Some basic knowledge of data warehouse schema topology (including star and snowflake
schemas)
o Some exposure to basic programming constructs (such as looping and branching)
o An awareness of key business priorities such as revenue, profitability, and financial accounting is
desirable
Course Objectives
After completing this course, students will be able to:
Describe the components, architecture, and nature of a BI solution.
Customize a cube.
Course Outline
The course outline is as follows:
Module 1: ‘Introduction to Business Intelligence and data modelling’ introduces key BI concepts and
the Microsoft BI product suite
Module 3: ‘Working with cubes and dimensions’ describes how to implement dimensions in a cube.
Module 4: ‘Working with measures and measure groups’ describes how to implement measures and
measure groups in a cube.
Module 5: ‘Introduction to MDX’ describes the MDX syntax and how to use MDX.
Module 7: ‘Implementing a tabular data model by using analysis services’ describes how to
implement a tabular data model in PowerPivot.
Module 8: ‘Introduction to Data Analysis Expression (DAX)’ describes how to use DAX to create
measures and calculated columns in a tabular data model.
Module 9: ‘Performing predictive analysis with data mining’ describes how to use data mining for
predictive analysis.
Course Materials
The following materials are included with your kit:
Course Handbook: a succinct classroom learning guide that provides the critical technical
information in a crisp, tightly-focused format, which is essential for an effective in-class learning
experience.
o Lessons: guide you through the learning objectives and provide the key points that are critical to
the success of the in-class learning experience.
o Labs: provide a real-world, hands-on platform for you to apply the knowledge and skills learned
in the module.
o Module Reviews and Takeaways: provide on-the-job reference material to boost knowledge
and skills retention.
Modules: include companion content, such as questions and answers, detailed demo steps and
additional reading links, for each lesson. Additionally, they include Lab Review questions and answers
and Module Reviews and Takeaways sections, which contain the review questions and answers, best
practices, common issues and troubleshooting tips with answers, and real-world issues and scenarios
with answers.
MCT USE ONLY. STUDENT USE PROHIBITED
About This Course iii
Resources: include well-categorized additional resources that give you immediate access to the most
current premium content on TechNet, MSDN®, or Microsoft® Press®.
Course evaluation: at the end of the course, you will have the opportunity to complete an online
evaluation to provide feedback on the course, training facility, and instructor.
Note: At the end of each lab, you must revert the virtual machines to a snapshot. You can
find the instructions for this procedure at the end of each lab
The following table shows the role of each virtual machine that is used in this course:
Software Configuration
The following software is installed on the virtual machines:
SQL2017
SharePoint 2016
Course Files
The files associated with the labs in this course are located in the D:\Labfiles folder on the 20768B-MIA-
SQL virtual machine.
Classroom Setup
Each classroom computer will have the same virtual machine configured in the same way.
MCT USE ONLY. STUDENT USE PROHIBITED
iv About This Course
Dual 120-gigabyte (GB) hard disks 7200 RM Serial ATA (SATA) or better
DVD drive
Network adapter
Additionally, the instructor’s computer must be connected to a projection display device that supports
SVGA 1024×768 pixels, 16-bit colors.
MCT USE ONLY. STUDENT USE PROHIBITED
1-1
Module 1
Introduction to Business Intelligence and Data Modeling
Contents:
Module Overview 1-1
Lesson 1: Overview of Business Intelligence and Data Models 1-2
Module Overview
Business intelligence (BI) is a fundamental part of everyday business activity for modern organizations,
enabling them to understand trends and plan future activities more effectively. A great deal of BI depends
on data models, which expose data in a meaningful way, and enable much faster analysis of complex data.
Objectives
After completing this module, you will be able to:
Lesson 1
Overview of Business Intelligence and Data Models
The term “business intelligence” is commonly used to refer to a broad range of activities and technologies
that enable organizations to better understand their data, and to use it to gain insights that can benefit
the business. Many organizations use data models as the basis of their BI activities because they can
improve usability and offer other benefits such as improved performance. Any BI project is a substantial
undertaking and requires careful planning. To ensure that projects are successful and achieve the required
return on investment (ROI), it is important to have an understanding of the key project roles in this type of
project.
Lesson Objectives
After completing this lesson, you will be able to:
Explain the components of business intelligence projects and the key project roles.
Reporting
Reporting is the communication of information that is gained from BI. Most organizations rely on reports
to summarize business performance and activities. Consequently, most BI solutions include an element
that generates reports. Typical examples are financial and management reports that include cash flow,
profit and loss, a balance sheet and open orders. A retail business might require stock inventory reports,
whereas a technical support call center might need a report that shows call log data. In some scenarios,
users might need to view reports interactively in a web browser or custom application. In other instances,
the requirement might be to send reports as email attachments in specific formats, such as Microsoft®
Excel® workbooks or Microsoft Word documents. In many cases, the reports might need to be printed,
for example, to send a physical report to customers or shareholders. When you are planning a reporting
solution, you must consider the reports that are required, the audiences for those reports, and how they
will be delivered. Microsoft SQL Server® includes Reporting Services, a powerful reporting technology
that supports a wide range of reporting scenarios.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 1-3
Note: This course does not describe SQL Server Reporting Services in detail. For more
information about using Reporting Services, you can attend course number 10990C: Analyzing
Data with SQL Server Reporting Services.
Analysis
Analysis is the interpretation of business data that the BI solution delivers. For business analysts in
particular, performing analysis is a discrete activity that involves using specialist analytical tools to examine
data in analytical models. For others, analysis is simply a part of everyday work and involves using reports
or dashboards as a basis for business decision making. In general, when you are planning a BI solution,
you should consider the following kinds of analytical requirements:
Interactive analysis. Some BI solutions must support interactive “slice and dice” analysis in business
tools such as Excel or specialist data analysis tools. The resulting information can then be published as
a report.
Dashboards and scorecards. Commonly, analytical data can be summarized in a dashboard or
scorecard and embedded into business applications or portals, such as Microsoft SharePoint® Server
sites. These solutions might provide some interactivity to enable users to “drill down” into specific
details, or they may simply show important key performance indicators (KPIs).
Data mining. Most analysis and reporting concerns historical data, but a BI solution can also support
predictive analysis by using historical data to determine trends and patterns.
sophistication of users. This self-service reporting approach is of significant benefit in scenarios where
businesses need to:
Empower information workers to get the information that they need to make informed decisions
without waiting for an IT professional to create a report.
Supplement standard reports that the IT department create with custom reports for specific job roles
or scenarios.
Reduce IT workload by minimizing requests for custom reports, enabling IT professionals to focus on
more strategic and operational tasks.
Promote collaboration—when information workers can easily share the reports and other documents
that they create, collaboration becomes much easier.
For self-service reporting to be effective, some initial work must be done to design and implement a
suitable reporting infrastructure. After that is in place, users can benefit from the ability to customize the
reports that they use without placing an additional burden on the IT department.
Out-of-the-Box Solutions
Another significant trend in BI is the availability of out-of-the-box solutions, which are all-in-one offerings
that can accelerate the time that it takes to plan and implement a BI solution. Reducing planning and
implementation times makes it possible to achieve a much faster ROI, but the upfront cost of these
systems can be a barrier for some organizations.
The data model abstracts the underlying data warehouse tables, which enables you to create models
that reflect how business users perceive the business entities and measures, regardless of the data
warehouse table schema. If necessary, you can modify or expand the underlying data warehouse
without affecting the data model that is used by business users for analysis.
The data model reflects the users’ view of the business, so data analysis is easier for information
workers who have little or no understanding of database schema design. You can use meaningful
names for tables and fields, and define hierarchies based on attributes in dimension tables that make
the data more intuitive for business users.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 1-5
You can add custom logic to a data model that increases business value when analyzing the data. For
example, you can define KPIs that make it easier to compare actual business measures with targets.
Although the SQL Server database engine can provide extremely fast query performance, a data
warehouse typically contains a massive volume of data. Most analyses involve aggregating measures
across multiple dimensions, so the processing overhead for complex queries can result in
unacceptably slow response times, especially when many users access the data concurrently. A data
model typically preaggregates the data, which provides vastly superior performance for analytical
queries.
Data models are a common feature in BI solutions and there are well-established standards. By
creating a data model, you can expose analytical data through a standard interface to be consumed
by client applications such as Excel or third-party analytical tools.
Note: In addition to using data models as a source for reporting and analysis, you can also
create analytical reports directly from the data warehouse or a departmental data mart. This
enables you to express queries by using Transact-SQL, which may be more familiar to a report
developer than a data modeling query language such as Multidimensional Expressions (MDX) or
Data Analysis Expressions (DAX).
Extract, Transform, and Load (ETL) processes. ETL is the process of extracting data from data
sources, applying transformations to convert the data into the required format, and then loading it
into a data store such as a data warehouse. Source data can come from many sources, and might be
in various formats, and it is usually necessary to perform regular data loads to keep a data warehouse
up to date.
Reporting and analysis tools. There are many different tools that you can use to create reports and
analyze data, including Excel, Reporting Services, and Report Builder. The tools that end users will
require can have a big influence on the design of the overall solution.
MCT USE ONLY. STUDENT USE PROHIBITED
1-6 Introduction to Business Intelligence and Data Modeling
Project Roles
Implementing a BI project can be a complex process, and typically requires the involvement of people
from across the business. Most BI projects include some or all of the roles that are described below (note
that the project role names might differ; it is the function of the role that is important):
A project manager. Coordinates project tasks and schedules, ensuring that the project is completed
on time and within budget.
A BI solution architect. Has overall responsibility for the technical design of the data warehousing
solution.
A data modeler. Designs the data warehouse schema and analytical data models.
A database administrator. Designs the physical architecture and configuration of the data
warehouse database. Database administrators who have responsibility for data sources that are used
in the data warehousing solution must also be involved in the project to provide access to the data
sources that the ETL process uses.
An infrastructure specialist. Implements the server and network infrastructure for the data
warehousing solution.
An ETL developer. Builds the ETL workflow for the data warehousing solution.
Business users. Provide requirements and help to prioritize the business questions that the data
warehousing solution will answer. Often, the team includes a business analyst as a full-time member
to help interpret the business questions and ensure that the solution design meets users’ needs.
Testers. Verify the business and operational functionality of the solution as it is developed.
Note: The list in this topic is not exhaustive, but represents roles that must be performed. In
some cases, multiple roles may be performed by one person, although, in general, you should
avoid having testers validate their own development work.
Verify the correctness of the statement by placing a mark in the column to the right.
Statement Answer
Lesson 2
Microsoft Business Intelligence Platform
Microsoft products are used to provide IT infrastructure for organizations all over the world. Therefore, it
makes sense for many of these organizations to consider using the Microsoft BI platform to benefit from
the close integration and common infrastructure capabilities of the various products that can help to
deliver an enterprise BI solution. As a Microsoft BI professional, you need to know which products can be
used to implement the various elements of a BI solution, and how those products integrate with each
other.
Lesson Objectives
After completing this lesson, you will be able to describe:
The types of analytical data models that SQL Server Analysis Services supports.
SQL Server
SQL Server provides the core data services for a BI
solution. These services include:
SQL Server Analysis Services, which provides a storage and query processing engine for
multidimensional and tabular data models.
SQL Server Reporting Services, which provides a platform for publishing and delivering reports that
users can consume through a native web-based interface or have delivered by subscriptions.
MCT USE ONLY. STUDENT USE PROHIBITED
1-8 Introduction to Business Intelligence and Data Modeling
SQL Server Enterprise. You should use this edition for data warehouses and BI solutions that require
advanced SQL Server Integration Services features, such as fuzzy logic and change data capture (CDC)
components.
SQL Server Standard. You can use this edition for solutions that require basic reporting in SQL Server
Reporting Services, multidimensional models in SQL Server Analysis Services, and basic data mining.
Note: SQL Server is also available in Web and Express editions, but these are generally not
appropriate for BI solutions. SQL Server Developer edition includes all the functionality of
Enterprise edition, but is only licensed for development and test systems.
SharePoint Server
SharePoint Server provides enterprise information-
sharing services through collaborative websites.
SharePoint Server provides the following BI
capabilities:
Integration with SQL Server Reporting Services. You can deliver and manage reports and data
alerts through SharePoint document libraries instead of the native Report Manager interface that SQL
Server Reporting Services provides.
Power View. Power View is an interactive data visualization technology through which users can
graphically explore a data model in a web browser.
PerformancePoint Services. PerformancePoint Services enables BI developers to create dashboards
and scorecards that deliver KPIs and reports through a SharePoint site.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 1-9
Office Applications
Microsoft Office provides productivity applications
that business users can use to consume and interact
with BI data. These applications include:
Microsoft Word. Word is a document-authoring tool. In a BI scenario, users can export SQL Server
Reporting Services reports in Word format and use the editing and reviewing tools in Word to
enhance them.
Microsoft PowerPoint®. PowerPoint is a widely used presentation tool. Users can save Power View
visualizations as PowerPoint presentations, and present business data in a dynamic, interactive format.
Microsoft Visio®. Visio is a diagramming tool that can be used to document database schemas and
to visualize data mining analyses.
Power BI Desktop
Business users can also use Power BI Desktop to
consume and interact with BI data. It shares many
of the features offered by the Excel power tools, so
business users will find transitioning between the
two tools to be a straightforward process. Power BI
Desktop is a stand-alone tool that enables you to:
Publish reports. Using the Power BI Desktop application, you can publish reports to the online
Power BI service. If you need to keep your data inside your organization, you can use Power BI
Desktop (Optimized for Power BI Report Server) to publish reports to an on-premise Power BI Report
Server.
Create dashboards. After publishing a report, you can use the report items, known as tiles, to create
a new dashboard, even combining charts, maps, and KPIs from different reports.
Power BI Mobile
Power BI offers a mobile app for iOS, Android, and Windows devices. Reports and dashboards
automatically adjust their size to fit the screen of the device, so you need not worry about creating mobile
versions of your work. The apps are free to download, and reports and dashboards are fully interactive.
Q&A
One very useful feature of Power BI is Q&A. This means you can ask questions of your data using the
Natural Query Language. You can type in a topic, such as Total sales last year in Canada. You can also
specify which chart visual the data should be presented in. When Power BI returns the result, you can pin
the visual to a new or existing dashboard.
Note: In SQL Server, analytical data models are sometimes also called BI Semantic Models.
Hardware. Tabular data models use in-memory storage, so they require relatively large amounts of
memory.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 1-11
Calculations. Data models usually include calculations—you can implement these in tabular data
models by using the DAX language and in multidimensional models by using the MDX language.
Some calculations are easier to implement in DAX, others in MDX.
Many-to-many relationships. Tabular data models do not support the creation of many-to-many
relationships, although you can use DAX to model this type of relationship.
Data sources. Tabular data models support a wider range of data sources than multidimensional
data models, including text files and Excel.
Available skills. As with many technical decisions, a frequent deciding factor is the knowledge and
skills of the developers who will implement the data model.
Client tools. Most Microsoft tools can consume data from either type of data model.
Tabular mode. Tabular mode enables the creation of tabular data models.
PowerPivot mode. PowerPivot mode, which is also known as SharePoint integrated mode, integrates
SQL Server Analysis Services with a SharePoint server instance to make features of SQL Server Analysis
Services available through a SharePoint portal.
You cannot install two modes of SQL Server Analysis Services as part of the same instance, and you cannot
switch modes after installation. For example, if you need to create both tabular data models and
multidimensional data models, you should install two separate instances, each of which uses the
appropriate mode. As with instances of the database engine, it is possible to install multiple instances of
SQL Server Analysis Services on the same server running Windows Server®.
MCT USE ONLY. STUDENT USE PROHIBITED
1-12 Introduction to Business Intelligence and Data Modeling
SharePoint Architecture
When planning SharePoint integration, there are three tiers of the SharePoint architecture to consider:
Web front-end tier. One or more servers that accept requests for a SharePoint application or service,
and direct the request to the appropriate application server.
Application tier. One or more servers that host the service applications in the SharePoint Server
infrastructure.
Data tier. A SQL Server instance that hosts SharePoint databases. It is common to use clustering to
ensure high availability of the SharePoint databases.
Single server. In this topology, you host all of the SharePoint Server architecture layers on a single
server running Windows Server. The main benefit of this model is that it minimizes the licensing cost
for the solution. Typically, you use this type of configuration in development environments or training
environments because it is the easiest way to set up a SharePoint farm. However, because all three
layers run on the same server running Windows Server and share the same hardware, there can be
increased contention for resources. If this affects the performance of business reports, consider
implementing a scale-out solution.
Scale-out. In a scale-out topology, you separate each of the SharePoint Server architecture layers
onto different servers running Windows Server. Scaling out a SharePoint farm distributes the
workload across multiple servers, which reduces resource contention and improves throughput.
However, this topology comes with an additional licensing cost because it uses multiple servers.
Furthermore, it requires greater preparation to ensure that security works seamlessly across the
SharePoint farm. This topology offers no resilience if one of the servers shuts down. You should
consider a scale-out topology if performance is important, but there is no requirement for resilience.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 1-13
High availability. The high-availability topology involves separating the SharePoint architecture
layers across servers running Windows Server, and then duplicating each layer on another server. This
is the most expensive topology to implement, but it provides load balancing and high availability
across the entire SharePoint farm. The infrastructure preparation is similar to that of creating a scale-
out architecture, and also requires a network load balancer to distribute incoming requests to the first
available web front-end server.
The company is financially sound and has a strong order book, but sales volumes have remained relatively
static for the past few years. Senior management is under pressure from shareholders to develop a growth
strategy that will drive increased revenue and profit. Management believes that a key factor in its growth
strategy is investment in technology that improves collaboration between the various divisions of the
company, and enables them to track and share key business performance metrics.
Objectives
After completing this lab, you will have:
Explored a data warehouse by using a database diagram and by issuing Transact-SQL queries.
Performed basic data analysis by using Excel with a data model as a data source.
Password: Pa55w.rd
2. Create a database diagram for the AdventureWorksDW database, and note the following details
about its schema:
o The FactInternetSales table stores details of sales orders that are made through the Adventure
Works website. The table is related to the DimCustomer table, which contains details of the
customers who have placed orders.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 1-15
o The FactResellerSales table stores details of sales orders that are made to resellers. The table is
related to the DimReseller table, which contains details of the resellers who have placed orders.
o The DimDate table stores values for dates, including details of the calendar and fiscal periods in
which individual dates occur.
o The FactInternetSales and FactResellerSales tables are related to the DimDate table by
multiple fields. These fields represent the order date (the date when the order was placed), the
due date (the date when the order was expected to be in stock), and the ship date (the date
when the order was shipped to the customer).
o Both the DimCustomer and DimReseller tables are related to the DimGeography table, which
stores details of geographical locations. The DimSalesTerritory table is also related to
DimGeography.
o Many tables include multiple language values for the same data value, for example, the DimDate
table stores the English, French, and Spanish words for each month name.
o The DimEmployee table is related to itself to represent the fact that each employee has a
manager, who is also an employee.
3. Save the diagram as AdventureWorksDW Schema.
o The data warehouse contains historical Internet sales orders from July 2005 to July 2008. Reseller
sales in the data warehouse are also recorded for this time period.
o You can use the MonthNumberOfYear column in the DimDate table to sort month names into
chronological order—without this field, it would be difficult (though not impossible) for reporting
clients to sort months other than alphabetically. A similar field named DayNumberOfWeek can
be used to sort weekday names into chronological order.
3. Execute the query under the comment Geographical reseller sales, and note the following details:
o In 2005, Adventure Works only sold to resellers in the United States and Canada.
o In 2006, this was expanded to include France and the United Kingdom.
4. Execute the query under the comment Sales by product category, and note the following details:
o Adventure Works sells four categories of product: Accessories, Bikes, Clothing, and Components.
o Components are only sold to resellers, not to Internet customers.
2. Explore the Adventure Works OLAP database in the MIA-SQL SQL Server Analysis Services server.
Note that it contains a data source named Adventure Works Data Warehouse, which connects to
the AdventureWorksDW database that you explored in the previous exercise.
3. Browse the cube named Internet Sales, to view the Sales Amount measure by Order Date – Fiscal
Year. Note that in Adventure Works, fiscal years run from July to June, so fiscal year 2006 represents
the period from July 2005 to June 2006.
3. Import data from the MIA-SQL SQL Server Analysis Services server:
o Select the Internet Sales cube in the Adventure Works OLAP database.
5. Add the Order Date.Calendar Date hierarchy to the rows of the PivotTable, and explore the data by
drilling down from years to semesters, semesters to quarters, quarters to months, and months to days.
2. Use the filter to show only sales for the Accessories category:
3. Clear the filter, and then save and close the workbook.
Results: After completing this exercise, you will have used Excel to explore an analytical data model built
on the data warehouse.
Question: Which tools have you used to view BI data? How do these tools differ and what
are the advantages and disadvantages of these tools?
MCT USE ONLY. STUDENT USE PROHIBITED
1-18 Introduction to Business Intelligence and Data Modeling
Review Question(s)
Question: In your experience, what are the factors that affect the success or failure of a BI
project?
MCT USE ONLY. STUDENT USE PROHIBITED
2-1
Module 2
Creating Multidimensional Databases
Contents:
Module Overview 2-1
Lesson 1: Introduction to Multidimensional Analysis 2-2
Module Overview
You can use Microsoft® SQL Server® Analysis Services (SSAS) to build on Online Analytical Processing
(OLAP) solutions that help you to quickly and efficiently obtain accurate business intelligence (BI) that
improves business decision making—and helps to drive growth. SSAS multidimensional databases, which
are also known as OLAP cubes, have several benefits including:
Fast query response times because of a preaggregation of data and calculations. Queries against
cubes are generally much quicker than the equivalent queries against relational databases.
Multidimensional structures are logical and straightforward, and also provide an intuitive navigation
path for end users that is easy to understand.
Accessibility from a wide range of tools, such as Microsoft Excel®, Power View, and third-party tools.
This module introduces multidimensional databases and the core components of an OLAP cube.
Objectives
After completing this module, you will be able to:
Lesson 1
Introduction to Multidimensional Analysis
Multidimensional analysis using OLAP involves the creation of OLAP cubes, data sources, data source
views, dimensions, measures, and measure groups. This lesson explains the business problem that
multidimensional data models address, and describes data sources, data source views, and the core
components of a cube: dimensions, measures, and measure groups.
Lesson Objectives
After completing this lesson, you will be able to:
When considering using an OLTP system as a direct source of data for reporting and analysis, bear in
mind the following points:
Aggregated spanning queries are slow to generate.
Normalized relational data models are not intuitive for business users.
Slicing involves using a member of one dimension to provide a slice of the cube. For example, you
could slice a cube using a particular product, and view all sales of that product across all dates and
customers.
Dicing involves providing values for every dimension to locate a single value for a cube. For example,
you could look for sales of a particular product, on a particular day, to a particular customer.
MCT USE ONLY. STUDENT USE PROHIBITED
2-4 Creating Multidimensional Databases
Aggregations
One key difference between cubes and relational systems─and between cubes and tabular data models—
is the processing of the cube. The aggregations of measures are calculated when the cube is processed,
not when the query runs. Consequently, when business users run queries, response times are extremely
fast, because the complex processing is already complete.
Data Sources
A data source is an object that provides an SSAS
database with the information required to connect
to a data source for the cubes it contains. Analysis
Services can access data from one or more data
source. Typically, the source database for an OLAP
cube is a data warehouse or a departmental data
mart, in which the tables have been denormalized
to reflect a star or snowflake schema of fact and
dimension tables. However, SSAS can use virtually
any database as a data source, and abstract the
underlying data model by using a data source
view.
At a minimum, a data source includes an identifier, a name, and a connection string. The connection
string used to access the source data includes the following information:
space characters and capitalization, making it relatively difficult to understand. In a data source view, you
can represent columns by using names that are easier to read.
A data source view contains the following items:
A definition of any subset of the schema retrieved from one or more data sources, which could
involve the whole schema, including the following:
o Table names
o Column names
o Data types
o Nullability
o Column lengths
o Primary keys
Enhancements to the schema from the underlying data sources, including the following:
o Friendly names for tables, views, and columns.
o Named queries that return columns from one or more data sources (that show as tables in the
schema).
o Named calculations that return columns from a data source (that show as columns in tables or
views).
o Logical primary keys (needed if a primary key is not defined in the underlying table, or is not
included in the view or named query).
o Logical primary key/foreign key relationships between tables, views, and named queries.
You can also create multiple diagrams showing different subsets of the data source view. Unlike different
data source views, different diagrams reference the same schema. Therefore, any changes you make in
one diagram apply to all the others in the data source view. Diagrams are useful when you create multiple
cubes within the same solution.
Dimensions
As described earlier, dimensions provide the
context for the facts stored in the OLAP cube.
Dimensions include key values and hierarchies.
Key Values
Each dimension includes a key attribute that
matches values in the fact table. The key attribute
also enables SSAS to join records to related data in
the fact table, in the same way that tables use
columns to match values in Transact-SQL
statements. For example, a dimension called
Product Category might include a
ProductCategoryID key value, which also exists as
MCT USE ONLY. STUDENT USE PROHIBITED
2-6 Creating Multidimensional Databases
a column in the fact table. Matching the values in the dimension and the fact table enables Analysis
Services to aggregate the measure values correctly, according to the dimension that the user specifies.
Dimension Hierarchies
Analysis Services dimensions are hierarchical, not flat. For example, a Time dimension typically has years,
months, and days; a Geography dimension typically includes country, state, and town. A dimension can
have more than one hierarchy, meaning you can drill down in different ways. For example, one hierarchy
might include year, month, and day, and another might include year, week, and day.
Dimension hierarchies can also be unbalanced and ragged. An unbalanced dimension hierarchy does not
have the same number of levels in every branch. For example, in an Employee dimension, the Sales
Director reports to the Chief Executive Officer (CEO) and has three levels of staff below her. The Executive
Assistant also reports to the CEO but has no levels below him. A ragged dimension hierarchy is a particular
type of unbalanced dimension where there are missing or duplicated levels in the hierarchy. For example,
in a Geography dimension hierarchy that contains Continent, Country or Region, State, and City, the city
state of Monaco would either have the values of Europe, Monaco, Monaco, Monaco—or the values of
Europe, Monaco, NULL, NULL.
Note: You will learn more about MDX in the Introduction to MDX module in this course.
Measure Groups
Measures are grouped, based on their underlying fact tables. Measure groups are used to define the
relationship between dimensions and measures. When a dimension or a measure group is added to the
cube, SSAS will examine the relationship that exists between the fact table and the dimension table in the
data source and automatically set the Measure Group information in the Dimension Usage tab of the
Cube Designer. You can then modify this to your requirements.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 2-7
Cubes
A cube is the unit that defines dimensions and
measures and is the user’s point of access to the
multidimensional data. The term “cube” is used
because it describes the multidimensional nature
of the data, as opposed to the one-dimensional or
two-dimensional types of relational tables.
However, almost all cubes have more than three
dimensions. You can use cubes to bring together
all the functionality of dimensions and measures
to display them in a user-friendly interface, such as
an Excel PivotTable table. You can use the
PivotTable interface with SSAS to display
aggregated measure data, and slice and dice it by using dimension members.
After creating a cube, you must process it. This populates the cube with data and creates the measures
and calculations specified in the cube design. Periodically, you should also process cubes to bring the data
they contain up to date, and to reflect any changes. Cubes also represent an administrative unit within
Analysis Services, and include settings that define storage, aggregation levels, and processing frequency
for the cube.
MCT USE ONLY. STUDENT USE PROHIBITED
2-8 Creating Multidimensional Databases
Categorize Activity
Match the definition to the correct Analysis Services component.
Items
2 An aggregated numerical
value, such as a sales total.
Lesson 2
Data Sources and Data Source Views
OLAP and data mining projects in SSAS are designed based on a logical data model of related tables,
views, and queries from one or more data sources. Data sources are defined as data source objects in
Analysis Services, and logical data models are defined as data source views. You use data source views to
filter the data from a data source so that the cube includes only a subset of the data that populates a
large data warehouse.
Lesson Objectives
After completing this lesson, you will be able to:
o Analysis Services
o Oracle
If you have an existing data source defined in an SSAS database or project, and want to create a new data
source object that connects to the same underlying data source, you can copy the properties of the first
data source object into a new version.
MCT USE ONLY. STUDENT USE PROHIBITED
2-10 Creating Multidimensional Databases
A data source view handles the layout of tables, filters, SQL expressions, relationships, and other
complexities of the schema. Therefore, a data source view enables simple bindings by SSAS cubes,
dimensions, and mining models to the tables and columns in the data source view.
Use the FriendlyName property to specify a column name from a table or view that is easier for users
to understand—or is more relevant to the subject area.
Create a named query and named calculations that mean you can extend the relational schema of
existing tables in a data source view, without modifying the underlying data source.
Create diagrams to reduce the visual clutter when you only want to view a subset of the tables in the
data source view.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 2-11
Demonstration Steps
Create an Analysis Services Project
1. Ensure that the 20768C-MIA-DC and 20768C-MIA-SQL virtual machines are both running, and then
log on to 20768C-MIA-SQL as ADVENTUREWORKS\Student with the password Pa55w.rd.
4. In the New Project dialog box, in the Business Intelligence templates section, create a new
Analysis Services Multidimensional and Data Mining Project named Demo in the
D:\Demofiles\Mod02 folder.
1. In Solution Explorer, right-click Data Sources, and then click New Data Source.
4. In the Server name field, type localhost, in the Select or enter a database name list, click
AdventureWorksDW, click OK, and then click Next.
5. On the Impersonation Information page, click Use a specific Windows user name and password,
enter the user name ADVENTUREWORKS\ServiceAcct and the password Pa55w.rd, and then click
Next.
6. In the Data source name field, type Adventure Works Demo DS, and then click Finish.
1. In Solution Explorer, right-click Data Source Views, and then click New Data Source View.
2. On the Welcome to the Data Source View Wizard page, click Next.
3. On the Select a Data Source page, ensure that Adventure Works Demo DS is selected, and then
click Next.
4. On the Select Tables and Views page, select the DimDate, DimProduct, DimProductCategory,
DimProductSubcategory, DimReseller, DimSalesTerritory and FactResellerSales tables. Add these
tables to Included objects, and then click Next.
5. On the Completing the Wizard page, in the Name field, type Adventure Works Demo DSV, and
then click Finish.
MCT USE ONLY. STUDENT USE PROHIBITED
2-12 Creating Multidimensional Databases
1. If it is not already open, in Solution Explorer, right-click Adventure Works Demo DSV, and then click
Open.
2. In Data Source Designer, click the table name of the FactResellerSales table and press F4.
4. Repeat the previous steps to rename the DimSalesTerritory table to Sales Territory.
5. Right-click the DimProduct table, and then click New Named Calculation.
8. Right-click the DimProduct table and click Explore Data, then scroll down until you see a value in
the Product Size column (the last column in the table) that shows the size and measurement unit.
9. Close the Explore DimProduct Table window then, on the File menu, click Save All.
10. Keep Visual Studio open. You will return to it in a later demonstration.
Verify the correctness of the statement by placing a mark in the column to the right.
Statement Answer
Lesson 3
Cubes
A cube is a multidimensional structure containing dimensions and measures. Dimensions define the
structure of the cube and measures provide the numerical values of interest to the end user. As a logical
structure, a cube enables a client application to retrieve values as if cells in the cube define every possible
summarized value. Cubes consume the data that you make available to them through data sources and
data source views.
Lesson Objectives
This lesson describes how to create and modify cubes, and includes some considerations for cube design.
After completing this lesson, you will be able to:
Creating a Cube
To create a cube in Analysis Services, you can use
the Cube Wizard in an Analysis Services project in
SQL Server Data Tools. You can launch the wizard
by right-clicking the Cubes node in a project in
Solution Explorer, and then clicking New Cube.
When you create the cube, you can add existing dimensions, or create new dimensions that structure
the cube.
You can also create dimensions separately, by using the Dimension Wizard, and then add them to a
cube.
Instead of using an existing data source and data source view, you can build the cube without using a
data source and subsequently generate the database schema. Another option is to create the cube,
and enable SSAS to create the underlying schema supporting the cube.
You can use the Cube Wizard to automatically build attributes and hierarchies, or you can choose to
define them in the Cube Designer later.
MCT USE ONLY. STUDENT USE PROHIBITED
2-14 Creating Multidimensional Databases
Create aggregations.
Time Dimensions
One of the most important and commonly-used
types of dimension is the time dimension, which
includes time and date values that users can use to
filter the data in the cube. Although most cubes
include a time dimension, some cubes use
different factors instead—such as a unit of work or
project—to delineate data.
Server time dimensions. Server time dimensions are based on tables stored on the Analysis Services
server. A server time dimension avoids the need for joins in the data source, and can therefore be
faster to process. You can use server time dimensions if security settings prevent you from creating
tables in the data source.
Time dimension tables. Time dimensions are based on tables that are created and stored in the data
source. Many time dimensions need to include additional data—for example, corporate time
information such as quarters, which do not follow calendar quarters or public holidays. A time
dimension table gives you greater control so you can, for example, add detail to the time members,
which allows you to store additional properties for each date.
Browsing a Cube
After you create a cube, users can access it and
analyze the data that it contains by using a tool
such as Excel. To ensure that the cube functions as
expected before allowing users to access it, you
can use the Cube Browser in SQL Server Data
Tools. You can use the Cube Browser to browse
the cube, and to see the measures that it contains
aggregated by its dimensions. Being able to
browse the cube from within the development
environment is very useful, because it means you
can test the cube without switching between a
client application and SQL Server Data Tools. By
using the Cube Browser, you can change the security context and browse the cube as another user, which
helps to ensure that any security features and perspectives that you have configured are functioning
correctly.
Note: Before you can browse cube data in the Cube Browser tab, you must deploy the
database and cube. You can then click the Browser tab from within the Cube Designer to browse
the cube.
Analyze in Excel
You can also use the Analyze in Excel option, in the Cube Browser in SQL Server Data Tools, to open an
Excel workbook and use it to browse data in the cube. The Analyze in Excel feature automatically creates
the data connection from Excel to the cube, so there is no need to configure it manually.
MCT USE ONLY. STUDENT USE PROHIBITED
2-16 Creating Multidimensional Databases
Create a cube.
Demonstration Steps
Create a Cube
1. Ensure that you have completed the previous demonstration in this module.
2. Maximize Visual Studio, which should be open with the Demo project loaded.
5. On the Select Creation Method page, ensure that Use existing tables is selected, and click Next.
6. On the Select Measure Group Tables page, click Suggest then note that the wizard identifies
DimReseller and Reseller Sales as potential measure group tables. Clear DimReseller so that only
FactReseller Sales is selected, and then click Next.
7. On the Select Measures page, clear the FactReseller Sales check box to clear all selections, select
the Total Product Cost and Sales Amount measures, and then click Next.
8. On the Select New Dimensions page, clear the Reseller Sales dimension, and then click Next.
9. On the Completing the Wizard page, change the cube name to SalesDemo and click Finish. The
cube is created and opened in the Cube Designer.
2. After the deployment completes, in the Cube Designer, click the Browser tab.
3. In the Metadata pane, expand Measures and expand Reseller Sales. Note that the wizard has
created the measures you selected.
4. Drag the Sales Amount measure to the Drag levels or measures here to add to the query area.
The total sales amount for all reseller sales is shown.
5. In the Metadata pane, note that the wizard has created dimensions for the DimReseller and
DimProduct tables. It has also determined that there are three relationships defined between the
Reseller Sales table and the DimDate table, and so has a dimension for each related column (Due
Date, Order Date, and Ship Date).
6. Expand each dimension and note that the wizard has only created attributes for key columns. You will
need to modify the dimensions to add meaningful attributes for analysis.
7. Drag the Product Key attribute from the Dim Product dimension to the left of the Sales Amount
value in the grid. The browser now shows the aggregated sales amount totals for each product key.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 2-17
1. In the Cube Designer, click the Cube Structure tab, and then, in the Measures pane, expand Reseller
Sales.
2. Right-click the Total Product Cost measure and click Rename, then change the name of the
measure to Cost.
3. In the Dimensions pane, right-click Dim Reseller, click Rename and change the name of the
dimension to Reseller.
6. In the Data Source View pane, in the DimProduct table, drag the EnglishProductName field to the
Attributes pane.
7. In the Attributes pane, right-click English Product Name and click Rename, then rename the
attribute to Product Name.
8. In Solution Explorer, right-click Demo and click Deploy. If prompted, enter the password Pa55w.rd
for the ADVENTUREWORKS\ServiceAcct user.
9. After the deployment completes, click the SalesDemo.cube [Design] tab to return to the Cube
Designer, and then click the Browser tab.
10. On the Browser tab, click the Reconnect button in the upper left corner. If the grid contains any data
from previous queries, right-click in the grid and click Clear Grid.
11. In the Metadata pane, expand Measures and Reseller Sales, and drag Cost to the Drag levels or
measures here to add to the query area.
12. Expand the Product dimension, and then drag Product Name to the left of the Cost value. The total
cost associated with sales for each product is shown.
14. Keep Visual Studio open. You will use it again in a later demonstration.
MCT USE ONLY. STUDENT USE PROHIBITED
2-18 Creating Multidimensional Databases
Lesson 4
Overview of Cube Security
After you install an instance of SQL Server Analysis Services, only members of the server role have server-
wide permissions to perform any task within that instance. This is because, by default, no other users have
access permissions to the objects in the instance. Members of the SSAS server role can grant other users
access to server and database objects by using Microsoft SQL Server Management Studio, SQL Server Data
Tools, or an XML for Analysis (XMLA) script. This lesson describes the SSAS security model, and explains
how to use roles and permissions to implement security.
Lesson Objectives
After completing this lesson, you will be able to:
SSAS has a single fixed server role for administrators—this is called the server administrator role.
Members of this role have full permissions to perform any action in the instance.
Administrators can create database roles and grant access permissions to these roles to control user
access and database administrator rights. Role permissions are database specific.
You can grant database role permissions for Analysis Services databases, cubes, dimensions,
dimension members, individual cells within a cube, mining structures, mining models, data sources,
and stored procedures.
MCT USE ONLY. STUDENT USE PROHIBITED
2-20 Creating Multidimensional Databases
Database Roles
To assign permissions to users who do not require server-wide administrative rights, you can create
database roles. You should first decide what levels of access are required within your organization,
including basic users, power users, managers, and department administrators. After you have defined the
roles, you can create them, and then add users to the roles. Consider the following points when planning
database roles and permissions:
When assigning permissions, you should always follow the principle of least permission—you should
never give a role greater permissions than it requires to enable users to perform their tasks.
Remove groups with duplicated permissions and, where possible, consolidate groups with similar
permissions, providing this does not give any sensitive permission to another group.
You can create database roles by using SQL Server Management Studio or by using SQL Server Data
Tools:
In SQL Server Management Studio, in Object Explorer, expand the database, right-click the Roles
folder, and then click New Role.
In Visual Studio, in Solution Explorer, right-click the Roles folder and then click New Role. You can
also add a role by clicking the Project menu, and then clicking New Role.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 2-21
Assigning Permissions
Administrators assign permissions to roles, and
these permissions determine the actions that a
user can perform. You can set permissions for
Analysis Services objects including databases, data
sources, cubes, cells, dimensions, and dimension
data.
Database Permissions
Assigning permissions to roles in an Analysis
Services database gives users administrative rights
in the database─it does not enable them to view
or work with the data in the database. To enable
users to browse dimensions and measures, you
need to assign permissions on cubes and other objects. The permissions you can assign on Analysis
Services databases include:
Full control (Administrator). This gives users the ability to perform all administrative tasks, such as
processing databases and database objects, and creating and managing roles.
Process database. This enables users to process the database. Processing a database populates it
with data from the data source, and updates the database with new data.
Read definition. You can assign this to roles that also have the Process database permission to
enable users to process a database, by using tools such as SQL Server Data Tools. Without the Read
definition permission, the Process database permission only enables user accounts to process
databases by using scripting.
Cube Permissions
To access data within the database, users must either be members of a role with permissions to access the
cube, or members of a role with administrative rights. You can assign the following permissions for a cube:
Read. This enables users to read the data in a cube. This permission is usually sufficient for the
majority of users, who will only need to analyze data and not update it.
Read/Write. This enables users to read and change the data. Note that updates that users perform
are not written back to the source database—instead, the changes are written to a writeback table.
By default, a role with permissions for the cube can access all objects in the cube, including:
Note: Permissions to access a data source are not required for a user to access cube data.
MCT USE ONLY. STUDENT USE PROHIBITED
2-22 Creating Multidimensional Databases
Cell Permissions
Cell permissions control access to measure data in a cube at the individual cell level. A role that has Read
or Read/Write permissions on a cube can, by default, access all individual cells in the cube, because the
permissions are inherited from the cube level. By applying cell permissions, you can override the default
permissions to control access at a more granular level. Although the default is that cell permissions apply
to all cube cells, if you grant access to one or more cells for a role, that role is denied access to all other
cells—until you grant further permissions. You can use an MDX statement to specify the range of cells to
which the permissions apply.
Note: When a user attempts to access cells for which they do not have permission, the
query returns the value #N/A for that cell.
Note that assigning permissions to roles at the cell level cannot raise the permission level that is assigned
to the role at the cube level. For example, if a role has Read permission on a cube and is assigned
Read/Write permission on a cell, the effective permission that they have on the cell is only Read─the
Write portion of the permission is not applied.
In addition to the Read and Read/Write permissions for cells, you can also assign the Read-Contingent
permission. This permission conditionally enables access to a calculated cell, but users can only read the
cell if they also have permissions on all of the cells that the calculation references. For example, imagine a
role called Sales Manager that has the following access rights:
Read access to the Sales Value measure, but no access to the Product Cost measure.
Read access to the Profit calculated measure, which is defined as Sales Value minus Product Cost.
When granted Read permission on the Profit measure, Sales Manager role members can see the results
of the Profit measure. Because they can also view the results of the Sales Value measure, they could
calculate the value of the Product Cost measure, even though they have no direct access to it. Applying
Read-Contingent access to the Profit measure means that users can only see the results of the Profit
measure if they also have permission to view both the Sales Value and the Product Cost measures.
Test permissions.
Demonstration Steps
Create a Role
1. Ensure you have completed the previous demonstration in this module. Visual Studio should be open
with the Demo project loaded.
2. In Solution Explorer, right-click Roles, and click New Role. In Solution Explorer, right-click the
Role.role icon that has been added, click Rename, and change the name to Restricted User.role.
When prompted to change the object name, click Yes.
3. In the role designer, on the General tab, note that by default this role has no database permissions.
4. On the Membership tab, note that this is where you can add Windows users and groups to the role.
5. On the Data Sources tab, note that by default the role has no access to any data sources.
6. On the Cubes tab, change the Access value for SalesDemo to Read. This allows the role to access
the cube and read its data.
7. On the Cell Data tab, note that this is where you can specify MDX statements that define cells in the
cube that you want to permit or deny this role to access.
8. On the Dimensions tab, note that the role has Read access to all dimensions in the database. In the
Select Dimension Set list at the top of the page, click SalesDemo cube dimensions and note that
these permissions are inherited by the dimensions in the Demo Cube cube.
9. On the Dimension Data tab, in the Dimension list, under SalesDemo, select Measures Dimension
and click OK. On the Basic tab, clear the check box for the Cost measure.
10. In the Dimension list, under SalesDemo, select Product and click OK. On the Basic tab, in the
Attribute hierarchy list, select Product Name.
11. Select Deselect all members then scroll to the bottom of the list of product names and select all of
the products that begin with the word Touring.
Test Permissions
1. In Solution Explorer, right-click Demo and click Deploy. If prompted, enter the password Pa55w.rd
for the ADVENTUREWORKS\ServiceAcct user.
2. When deployment is complete, in Solution Explorer, double-click SalesDemo.cube to return to the
Cube Designer.
3. On the Browser tab, click the Reconnect button at the top left. If the grid contains any data from
previous queries, right-click in the grid and click Clear Grid.
4. In the Metadata pane, expand Measures and Reseller Sales, and drag Sales Amount and Cost to
the Drag levels or measures here to add to the query area. Expand the Product dimension and
drag Product Name to the left of the measure values. The browser shows the cost and sales amount
for all products.
6. In the top left area of the browser window, click the Change User button. In the Security Context –
Demo Cube dialog box, select Roles, and in the drop-down list, select Restricted User and click OK.
Click OK again to return to the browser window.
7. Note that the grid has been cleared then, in the Metadata pane, expand Measures and Reseller
Sales, and drag Sales Amount to the Drag levels or measures here to add to the query area. Note
that members of this role cannot access the Cost measure.
8. Expand the Product dimension and drag Product Name to the left of the measure values. The
browser only shows the sales amount for the Touring products.
9. On the File menu, click Save All, and then close Visual Studio.
Lesson 5
Configuring SSAS
It is important to understand how SSAS allocates and manages memory to ensure that memory usage and
limits are optimized for the server that is running SSAS. Different configurations, such as multi-instance,
sharing with a SQL Server relational instance, or single-instance configurations, might require some
adjustment of the memory configuration settings. In addition, it is important to understand the optimal
storage configuration for Analysis Services, because this has specific characteristics that are different to
other SQL Server workloads.
Lesson Objectives
After completing this lesson, you will be able to:
Setting Description
LowMemoryLimit This limit is used by multidimensional instances, and is the lowest limit at
which the SSAS instance will begin to release memory allocated to
infrequently used objects.
VertiPaqMemoryLimit This limit is used by tabular instances, and is the lowest threshold at
which the SSAS instance begins releasing memory allocated to
infrequently used objects. If memory paging to disk is enabled, this value
also defines the level of memory consumption at which memory paging
should start. The default value is 60.
TotalMemoryLimit This is an upper threshold at which the SSAS instance begins releasing
memory more aggressively to make room for currently executing
requests and new high-priority requests. This limit applies to both
multidimensional and tabular instances. The default value is 80 percent
of either physical memory or virtual address space, whichever is smaller.
MCT USE ONLY. STUDENT USE PROHIBITED
2-26 Creating Multidimensional Databases
Setting Description
HardMemoryLimit This threshold defines a level at which the SSAS instance starts to reject
requests completely due to memory usage. The default value for this
setting is 0, which automatically places the threshold midway between
the TotalMemoryLimit value and either the physical memory or virtual
address space, whichever is smaller.
Setting the above properties with a value between 1 and 100 will interpret the values as a percentage of
system memory (or virtual address space). Setting the properties with a number larger than 100 will
interpret the value as a fixed number of bytes. For example, setting the value of TotalMemoryLimit to 85
will mean that SSAS will release memory more aggressively when 85 percent of memory is in use, but
setting the value to 12884901888 would mean that SSAS would start releasing memory more aggressively
after 12 GB of memory was in use.
In addition, for tabular instances, you can set the VertiPaqPagingPolicy property to 0 to disable memory
paging to disk. This will generate an out-of-memory error if no more memory is available. Setting the
value to 1 enables paging to disk.
Note: Several other server properties can affect memory behavior, but you should not alter
others than those outlined here without seeking guidance from Microsoft Support.
the operating system and for the SQL Server database instance. In addition, for a configuration such as
this, you might also consider configuring the minimum server memory property on the SQL DB instance,
to ensure that the SQL Server database instance has sufficient memory for processing.
Memory Properties
https://aka.ms/wc4yue
NUMA Configurations
Non-Uniform Memory Access (NUMA) is a
mechanism designed to improve performance on
multiprocessor systems. NUMA architecture
allocates specific areas of memory to individual
processors in a multiprocessor system, so that
processors experience less contention over access
to a large shared memory.
0 The SSAS instance will ignore NUMA nodes and create one IOProcess
thread pool to be used by all logical processors.
1 The SSAS instance creates one IOProcess thread pool for each NUMA
node. This improves coordinated access to memory.
2 The SSAS instance creates one IOProcess thread pool for each logical
processor. It is intended for highly scaled hardware, with intensive
Analysis Services workloads.
As of SQL Server 2016 SP1 and later, Analysis Services tabular instances are NUMA node aware. NUMA
node awareness and changes to behavior are automatically activated on systems with four or more NUMA
nodes, where a separate job queue is maintained for each NUMA node. On systems with only two NUMA
nodes, the marginal benefit usually doesn’t overcome the overhead of managing NUMA.
For more information, see Improving Analysis Services Performance and Scalability with SQL Server 2016
Service Pack 1 on the Analysis Services Team Blog:
Improving Analysis Services Performance and Scalability with SQL Server 2016 Service Pack 1
https://aka.ms/k6wf45
MCT USE ONLY. STUDENT USE PROHIBITED
2-28 Creating Multidimensional Databases
Processor Affinity
You can also use the GroupAffinity property to control which Analysis Services thread pools can use which
logical processors in the system. This means a more granular control of workloads for advanced
performance tuning on large, multicore systems. Customizing GroupAffinity on systems that have less
than 64 logical processors might not provide tangible benefits and may even be detrimental to Analysis
Services performance.
For more information, see Thread Pool Properties in the Microsoft Docs:
Storage Configuration
Based on a typical Analysis Services workload, the
I/O generated is largely random reads during
operational periods. Of course, this depends on
how frequently the cube is being updated, but
cube updates are periodical and often occur
outside of operational hours. This means that disk
configurations that favor read operations are
typically desirable.
In addition, there are a few general recommendations for Analysis Services storage configuration:
Configure a single volume. It is not normally considered a good practice to separate any of the data
files for the cube onto a separate volume. Configuration of a single, large volume for your cubes will
typically ease management overhead and allow the largest I/O bandwidth to the storage hardware.
Exclude Analysis Services folders from virus scanners. Ensure that the Data, TempDir, and backup
folders are not being scanned by antivirus software. There are no executable files in these folders.
Defragment the data folder. Over time, the files in cube data folders can become very fragmented.
Periodically, you should defragment the cube volume during a maintenance period to keep
performance at expected levels.
For more information, see the Microsoft SQL Server Analysis Services Multidimensional Performance and
Operations Guide on the Microsoft Download Center.
Microsoft SQL Server Analysis Services Multidimensional Performance and Operations Guide
https://aka.ms/q0gr28
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 2-29
Lesson 6
Monitoring SSAS
Monitoring an Analysis Services multidimensional instance for performance will give you important
information regarding instance and cube performance. Of course, instance performance will be affected
by the availability of hardware resources, such as processor or memory. However, cube performance can
also be greatly affected by the way queries are written and processed.
Lesson Objectives
After completing this lesson, you will be able to:
o Data retrieval. The storage engine extracts the required data from the data model.
o Calculations. The formula engine performs the required calculations to output the data.
Cube Processing. The data held in the cube is typically updated at a predetermined interval, to allow
queries to represent more up-to-date information or changes to the data model. Cube processing
can be a resource intensive task, so it should only be performed as frequently as the data needs
updating for fresh reports or analysis output.
Analysis Services Proc Temp file bytes written The amount of data written
Aggregations to the temp file during
processing operations. If the
cube and hardware are well
balanced, this will be near 0.
Analysis Services Proc Indexes Current Partitions Measures the speed and
Rows/sec concurrency of index
processing.
System wide System File Read Bytes/sec File system read activity,
File Read Operations/sec including reads from the file
system cache.
For performance troubleshooting, you might also include Analysis Services counters for Threads, MDX and
Storage Engine Query objects. For I/O troubleshooting, the Memory and Physical Disk objects contain
some useful extra counters.
MCT USE ONLY. STUDENT USE PROHIBITED
2-32 Creating Multidimensional Databases
Transact-SQL statements.
The start or end of a stored procedure.
These events are grouped into classes. To capture only the information that you need, you can select
which classes of event to capture in the trace. Examples of event classes for Analysis Services include:
Audit Login
Audit Logout
Query Begin
Query End
Query Subcube
SQL Server Profiler also gives you the ability to select how much information about each kind of event
you capture. Examples of these DataColumns include:
ApplicationName
StartTime
Duration
DatabaseName
NYUserName
When you create a trace for SQL Server Profiler, and select the event classes and DataColumns for the
trace, you can also save the trace as a template. The template is saved as a file with a .tdf extension. This
enables you to rerun the trace at a later time to capture the same kind of information, or transfer the file
to a different server to run the same trace there—such as from a development server to a production
server.
For more information, see SQL Server Profiler in the Microsoft Docs:
Note: Note that SQL Server Profiler has been deprecated for use with the SQL Server
database engine. SQL Server Profiler is not deprecated for use with Analysis Services in SQL Server
2017.
Extended Events
Analysis Services also includes a graphical user interface to create and manage Extended Events
(sometimes called XEvents) within SQL Server for capturing detailed event data. Extended Events can
capture information similar to SQL Server Profiler; however, Extended Events are better because they can
capture more information and perform additional tasks—and they have less overhead on the system. For
example, it is reported that 20,000 events/sec on a 2ghz CPU with 1 GB of RAM takes less than 2 percent
of the CPU. This means that, on a modern server, there should be little impact on performance.
Extended Events are constructed in SQL Server Management Studio (SSMS), in a similar way to SQL Server
Profiler traces, starting by selecting the types of event to capture (these include equivalent SQL Server
Profiler events), and the associated information about the event, called event fields. Extended Event data
can be saved to a file for later analysis, or sent to a memory buffer for real-time monitoring. You can also
use SSMS to output your Extended Event configuration as a script, which can be useful to reproduce the
Extended Event easily on other servers, or to reproduce the capture data after you delete the Extended
Event. Deleting the session object is currently the only way to stop the Extended Event from capturing
data.
For more information, see Monitor Analysis Services with SQL Server Extended Events in Microsoft Docs:
Monitor Analysis Services with SQL Server Extended Events
https://aka.ms/M4gpz3
Most DMV queries are executed by using a SELECT statement on the $System schema with an XML/A
schema rowset. These include:
$system.discover_commands that lists all currently running commands on the server.
$system.discover_sessions that lists all sessions on the server. You can use it to determine the
commands that were executed and in which connections.
MDX: Total cells calculated If this number is high, queries might be performing cell-
by-cell calculations instead of block-oriented calculations.
MDX: Number of calculation covers The total number of active and cached evaluation nodes
built by MDX execution plans. If this number is high,
queries might be performing cell-by-cell calculations
instead of block-oriented calculations.
MDX: Total Sonar subcubes The total number of subcubes that query optimizer
generated. If this number is high, queries might be
performing cell-by-cell calculations instead of block-
oriented calculations.
MDX: Total recomputes The number of cells recomputed due to error. Non-zero
values indicate recalculations to fix errors, again possibly
on a cell-by-cell basis, which are using additional
processor time.
MDX: Total NON EMPTY The number of times an unoptimized NON EMPTY
unoptimized algorithm is used.
MDX: Total NON EMPTY for The total number of times a NON EMPTY algorithm was
calculated members looping over calculated members.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 2-35
Objectives
After completing this lab, you will have:
Password: Pa55w.rd
2. Run Setup.cmd in the D:\Labfiles\Lab02\Starter folder as Administrator. Note that the script may
take up to several minutes to complete.
3. Configure the data source to use the ADVENTUREWORKS\ServiceAcct account with the password
Pa55w.rd.
4. Name the data source Adventure Works Data Warehouse.
o DimCustomer
o DimDate
o DimGeography
o DimProduct
o DimProductCategory
o DimProductSubCategory
o FactInternetSales
o For example, the FactInternetSales table should have the friendly name Internet Sales, and the
DimProductCategory table should have the friendly name Product Category.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 2-37
2. Add a calculation named Full Name to the Customer table. Use the following MDX expression:
CASE
WHEN MiddleName IS NULL THEN
FirstName + ' ' + LastName
ELSE
FirstName + ' ' + MiddleName + ' ' + LastName
END
1. Create a Cube
2. Configure Measures
3. Configure Dimensions
o Order Quantity
2. Change the name of the Total Product Cost measure to Internet Cost.
MCT USE ONLY. STUDENT USE PROHIBITED
2-38 Creating Multidimensional Databases
3. Add the CustomerAlternateKey, Title, FirstName, MiddleName, LastName, and Full Name
attributes from the Customer table to the Customer dimension.
2. Use the Cube Browser in Visual Studio to view the Sales cube, and view the Internet Revenue and
Internet Sales Count measures to the data area by Order Date.Calendar Year.
Created a cube.
2. Create a Dimension
2. Analyze the cube in Excel, and view the Internet Revenue measure by the Sales Territory Group,
Sales Territory Country, and Sales Territory Region attributes of the Sales Territory dimension.
Created a dimension.
Added a dimension to the cube.
Question: In the final exercise, in which you added a dimension to the cube, you edited the
data source view to include the table that the dimension was based on. Why was it not
necessary to also edit the data source object?
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 2-41
Review Question(s)
Question: What should you consider when assigning friendly names for objects in a
multidimensional database?
MCT USE ONLY. STUDENT USE PROHIBITED
MCT USE ONLY. STUDENT USE PROHIBITED
3-1
Module 3
Working with Cubes and Dimensions
Contents:
Module Overview 3-1
Lesson 1: Configuring Dimensions 3-2
Module Overview
Dimensions are a fundamental component of cubes. Facts, or measures, have the values that interest you,
but dimensions provide the business context by which you aggregate these measures. Dimensions
organize your data by category and show results grouped by these categories, such as product, customer,
or month.
Microsoft® SQL Server® Analysis Services dimensions contain attributes that correspond to columns in
dimension tables. These attributes appear as attribute hierarchies and can be organized into user-defined
hierarchies, or defined as parent-child hierarchies, based on columns in the underlying dimension table.
You use hierarchies to organize measures contained in a cube.
Objectives
After completing this module, you will be able to:
Configure dimensions.
Lesson 1
Configuring Dimensions
All Analysis Services dimensions are groups of attributes based on columns from tables or views in a data
source view. Dimensions can exist independently of a cube—you can use dimensions in multiple cubes,
use them multiple times in a single cube, and link them between Analysis Services instances. A database
dimension exists independently of a cube; an instance of a database dimension within a cube is called a
cube dimension.
Lesson Objectives
After completing this lesson, you will be able to:
Define the columns used to connect dimensions to the fact table, to display to users, and to use in
Multidimensional Expressions (MDX) calculations.
Dimension Concepts
Dimensions form the contexts for facts, and define
the aspects of the business by which you
aggregate facts. For example, Product and Time
dimensions might provide context to the Sales
Revenue measure.
The Key attribute is typically the primary key of the dimension table. The Key attribute is the column in
the dimension table that links to the fact table. The Name attribute provides a friendly name for the
dimension, enabling you to display an alternative, more relevant, name than the source table name-to-
end users.
Typically, you arrange attributes into hierarchies that define the drill-down paths through aggregations.
Each layer of the hierarchy is called a level. For example, a Time dimension might have a hierarchy with
Day, Month, and Year levels, but you could define other hierarchies that have attributes such as Week,
Quarter, and Century.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 3-3
By default, every attribute defined within a dimension is part of a two-level hierarchy known as an
attribute hierarchy. The top level is named All; the second is the Leaf level that contains values for each
individual member of the attribute. While they can help in browsing, the data within an attribute
hierarchy can typically be too large and difficult to navigate. Attribute hierarchies are often replaced with
user defined hierarchies where you can define more levels and make data more manageable. For example,
a Date attribute hierarchy might have an All level and a second level containing all the dates within the
dimension. To make this more manageable, you could replace the Date attribute hierarchy with a user-
defined hierarchy named Calendar Year that contains Year, Quarter and Month levels, making the data
easier to navigate.
Analysis Services can add dimension intelligence to some dimensions. For example, time dimensions have
a fixed structure that can be used by Analysis Services. It knows which months are in each quarter, which
days are in each month, and so on.
Use the Translations tab to view and edit the multilanguage translations for the attributes, levels,
and hierarchies.
Use the Browser tab to browse members of each hierarchy in the dimension. You can only browse
members after you have deployed the solution.
Data for a dimension that uses ROLAP is stored in tables used to define the dimension. The ROLAP
storage mode can be used to support large dimensions without duplicating large amounts of data,
but at the expense of query performance. Because the dimension relies directly on the tables in the
data source view used to define the dimension, the ROLAP storage mode also supports real-time
ROLAP.
You can rename an attribute to provide a more meaningful or user-friendly name than the dimension
table. Do this by right-clicking the attribute in the Dimension Structure tab of the Dimension Designer.
You can also set the Name property of the attribute in the Properties window or edit it directly if the
Attributes pane is in the grid view.
Having many attributes for a dimension can confuse users. You can organize attributes into display folders
to simplify browsing. Using folders only affects the way client applications display the dimension and has
no other effects on hierarchies or attributes. After you have created display folders, deploy the solution
and reconnect to see the results on the Browser tab.
Attributes can be used to create hierarchies. For example, a Product dimension might have Product
Category, Product Sub-Category, and Product Name attributes. Hierarchies are covered in more detail
in the next lesson.
Attributes are used to add extra detail to dimension members and do not need to be the basis for a
hierarchy method. Therefore, in the previous example, you might have Product Description and Product
Image attributes. These attributes are not used for a hierarchy, nor to sort or group members, but are
often needed to provide additional detail to dimension members.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 3-5
The ValueColumn is returned by the MDX MemberValue function. This means you can create
calculations based on a value other than the name or key. For example, a time dimension is stored in
a dimension table with one row for each day. The key column is a SMALLINT and the name column is
a CHAR(11) that displays the day, month, and year. The value column contains the date as a
SMALLDATETIME. This allows calculations to use the true date value rather than converting it from
string values, but also enables the key column to hold a smaller value. A key column value occurs in
every row of the fact table, so reducing its size makes the fact table smaller and makes joins between
the fact table and the time dimension faster.
MCT USE ONLY. STUDENT USE PROHIBITED
3-6 Working with Cubes and Dimensions
Lesson 2
Defining Attribute Hierarchies
Hierarchies define the multilevel structure of a dimension, and the relationships between the levels can
affect query and processing performance.
Lesson Objectives
After completing this lesson, you will be able to:
Describe hierarchies.
Distinguish parent-child from balanced hierarchies and describe when each type should be used.
Describe ragged hierarchies and the options you have when configuring them.
Describe considerations for using hierarchies.
Defining relationships between hierarchy levels enables Analysis Services to establish more useful
aggregations that, in turn, increase query performance. This can save memory during processing and
increase performance—which is often important with large or complex cubes.
When arranging attributes into user-defined hierarchies, you define relationships between hierarchy
levels. The levels are connected in a many-to-one or one-to-one relationship, referred to as a natural
relationship. For example, in a Calendar Time hierarchy, a Day level is related to the Month level, the
Month level to the Quarter level, and so on.
A natural hierarchy is composed of attributes where each is a member property of the attribute below. For
example, a Customer Geography hierarchy with the levels Country-Region, State-Province, City, ZIP
Code and Customer, is a natural hierarchy because of the relationships between the attributes. By
contrast, a Marital Status-Gender hierarchy containing the levels Marital Status and Gender is non-
natural, because marital status and gender do not have a hierarchical relationship to each other.
For performance reasons, natural hierarchies are preferred and the Dimension Designer will warn you if
you create a hierarchy that is non-natural. You can ignore this warning when it makes sense to use a non-
natural hierarchy. For example, it is plausible that you would want to drill down from marital status to
gender.
MCT USE ONLY. STUDENT USE PROHIBITED
3-8 Working with Cubes and Dimensions
Parent-Child Hierarchies
A parent-child hierarchy exists when you have a
self-referencing dimension table. For example, an
Employee dimension might have a Manager
attribute. With the exception of the most senior
employee, all other employees have a position in
the hierarchy defined by the identities of their
managers, and those they manage.
You define parent-child hierarchies, not by the order in which attributes are added, but by the
relationships in the dimension table.
Parent-child dimensions are “changing dimensions”, which means that rows can be modified without the
need for processing. They are also the only dimension type you can write-enable.
Parent-child dimensions can be read-only and are classified as changing dimensions because the
hierarchy structure is calculated at run time. This can be beneficial if the dimension records change
frequently, but there are performance considerations. Because the parent-child hierarchy is calculated at
run time, no aggregates are calculated when the cube is processed. For example, the total sales for each
sales manager, and every employee who reports to them, are only calculated when the query is run.
This trade-off between a versatile changing dimension and query performance must be considered and,
ideally, the effects tested. If you do not want to use a parent-child dimension, you can create traditional
dimensions. For example, an employee could list their level managers up through the hierarchy. This
would allow the dimension aggregates to be calculated during processing, but with a loss of flexibility.
You should also consider what to do with non-leaf data. In the example used here, the sales manager can
also make sales. If this is the case, and you have data in the fact table associated to non-leaf members,
you must change the dimension's Members With Data property to non-leaf data visible or non-leaf data
hidden. Otherwise, processing the cube fails. If you use non-leaf data visible, the parent—in this case the
sales manager—will also appear in the level below and seem to report to himself or herself. If you use
non-leaf data hidden, the sales manager will not appear in the level below and, should you perform a sum
on all employee sales, the value will not include the sales manager.
For more information on parent-child dimensions, see Parent-Child Dimension in Microsoft Docs:
Parent-Child Dimension
http://aka.ms/Whhuwv
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 3-9
Ragged Hierarchies
To the user, ragged and parent-child hierarchies
often seem similar. They both have a different
number of levels in separate parts of the hierarchy,
but these are formed from different dimension
table columns, rather than from a self-referencing
relationship. For example, in a Location dimension,
you might have Location, Region, State and
Country levels, but the State level might only be
used for the United States, Canada, and Australia.
All other countries might skip the State level.
OnlyChildWithParentName – this value hides a level member when it is an only child with the same
name as its parent.
NoName – this value hides a level member when it is null or a zero-length string.
ParentName – this value hides a level member when it has the same name as its parent.
You can use a ragged hierarchy as an alternative to a parent-child hierarchy. The aggregates are
calculated when the cube is processed, improving query performance. A ragged hierarchy is not, however,
a changing dimension, so the flexibility of parent-child dimensions is lost.
Using Hierarchies
You typically create user-defined hierarchies to
allow users to drill up and drill down through the
data, and to allow Analysis Services to create
meaningful aggregations of the measures.
Hiding and disabling attribute hierarchies can improve performance and focus data for users. For
example:
If you set the AttributeHierarchyEnabled property to False, the hierarchy is disabled and Analysis
Services only creates the attribute hierarchy as a member property. This is useful if the attribute is
providing detail, but you do not want to use it as a level for aggregation.
If you set the AttributeHierarchyVisible property to False, the attribute is only visible from user-
defined hierarchies. This is useful if there are large numbers of distinct values in the attribute
hierarchy that would cause confusion and not add any benefit.
Attribute Relationships
Attributes are always related directly or indirectly
to the key attribute. Initially all attributes are
directly related to the key attribute and this might
be the relationship you require. For example, a
Product dimension contains ProductKey, Name,
Weight, ProductionCost, and
RecommendedSalesCost. In this dimension, you
do not group by any attribute, and you only need
the All level and one other level containing every
member.
In most dimensions, there are levels with
relationships between them. For example, a
Customer dimension containing attributes for CustomerKey, Name, Address, City, Region, and
Country. Name and Address attributes relate directly to the CustomerKey, but relationships have to be
created for the other attributes. You form a relationship, from Country to Region, from Region to City,
and from City to CustomerKey; this supports levels within the data and is used to create aggregates to
improve query performance.
Attribute relationships are straightforward to create, using the Attribute Relationships tab of the
Dimension Designer. You can right-click a blank space to create a dimension relationship, and then
choose the source and related attributes. Each source attribute can only have one related attribute. For
example, a month can only have one quarter; although a quarter can have several months. In this
relationship, the month is the source attribute and the quarter is the related attribute.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 3-11
Demonstration Steps
Create a Parent-Child Hierarchy
1. Ensure that the 20768C-MIA-DC and 20768C-MIA-SQL virtual machines are both running, and log
on to 20768C-MIA-SQL as ADVENTUREWORKS\Student with the password Pa55w.rd. In the
D:\Demofiles\Mod03 folder, run Setup.cmd as Administrator.
3. In Solution Explorer, expand Data Source Views and double-click Adventure Works Demo
DSV.dsv.
4. On the Data Source View menu, click Add/Remove Tables. In the Add/Remove Tables dialog box,
add the DimEmployee table to the Included objects list and click OK.
5. In the data source view diagram, right-click the DimEmployee table and click New Named
Calculation. In the Create Named Calculation dialog box, create a named calculation with the
column name Full Name and the expression [FirstName] + ' ' + [LastName], and then click OK.
o Click Next.
10. On the Select Related Tables page, clear the Sales Territory check box, and click Next.
12. On the Completing the Wizard page, in the Name box, type Employee and click Finish.
1. In the Employee.dim Dimension Designer, on the Dimension Structure tab, in the Attributes
section, click Parent Employee Key.
2. In the Properties pane, note that the Usage property for this attribute has been set to Parent.
7. In the next blank Name cell, type Junior Employee then click OK.
9. In the Attributes pane, click Employee dimension, and set the UnknownMember property to None.
Select the Employee Key attribute, expand its KeyColumns property, expand the
DimEmployee.EmployeeKey column, and set the NullProcessing property to Automatic.
10. In Solution Explorer, right-click Demo and click Deploy. If prompted for a password, type Pa55w.rd
for the ADVENTUREWORKS\ServiceAcct user, and then click OK.
11. When deployment has completed, in the Employee.dim Dimension Designer, in the Browser tab,
expand the employees in the hierarchy. Note that, when you select an employee, the hierarchy level
name is displayed at the top of the browser area.
Question: Excluding organizational charts, where else might you use parent-child
hierarchies?
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 3-13
Lesson 3
Implementing Sorting and Grouping for Attributes
A cube can be difficult to navigate if it has numerous attributes and attribute hierarchies. In Analysis
Services, you can sort by the member name, the member key, or by a related attribute. You can also
group attributes. A member group is a system-generated collection of consecutive dimension members.
To improve usability in Analysis Services, attribute members can be formed into member groups through
a process called discretization.
Lesson Objectives
This lesson describes sorting and grouping attributes. After completing this lesson, you will be able to:
Sort attributes.
Group attributes.
Sorting Attributes
You can choose any attribute by which to sort a
hierarchy. This attribute can be the key, the name,
or any other secondary attribute in the dimension
table.
If you order by name, Analysis Services will
put the members in alphanumeric order.
You can also order by a secondary attribute, which could be a standard or calculated column created
in the data source view. For example, you might want to sort a Course dimension in which the course
name runs from “Course 1” to “Course 450”. The course key is provided by the course vendor and is
not a relevant sort order. If you sort by name, the order is “Course 1”, “Course 11”, “Course 111”,
“Course 2”, “Course 22”, and so on. Therefore, you create a new column in the dimension table with
the course number as a numeric field. This can then be used to sort data in the correct order.
MCT USE ONLY. STUDENT USE PROHIBITED
3-14 Working with Cubes and Dimensions
Grouping Attributes
Some hierarchies have no natural levels, so
Analysis Services only creates All and Leaf levels.
This can make the cube difficult to navigate if
there are many members in the hierarchy. You can
use grouping to organize members into groups to
simplify cube browsing. For example, customers
could be grouped into income brackets rather
than showing individual incomes. You can then
drill down into the groups to show the detail as
needed.
To specify the number of groups, you must set the DiscretizationBucketCount property. The default is
based on the square root of the number of distinct members.
To specify a naming template, you must set the Format option for the NameColumn property of an
attribute. The default-naming template displays the first and last group members in the format “January –
March”. You can create your own naming templates to modify group names. Because naming templates
are based on the members they contain, the names of groups can change as members are added or
removed.
Demonstration Steps
Use Sorting
1. In Visual Studio, in Solution Explorer, expand Dimensions, and then double-click Dim Date.dim.
2. In the Browser tab, ensure Date is selected in the Hierarchy drop-down and explore the Date
dimension, noting that the month numbers are not in numeric order.
3. On the Dimension Structure tab, in the Attributes section, click Month Number Of Year.
5. On the Dimension menu, click Process. If you receive a message about out-of-date content, click
Yes, and then click Yes to confirm you want to continue with deployment. If you are prompted for a
password, type Pa55w.rd and click OK.
6. In the Process Dimension – Dim Date dialog, click Run, and when the build process has completed,
in the Process Progress dialog, click Close.
8. In the Browser tab, ensure Date is selected in the Hierarchy menu and then, on the Dimension
menu, click Reconnect.
9. Browse the Date dimension noting the month numbers are now sorted correctly.
Use Grouping
2. On the Browser tab, ensure Resellers is selected in the Hierarchy drop-down, and then browse the
Resellers hierarchy, noting the data is presented as one long list of reseller IDs. To enable simpler
location of a specific retailer ID, these will be grouped.
3. On the Dimension Structure tab, in the Attributes pane, click Reseller Key, in the Properties pane
change the DiscretizationMethod property to Automatic, and then change the
DiscretizationBucketCount to 10.
4. On the Dimension menu, click Process. If you receive a message about out-of-date content, click
Yes, and then click Yes to confirm you want to continue with deployment. If you are prompted for a
password, type Pa55w.rd and click OK.
5. In the Process Dimension – Dim Reseller dialog, click Run, and when the build process has
completed, in the Process Progress dialog, click Close.
8. Browse the Reseller dimension noting Reseller IDs are now grouped.
Question: When might you need to use a secondary attribute for sorting data?
MCT USE ONLY. STUDENT USE PROHIBITED
3-16 Working with Cubes and Dimensions
Lesson 4
Slowly Changing Dimensions
In many dimension tables, the stored data never changes. For example, if a sale takes place in Japan, that
location is fixed. However, in other dimensions, some attributes may change. For example, the sales
representative who made that sale in Japan might move departments, offices, or work for a different
manager. With changing dimensions like this one, you should consider carefully how a cube stores
attribute values. For example, is it important to store old versions of attributes? In this lesson, you will see
how to design and implement dimensions that might change over time.
Lesson Objectives
At the end of this lesson, you will be able to:
Explain the operations that the Slowly Changing Dimension Transformation can perform on incoming
rows during a data load.
Use the Slowly Changing Dimension Wizard to configure the Slowly Changing Dimension
Transformation.
Any dimension that is subject to such change is termed a Slowly Changing Dimension (SCD). You can take
three different approaches to their design:
Type 1. These changes are the simplest type of SCD to implement. Attribute values are updated
directly in the existing dimension table row and no history is maintained. This makes Type 1 changes
suitable for attributes that are used to provide drill-through details, but unsuitable for analytical
slicers or hierarchy members where historic comparisons must reflect the attribute values as they were
at the time of the fact event.
Type 2. These changes involve the creation of a fresh version of the dimension entity in the form of a
new row. Typically, a bit column in the dimension table is used as a flag to indicate which version of
the dimension row is the current one. Additionally, datetime columns are often used to indicate the
start and end of the period for which a version of the row was (or is) current. Maintaining start and
end dates makes it easier to assign the appropriate foreign key value to fact rows as they are loaded
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 3-17
so that they are related to the version of the dimension entity that was current at the time the fact
occurred.
Type 3. These changes are rarely used. In a Type 3 change, the previous value (or sometimes a
complete history of previous values) is maintained in the dimension table row. This requires
modifying the dimension table schema to accommodate new values for each tracked attribute, and
can result in a complex dimension table that is difficult to manage.
Note: Type 3 SCDs are rarely used and not supported by the Slowly Changing Dimension
Transformation or the Slowly Changing Dimension Wizard.
The Slowly Changing Dimension Transformation has a workflow of operations that includes the following:
A path to insert a new record for dimension members where a historic attribute has been modified.
This path also updates the current record indicator. This is an implementation of a Type 2 SCD.
A path to insert minimal records for inferred members in the source data.
For more information, see Slowly Changing Dimension Transformation in Microsoft Docs:
Best Practice: When you design and select key columns in dimension tables, ensure that
they are unchanging. For example, in a product database, a product number or part number is
often used as a primary key because it is unique to the product. However, a product number or
part number can change and so should be an attribute of an SCD. If you want to store both old
and new product numbers for later analysis, you need a Type 2 SCD and two rows with different
product numbers. Ensure that the Slowly Changing Dimension Transformation can identify these
records as relating to the same product by using a different identity value for the primary key in
the dimension table.
Question: You are implementing a Customer dimension in a cube. Should you implement
this as a fixed dimension, a Type 1 SCD, or a Type 2 SCD?
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 3-19
Objectives
After completing this lab, you will be able to:
Password: Pa55w.rd
2. Open the Customer dimension in the Dimension Designer and note that many attributes have been
added to allow business users to aggregate measures in many different ways. However, users have
complained that some of these attributes are unnecessary and that they should be removed to make
browsing the cube simpler.
3. Delete the Commute Distance, Number Cars Owned, and Number Children At Home attributes
from the Customer dimension.
4. Similar feedback has been received about the Product dimension, so delete the Days To
Manufacture and Safety Stock Level attributes from the Product dimension.
MCT USE ONLY. STUDENT USE PROHIBITED
3-20 Working with Cubes and Dimensions
o Date: Month
Results: After this exercise, unused attributes in the Customer and Product dimensions will have been
removed; time intelligence will have been added to the Date dimension.
o Category
o Subcategory
o Product
4. Set the AttributeHierarchyVisible property of all attributes to False so that the Categorized
Products hierarchy is the only way to browse the Product dimension.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 3-21
o If you are prompted for impersonation credentials, enter the password Pa55w.rd for the
ADVENTUREWORKS\ServiceAcct account.
o Gender
o Marital Status
Note: if a warning is displayed, saying that attribute relationships do not exist and that performance
may be decreased, ignore it. You will see how to use attribute relationships to optimize a hierarchy
later in this lab.
o If you are prompted for impersonation credentials, enter the password Pa55w.rd for the
ADVENTUREWORKS\ServiceAcct account.
3. Browse the Gender-Marital Status hierarchy in the dimension browser. Note that gender can be F,
M, or Unknown, and that marital status can be M or S.
1. In the Dimension Designer for the Date dimension, modify the Calendar Semester attribute so that a
semester is uniquely identified by both the calendar year and semester, but displayed using only the
calendar semester value. To do this:
o In the properties for the Calendar Semester attribute, set the KeyColumns property so that the
key columns are CalendarYear followed by CalendarSemester.
o Set the NameColumn property so that the source column value is CalendarSemester.
o Set the ValueColumn property so that the source column value is CalendarSemester.
2. Modify the Calendar Quarter attribute so that a quarter is uniquely identified by both the calendar
year and the calendar quarter, but displayed using only the calendar quarter value. To do this:
o In the properties of the Calendar Quarter attribute, set the KeyColumns property so that the
key columns are CalendarYear followed by CalendarQuarter.
o Set the NameColumn property so that the source column value is CalendarQuarter.
o Set the ValueColumn property so that the source column value is CalendarQuarter.
MCT USE ONLY. STUDENT USE PROHIBITED
3-22 Working with Cubes and Dimensions
3. Modify the Month attribute so that a month is uniquely identified by both the calendar year and the
month number of year, but displayed using the month name value. To do this:
o Set the KeyColumns property so that the key columns are Calendar Year followed by
MonthNumberOfYear.
o Set the NameColumn property so that the source column value is EnglishMonthName.
o Set the ValueColumn property so that the source column value is EnglishMonthName.
Create a Hierarchy
1. Modify the Date dimension structure to create a new hierarchy named Calendar Date that contains
the following levels:
o Calendar Year
o Calendar Semester
o Calendar Quarter
o Month
o Full Date Alternate Key (renamed to Day)
2. Set the AttributeHierarchyVisible property of the attributes that are included in the Calendar Date
hierarchy to False so that they can only be used by browsing the hierarchy.
3. Process the dimension:
o If you are prompted for impersonation credentials, enter the password Pa55w.rd for the
ADVENTUREWORKS\ServiceAcct account.
Results: After this exercise, you should have created a Categorized Products hierarchy and a Gender-
Marital Status hierarchy.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 3-23
2. Modify the Month attribute to set its OrderBy property to Key. The key for this attribute consists of
the Calendar Year and Month Number of Year columns, so sorting by key should ensure that
months are displayed in chronological order.
3. Reprocess the dimension and verify that the months are now displayed in the correct order.
o If you are prompted for impersonation credentials, enter the password Pa55w.rd for the
ADVENTUREWORKS\ServiceAcct account.
3. Browse the dimension and view the Yearly Income hierarchy. Note that this hierarchy has no
structure.
o DiscretizationMethod: Automatic
o DiscretizationBucketCount: 5
o OrderBy: Key
5. Reprocess the dimension and browse the Yearly Income hierarchy to verify that the values are now
grouped into five income bands, with a sixth band for customers whose income is unknown.
Microsoft SQL Server Analysis Services dimensions contain attributes that correspond to columns in
dimension tables. These attributes appear as attribute hierarchies and can be organized into user-defined
hierarchies, or defined as parent-child hierarchies, based on columns in the underlying dimension table.
Hierarchies are used to organize measures contained in a cube.
MCT USE ONLY. STUDENT USE PROHIBITED
4-1
Module 4
Working with Measures and Measure Groups
Contents:
Module Overview 4-1
Lesson 1: Working with Measures 4-2
Module Overview
Measures and measure groups specify the data values that your cube can aggregate to provide summary
values for analysis. This module describes measures and measure groups. It also explains how you can use
them to define fact tables and associate dimensions with measures.
Objectives
After completing this module, you will be able to:
Configure measures.
Configure measure groups.
MCT USE ONLY. STUDENT USE PROHIBITED
4-2 Working with Measures and Measure Groups
Lesson 1
Working with Measures
This lesson explains how to work with measures, including configuring how measures are displayed and
aggregated, and information about measure properties.
Lesson Objectives
After completing this lesson, you will be able to:
Introducing Measures
A measure represents a column that contains
quantifiable data, usually numeric, that you can
aggregate. Typically, measures occur as a column
in the fact table and are the values that the
business user finds most interesting. Measures are
organized into measure groups and are distinct
from dimensions.
To provide specific aggregated details, you might select a store from the stores dimension, a product from
the products dimension, a day from the time dimension, a salesperson from the salesperson dimension
and, from the measures dimension, either sales units or sales value.
You create measures as part of the Cube Wizard or on the Cube Structure tab of the Cube Designer.
Calculated Measures
You can create calculated measures based on other measures in the fact table. You use a “measure
expression” to define the value of a calculated measure, based on a fact table column as modified by a
Multidimensional Expressions (MDX) statement. You should consider the performance impact of using
calculated measures because they are worked out at run time. If a calculated measure is infrequently used
and is quite simple—for example, the sum of two measures—it will have little performance impact on
queries, but might reduce processing times. If a measure is frequently used and involves a complex
calculation, it might cause unacceptable query times.
You can use attribute columns from dimension tables to define measures. However, these are typically
semiadditive or nonadditive, which means that they cannot be fully aggregated across all dimensions. You
will learn more about semiadditive and nonadditive measures later in this lesson.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 4-3
Aggregation Function
The aggregation behavior of each measure is determined by the aggregation function that is associated
with the measure. You will learn more about aggregations later in this lesson.
Granularity
You should consider the granularity of measures, which refers to how specific something is. For example,
an hour is more granular than a day, and a day is more granular than a week. You cannot make a measure
more granular than the highest level of granularity in the dimension tables, but you can make it less so.
For example, if you have a time dimension that stores data at the levels of day, month, quarter, and year,
you cannot store sales measures at a granularity of hours, but you can store them at a granularity of
months. As you will see later in this module, you can specify the granularity of a measure group in relation
to a specific dimension.
Properties of Measures
Measures have properties that enable you to
define how the measures function and to control
how the measures appear to users. You can
configure measures on the Cube Structure tab of
the Cube Designer.
The data type of the column in the underlying fact table to which the measure is bound.
The column in the data source view to which the measure is bound.
The folder in which the measure will appear when users connect to the cube.
The display format of the measure.
The unique identifier (ID) of the measure; note that this property is read-only.
Standard 123456.78
Currency $123,456.78
0 123457
$#,#.00 $123,456.78
#,#0.000 123,456.789
The last two rows in the above table show user-defined formats that have been entered, rather than
chosen from the list. In this example, the regional setting in Control Panel on the client computer is
English (United States).
Note: The currency format will display the currency symbol of the client’s location.
Therefore, the value may be incorrect and, in most scenarios, it is more appropriate to employ a
user-defined FormatString property.
Aggregation Functions
Aggregation functions determine the function that
is used to aggregate the measure. Before applying
an aggregation function to a measure, you should
consider how the measure will aggregate along all
of the dimensions in the measure group that
contains the measure. This is called the additivity
of the measure, of which there are three types:
the measure, without restriction. Additive measures are the most commonly used in SQL Server
Analysis Services.
A semiadditive measure. A semiadditive measure can be aggregated along some, but not all,
dimensions that are included in the measure group that contains the measure. An example of a
semiadditive measure is a units-in-stock value for warehouse goods. This would be additive by region
to reveal the total units in stock, but would not be additive by time because, if you add last week's
stock to this week's stock, the resulting value could be twice as much stock as you actually have.
A nonadditive measure. A nonadditive measure cannot be aggregated along any dimension in the
measure group that contains the measure. Instead, you must individually calculate the measure for
each cube cell that represents the measure. For example, a calculated measure that returns a
percentage, such as profit margin, cannot be aggregated from the percentage values of child
members in any dimension.
By default, the AggregateFunction property is set to Sum. You can change the AggregateFunction
property for a measure in the Properties window of the measure in the Cube Designer. All aggregation
functions are additive, semiadditive, or nonadditive.
The Sum function. This is additive and calculates the sum of all values for every child member. Sum is
the default function.
The Count function. This is additive and calculates the quantity of child members.
The Min function. This is semiadditive and calculates the lowest value for each child member.
The Max function. This is semiadditive and calculates the highest value for each child member.
The DistinctCount function. This is nonadditive and calculates the count of all unique child members.
The None function. This is nonadditive, performs no aggregation, and supplies values directly from
the fact table.
The AverageOfChildren function. This calculates the average of values for all non-empty child
members.
The FirstChild function. This retrieves the value of the first child member.
The LastChild function. This retrieves the value of the last child member.
The FirstNonEmpty function. This retrieves the value of the first non-empty child member.
The LastNonEmpty function. This retrieves the value of the last non-empty child member.
Question: Give an example of scenarios where you would use an additive measure, a
semiadditive measure, and a nonadditive measure.
MCT USE ONLY. STUDENT USE PROHIBITED
4-6 Working with Measures and Measure Groups
Lesson 2
Working with Measure Groups
You use measure groups to associate dimensions with measures. Properties that you can configure at the
measure group level include:
Partitions. These are containers for a portion of the measure group data.
Aggregations. These are precalculated summaries of data from leaf cells that improve query
response times.
Lesson Objectives
After completing this lesson, you will be able to:
How measure aggregations should be stored. For example, you might optimize cube performance by
storing preaggregated values for some or all of the possible aggregations for measures in a measure
group and its related dimensions.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 4-7
When you create a cube by using the Cube Wizard in SQL Server Data Tools, you define one or more
measure groups. By default, the Cube Wizard will create one measure group per fact table. You can add
and configure measure groups for existing cubes by using the Cube Designer.
Note: The DistinctCount aggregation looks for the number of distinct values in a fact
table column. For example, you might want to know how many sales staff sold a particular
product. This query is very resource-intensive, so SQL Server Analysis Services creates a separate
group for DistinctCount measures.
EstimatedRows. This specifies the estimated number of rows in the fact table. You use this when you
design aggregations. The value is static and should be kept approximately accurate, either manually
or by updating the count in the Aggregation Design Wizard.
EstimatedSize. This specifies the estimated byte size of the measure group. You use this when you
design aggregations.
IgnoreUnrelatedDimensions. This determines the output when dimensions are used that are not
related to the measure group. If this is set to True, the output will show the top-level aggregation for
the dimension. If this is set to False, the output will be blank for the dimension.
ProactiveCaching. This defines how data is reprocessed when there are changes in the underlying
data source. You will learn more about proactive caching later in this module.
ProcessingMode. This indicates whether indexing and aggregating should occur during or after
processing. You can use lazy processing to enable SQL Server Analysis Services to choose a time when
workload is low, but you will not know when the indexing workload will occur, or when indexing has
taken place and queries are at peak performance.
MCT USE ONLY. STUDENT USE PROHIBITED
4-8 Working with Measures and Measure Groups
ProcessingPriority. This determines the processing priority of the cube during background
operations, such as lazy aggregations and indexing.
StorageLocation. This is the file system storage location for the measure group. If none is specified,
the location is inherited from the cube that contains the measure group.
StorageMode. This determines the storage mode for the measure group. You will learn more about
storage modes later in this module.
Relationship Types
There are four types of relationship between dimension and fact tables:
Regular. A regular dimension relationship represents the relationship between dimension tables and
a fact table in a traditional star schema design. The key column for the dimension is joined directly to
the fact table.
Reference. A reference dimension relationship represents the relationship between dimension tables
and a fact table in a snowflake schema design. The key column for the dimension is joined indirectly
to the fact table.
Fact. If a dimension consists entirely of values in a fact table and does not have a separate dimension
table, it has a fact dimension relationship.
Many-to-many. Typically, every dimension member relates to many facts, but all of those relate to
just one member in each dimension. This is a standard one-to-many relationship. You might also have
many-to-many relationships when, for example, a customer has multiple reasons for making a
purchase, each reason having numerous customers. In a relational database, this relationship would
be achieved through an intermediate table. In SQL Server Analysis Services, a similar technique is used
by joining the dimension to an intermediate fact table, by joining the intermediate fact table to an
intermediate dimension, and by joining the intermediate dimension to the fact table.
Note: Foreign-key relationships between all tables that are involved in a many-to-many
relationship must exist in the underlying data source view.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 4-9
Granularity
By default, a measure group will use the highest level of granularity. For example, measure groups are
often related to a date dimension, in which the highest level of granularity is day level. This is suitable for
some measure groups, but in other measure groups, the data in the fact table might not have that level of
detail, in which case you will need to change the granularity to another level, such as month or quarter. To
change the granularity of a particular relationship, you can use the Granularity attribute list.
Demonstration Steps
1. Ensure that the 20768C-MIA-DC and 20768C-MIA-SQL virtual machines are both running, and then
log on to 20768C-MIA-SQL as ADVENTUREWORKS\Student with the password Pa55w.rd.
3. Start SQL Server Data Tools, and then open Demo.sln in the D:\Demofiles\Mod04 folder.
4. On the Build menu, click Deploy Solution. If you are prompted, specify the user name
ADVENTUREWORKS\ServiceAcct and the password Pa55w.rd.
5. Wait for the Deployment Completed Successfully message in the Deployment Progress – Demo
window, and then close the Deployment Progress – Demo window.
6. In Solution Explorer, double-click SalesDemo.cube, and on the Browser tab, expand Measures,
expand Reseller Sales, and then drag the Revenue measure to the query results area. Expand the
Geography dimension, and then drag Country-Region to the left of the Revenue value. Note that
the values for each region are the same. The aggregation is incorrect.
7. In Solution Explorer, expand dimensions, right-click Geography.dim, and then click View Designer.
Note that this dimension is based on the Geography table and has a Country-Region attribute.
8. In Solution Explorer, right-click Reseller.dim, and then click View Designer. Note that this dimension
is based on the DimReseller table, which includes a GeographyKey attribute that relates it to the
Geography table.
9. Click the tab for the SalesDemo cube, and on the Cube Structure tab, in the Data Source View pane,
note that there is no direct relationship between the Reseller Sales fact table and the Geography
dimension table.
10. On the Dimension Usage tab, click the intersection of the Reseller Sales measure group and the
Geography dimension, and then click the ellipsis (…) button.
13. In the Reference dimension attribute list, select Geography Key, in the Intermediate dimension
attribute list, select Geography Key, and then click OK.
14. On the Dimension Usage tab, in the Dimensions list, right-click Geography, and then click
Rename.
15. Change the name of this cube dimension to Reseller Geography, and then press Enter to make this
name change take effect.
MCT USE ONLY. STUDENT USE PROHIBITED
4-10 Working with Measures and Measure Groups
16. On the Build menu, click Deploy Solution. If you are prompted, specify the user name
ADVENTUREWORKS\ServiceAcct and the password Pa55w.rd.
17. Wait for the Deployment Completed Successfully message in the Deployment Progress – Demo
window, and then close the Deployment Progress – Demo window.
18. On the Browser tab for the SalesDemo cube, click the Reconnect button.
19. Right-click the query results area, and then click Clear Grid.
20. Expand Measures, expand Reseller Sales, and then drag the Revenue measure to the query results
area. Expand the Reseller Geography dimension, and then drag Country-Region to the left of the
Revenue value. Note that the values for each region are now correct.
Aggregations
Aggregations are precalculated summaries of leaf
cell data that improve query response time by
preparing the answers before the questions are
asked.
Aggregations give multidimensional cubes their performance benefits. They precalculate the answer to
queries at processing time so that, when the query is run, performance is hugely improved. If you consider
that a query might have to aggregate thousands of individual values to produce one summarized output
value, of which there may be hundreds, it becomes clear that precalculating these results will have
enormous benefits.
It might seem appropriate to precalculate every possible result, but some aggregations provide little
benefit. SQL Server Analysis Services incorporates a sophisticated algorithm to select aggregations for
precalculation so that other aggregations can be quickly computed from the precalculated values. For
example, if SQL Server Analysis Services stores aggregates at a month level, it takes little processing to
generate quarter data at query run time. The Aggregation Design Wizard gives options for you to specify
storage and percentage constraints on the algorithm to achieve a satisfactory trade-off between query
response time and storage requirements. Typically, there is little benefit from preprocessing more than 30
percent of aggregations.
After using the Aggregation Design Wizard, you can further improve aggregation design for your specific
system by using SQL Server Analysis Services with normal workloads for some time, and then running the
Usage-Based Optimization Wizard. This wizard is almost identical to the Aggregation Design Wizard, but
bases optimization on queries that are submitted to SQL Server Analysis Services and should, therefore,
give better query response with less processing time.
To use the Aggregation Design Wizard or the Usage-Based Optimization Wizard for a measure group, in
the Cube Designer, on the Aggregations tab, right-click the measure, and then click Design
Aggregations or Usage Based Optimization.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 4-11
Partitions
A partition is a container for all, or a portion, of
the measure group data. When a measure group is
created, it will have one partition. You can then
add further partitions to the measure group.
Partitions enable the source data and aggregate data of a cube to be distributed across multiple hard
drives and among multiple server computers. You can use this to greatly improve performance on
large cubes.
Note: When you incrementally update a partition, a temporary partition is created that has
an identical structure to the source partition. The temporary partition is then merged with the
original partition. There are possible scenarios that could affect data integrity when you
incrementally update individual partitions. For example, if you had a different partition for each
month, and the date of a record in the source data changed to or from the most recent month,
the data may either disappear or be duplicated. You should consider these scenarios and plan
accordingly.
Basic information that includes the name of the partition, in addition to the storage and processing
modes.
An aggregation design that is a collection of aggregation definitions that you can share across
multiple partitions.
In a horizontally partitioned measure group, each partition is based on a separate fact table that can be
from different data sources.
A vertically partitioned measure group is based on a single table, with each partition centered on a source
system query that filters data for the partition.
MCT USE ONLY. STUDENT USE PROHIBITED
4-12 Working with Measures and Measure Groups
ROLAP
ROLAP storage stores the aggregations in indexed
relational data, along with the source data. It does
not use multidimensional storage, so ROLAP data
is slower to query and process than MOLAP or
HOLAP, but it enables real-time access to data and
uses less storage space.
MOLAP
MOLAP is the most commonly used storage mode. It stores both the aggregations and a copy of the
source data in the multidimensional cube. MOLAP gives the greatest performance, but requires more
storage space due to the duplication. There is latency when you use MOLAP storage because the cube
data is refreshed only when the cube is processed, so changes from the data source are only updated
periodically.
You can use proactive caching with MOLAP storage. When proactive caching is used, the server is notified
when changes are made to the data source, and then the changes are incorporated. While the cache is
rebuilt with new data, you can choose to send queries to ROLAP data, which is up to date, but slower, or
to the original MOLAP storage, which is faster, but will not have the new data.
If you only need daily updates, you can set processing to occur every 24 hours. You can schedule
processing for when the cube is rarely used, for example, at night—however, some systems are in use 24
hours a day, seven days a week.
For maximum performance, you can use MOLAP without proactive caching or scheduling. This is best
suited to cubes that do not need the most up-to-date data. When objects are updated, some downtime
will be required. You can minimize this by processing the cube to a staging server, and using database
synchronization to copy the processed data to the production server.
HOLAP
HOLAP storage stores aggregations in the multidimensional cube and leaves source data in the relational
database. This can provide a good compromise when leaf-level data is rarely accessed. If leaf-level data is
frequently accessed, MOLAP would provide improved performance.
Note: You should also consider tabular data model storage, particularly as an alternative to
ROLAP and HOLAP. The tabular data model is covered in more detail in Module 7 of this course,
“Implementing a Tabular Data Model by Using Analysis Services.”
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 4-13
Storage Settings
You can configure storage at partition level by using the Storage Settings dialog box. This enables you to
maximize efficiency by using configurations that are most suitable for each partition.
The Storage Settings dialog box contains the following standard storage configurations, which are
combinations of storage mode and caching options:
Low Latency MOLAP. Use to set to MOLAP storage mode with proactive caching and a latency
target of 30 minutes after first change—queries revert to ROLAP during update.
Medium Latency MOLAP. Use to set to MOLAP storage mode with proactive caching and a latency
target of four hours after first change—queries revert to ROLAP during update.
Automatic MOLAP. Use to set to MOLAP storage mode with proactive caching and a latency target
of two hours after first change—during update, queries use MOLAP data that was cached before
update started.
Scheduled MOLAP. Use to set to MOLAP storage mode with updates scheduled every 24 hours.
To configure storage for an existing partition, in the Cube Designer, on the Partitions tab, expand
the measure group, right-click the partition, and then click Storage Settings. This displays the
Storage Settings dialog box for the selected partition.
To configure default storage settings for new partitions that are added to a measure group, in the
Cube Designer, on the Partitions tab, expand the measure group, and then click the Storage
Settings link for that measure group. This displays the Storage Settings dialog box for the selected
measure group.
To configure default storage settings for new measure groups that are added to a cube, in the Cube
Designer, on the Cube Structure tab, in either the Measures or Dimensions pane, click the cube
object. In the Properties window, click the ellipsis (…) button for the ProactiveCaching property
setting. This displays the Storage Settings dialog box for the selected cube.
MCT USE ONLY. STUDENT USE PROHIBITED
4-14 Working with Measures and Measure Groups
MOLAP
Automatic MOLAP
Users have also requested that you remove some measures that they do not need to use when analyzing
data, and also ensure that the remaining measures are clearly named.
Users specifically need to analyze reseller sales by product, so you must ensure that the cube supports the
required relationship between the new reseller sales measure group and the Product dimension.
Finally, the data center administrator is concerned about the disk space that the cube uses, but your users
are worried about performance when they analyze Internet sales. You must optimize the storage and
aggregations of the cube to balance these concerns.
Objectives
After completing this lab, you will be able to:
Configure measures.
Password: Pa55w.rd
2. In the Adventure Works DSV data source view, add the FactResellerSales table, together with all
related tables.
3. In the Sales cube, add a new measure group named Reseller Sales based on the FactResellerSales
table.
4. Review the names of the measures in the Reseller Sales measure group. Note that, when the
Reseller Sales measure group was set up, measures were created for all of the numerical fields in the
FactResellerSales table.
o Revision Number
o Unit Price
o Extended Amount
o Tax Amt
o Freight
Tip: click the Show Measures Grid icon to view all of the measures in the cube as a grid. In this view,
you can select several measures at the same time by holding down the Ctrl key.
2. Rename the following measures:
Results: After this exercise, you should have created a new measure group for the FactResellerSales
table, removed unrequired measures, and renamed measures.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 4-17
2. Create a Dimension
2. Browse the Sales cube and review the measures and dimensions that are available by selecting each
measure group:
o When the Internet Sales measure group is selected, the Customer dimension should be listed.
o When the Reseller Sales measure group is selected, there is no Customer dimension, because
reseller sales are sold to resellers, which are defined in a different dimension table.
o Include only the Reseller Key, Business Type, and Reseller Name attributes.
2. On the Dimension Usage tab of the Cube Designer for the Sales cube, verify that a regular
relationship has been defined between the Reseller Sales measure group and the Reseller
dimension.
3. Deploy the Adventure Works OLAP solution, and then browse the cube, verifying that you can view
reseller revenue by attributes of the Reseller dimension.
Results: After this exercise, you should have added a Reseller dimension that uses a regular relationship
with the Reseller Sales measure group to enable you to analyze reseller sales data.
MCT USE ONLY. STUDENT USE PROHIBITED
4-18 Working with Measures and Measure Groups
2. Design Aggregations
2. Configure proactive caching for the Reseller Sales measure group in the Sales cube. Specify that the
Automatic MOLAP setting should be used.
4. Use SQL Server Management Studio to connect to the localhost instance of SQL Server Analysis
Services, and then verify that the aggregation designs were deployed by using the Sales cube in the
Adventure Works OLAP database.
Results: After this exercise, you should have configured proactive caching and defined the storage mode
aggregations for the Internet Sales and Reseller Sales measure groups.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 4-19
Module 5
Introduction to MDX
Contents:
Module Overview 5-1
Lesson 1: MDX Fundamentals 5-2
Module Overview
When you have a relational database that contains structured data in rows and columns, you can use
Transact-SQL to write simple and effective queries to return the data that interests you. However,
Transact-SQL is not designed to handle data that has more than two dimensions, such as that found in an
online analytical processing (OLAP) cube. Instead, you can use the Multidimensional Expressions (MDX)
language both to query multidimensional data and to return data in multiple dimensions. In this module,
you will see how to use MDX to add features to a cube and display data in client applications such as SQL
Server® Reporting Services or Microsoft® Excel®.
Objectives
After completing this module, you will be able to:
Write a simple MDX query that establishes cube context and specifies both query and slicer axes.
Use MDX to add calculated members, named sets, and scoped assignments to cubes.
Use MDX from SQL Server Management Studio, Excel, SQL Server Reporting Services, and custom
code to access and display data.
MCT USE ONLY. STUDENT USE PROHIBITED
5-2 Introduction to MDX
Lesson 1
MDX Fundamentals
A table in Microsoft SQL Server consists of two-dimensional data that is organized into columns and rows.
An OLAP cube can have many more dimensions and multiple members of each dimension. The Transact-
SQL language that is used to query tabular data is not ideal for more than two dimensions, so SQL Server
Analysis Services includes the MDX query language. By using MDX, you can write queries that are easy to
read and understand, but execute against multidimensional cube data. In this lesson, you will learn the
essential features of the MDX language.
Lesson Objectives
After completing this lesson, you will be able to:
Describe how MDX differs from Transact-SQL and how it enables developers to query
multidimensional data more easily.
Use SELECT and WHERE to specify query and slicer axes in an MDX query.
Use FROM, CREATE SUBCUBE, LOOKUPCUBE, and FILTER to establish the cube context for a query.
Use SQL Server Management Studio to issue simple MDX queries.
What Is MDX?
Most databases store data in two-dimensional
tables that consist of rows and columns. Transact-
SQL is designed to formulate queries against this
two-dimensional data and is highly efficient and
readable. However, in an OLAP cube, data that has
three or more dimensions is frequently stored.
Very complex Transact-SQL would be required to
query this data and it would be difficult for
developers to read and understand such queries.
Instead of using Transact-SQL, you can use MDX
to query OLAP cubes. In MDX, it is simple to drill
down into multiple dimensions and hierarchies,
and select pertinent data from many dimensions.
In some ways, MDX is similar to Transact-SQL. For example, SELECT statements and WHERE clauses are
common. However, these familiar elements have a different meaning and accept a different syntax in
MDX.
An MDX query usually selects a subset of all of the data in the cube and this subset frequently has a
smaller number of dimensions. For example, it is common to use MDX to return two-dimensional table-
like data that can be displayed in an Excel spreadsheet. However, you can return any number of
dimensions in your result set, up to the number of dimensions in the cube itself.
Note: There is also a hard limit of 128 query axes in an MDX SELECT statement.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 5-3
An MDX query that returns a single value is called an MDX expression. A query that returns a large set of
data, such as a table or a cube, is called an MDX statement. The following terms are also frequently used
in MDX documentation:
Cell. A cell is the space at the intersection between the specified member of the measures dimension
and a specified member of one or more other dimensions. You can think of a cell as containing a
single piece of data.
Tuple. A tuple uniquely identifies a slice of data from a cube. It is defined as a combination of
dimension members from different hierarchies. For example, a tuple might be all of the customers
that are located in North America.
Set. A set is a collection of tuples that defines multiple cells from the same dimensions. For example, a
set might be all of the customers that are located in North America and all of the customers that are
located in Africa.
MDX is used in many scenarios. For example, you can use it to select data for display in Excel and SQL
Server Reporting Services. You can also use it in the definition of a cube, for example, to define a
calculated member.
A WHERE clause. The WHERE clause is optional. You can use it to restrict the data that is returned.
For example, it might specify that only data for the South West region is returned.
Navigating Hierarchies
In a cube, the members of dimensions and measures are hierarchical. For example, in a time dimension,
you might want to see data for 2016, for May 2016, or for May 1, 2016. There might also be parallel
hierarchies. For example, you may want to see data for the 2015–2016 fiscal year instead of the calendar
year. In MDX, you navigate these hierarchies by using dots. For example, to specify May 2016, you might
use the term “[2016].[Q1].[May]”. The levels in the hierarchy depend on the structure of the cube that you
are executing queries against.
When the object name matches an MDX keyword, such as SELECT or FROM.
MCT USE ONLY. STUDENT USE PROHIBITED
5-4 Introduction to MDX
When the object name begins with a numeric character, such as the name of a year.
Many MDX developers always use square brackets as a convention to avoid errors and ambiguity.
Avoiding Ambiguity
In a cube, many members might share the same name. For example, in a time dimension, Q1 might refer
to the first quarter of 2015 or the first quarter of 2016, or any other year in a single dimension. Similarly,
the name Tailspin Toys may appear in both a Suppliers dimension and a Customers dimension. It is
important to ensure that you specify objects or ranges of objects without any ambiguity to ensure that
the data displayed is what you intended.
To eliminate these ambiguities, ensure that you qualify each object name to uniquely identify it. For
example, to specify the first quarter of 2015, use [2015].[Q1]. To specify Tailspin Toys in the Customers
dimension, use [Customers].[Tailspin Toys], and so on. The precise qualification that you use will
depend on the structure and hierarchy levels in your cube.
If an object is identified ambiguously, MDX does not return an error, but returns the first occurrence of
the object in the database. For example, if there were members named Q1 for every year from 2011,
[2011].[Q1] would be returned because it is the first occurrence. Even if this is what you intended, it is
best to uniquely identify a member for the benefit of other query writers.
Note: It is very common to specify two query axes because the tabular data that is
produced can be easily read, for example, in a tabular report.
In the SELECT query, use the ON keyword to specify the axis on which to display a set of members.
In the following example, the query axes are specified by using the aliases COLUMNS, ROWS, and PAGES:
In a SELECT query, you can specify up to 128 query axes. The first five of these axes have the aliases
COLUMNS, ROWS, PAGES, SECTIONS, and CHAPTERS. Instead of using these aliases, you can use an
ordinal number, starting from 0 for the columns.
In the following example, the query axes are specified by using the ordinal numbers:
Note: You cannot skip axes in a SELECT query. For example, you cannot specify axes 0 and
2 without specifying axis 1. Similarly, you cannot use a PAGES axis without using both a
COLUMNS axis and a ROWS axis.
In the above example, the 0 axis will include a 2015 column and a 2016 column. To return a column for
every calendar year in the Date dimension, you could use the Members function. For example, use
[Date].[Calendar Year].Members.
A slicer axis does not filter the members that appear along the edges of the result set. For example, it does
not affect the rows that are returned. Instead, it filters the cube cells that will be summed (or otherwise
aggregated) to generate the result cells.
MCT USE ONLY. STUDENT USE PROHIBITED
5-6 Introduction to MDX
Creating a Subcube
Sometimes, you might be interested in executing multiple MDX queries against a small portion of the
cube. For example, you might want to investigate several aspects of sales performance in North America
during 2015. In such cases, you can, of course, specify query and slicer axes individually for each query,
but it is more efficient to create a subcube of the data that interests you, and then execute queries against
it.
Use the CREATE SUBCUBE statement to restrict a cube in this way. You pass to this statement an MDX
expression that defines the content of the subcube.
In this example, a subcube is created that includes sales amounts for all calendar years and all customers.
Other dimensions in the original cube are left out of the subcube.
Creating a Subcube
CREATE SUBCUBE [Adventure Works] AS
SELECT
{[Date].[Calendar Year].Members} ON COLUMNS,
{[Measures].[Sales Amount]} ON ROWS,
{[Customers].Members} ON PAGES
FROM [Adventure Works]
Note: In the previous example, the subcube shares the same name as the original cube
(“Adventure Works”). All subsequent MDX queries that have “Adventure Works” in the FROM
clause will execute against the subcube until the session closes, or until you issue a DROP
SUBCUBE statement.
Note that some members of a cube might be present in the subcube even though you did not explicitly
specify them in the CREATE SUBCUBE statement. For example, the subcube will include all of the
descendants and ascendants of the members that you specified.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 5-7
Also, be careful to understand aggregation in subcubes. For example, consider a subcube that includes
the US states, Washington and Oregon, plus the country, the United States. The reported sales for the
United States member will be the sum of sales in Washington and Oregon, but sales from other states will
not be added, because those states are not included in the subcube.
In the following example, the “Sales Amount” measure from the “Adworks Archive” cube is added as a
new measure member named “Archive Sales Amount.” This is displayed on its own row.
Best Practice: Although they are useful, queries that use the LOOKUPCUBE function to
integrate two cubes are likely to perform less well than queries against a single cube. If you find
that you use LOOKUPCUBE often, consider redesigning your cubes to include all of the relevant
data.
In the following example, the FILTER function removes all calendar years before 2010 from the result set:
Demonstration Steps
Deploy and Query a Cube
1. Ensure that the 20768C-MIA-DC and 20768C-MIA-SQL virtual machines are both running, and then
log on to 20768C-MIA-SQL as ADVENTUREWORKS\Student with the password Pa55w.rd. In the
D:\Demofiles\Mod05\Starter folder, run Setup.cmd as Administrator.
2. On the Start screen, type SQL Server Data Tools 2015, and then press Enter.
MCT USE ONLY. STUDENT USE PROHIBITED
5-8 Introduction to MDX
3. In SQL Server Data Tools, on the File menu, point to Open, and then click Project/Solution.
4. In the Open Project dialog box, browse to the D:\Demofiles\Mod05\Starter folder, and then
double-click Adventure Works OLAP.sln.
11. In the Connect to Server dialog box, in the Server type drop-down list, select Analysis Services.
12. In the Server name text box, select MIA-SQL, and then click Connect.
13. In Object Explorer, expand Databases, right-click Adventure Works OLAP, point to New Query,
and then click MDX.
SELECT
{
[Measures].[Internet Sales Count],
[Measures].[Reseller Sales Count]
} ON COLUMNS,
{
[Order Date].[Calendar Date].[Calendar Year]
} ON ROWS
FROM [Sales]
18. Close SQL Server Management Studio, without saving any changes.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 5-9
Lesson 2
Adding Calculations to a Cube
In previous modules, you have seen how to create dimensions and measures and use them to define the
data in a cube. However, not all of the members of a cube must come from the underlying data source,
such as a data warehouse. In this lesson, you will see how to create additional features in a cube, including
calculated members, named sets, and other script commands. All of these features are added to the cube
by using the Calculations tab of the Cube Designer. You will also see some MDX functions that can be
very helpful when defining script commands.
Lesson Objectives
After completing this lesson, you will be able to:
Describe calculated members and explain how they can be used to enhance the information in a
cube.
Define named sets and explain how they can make it easier to write MDX queries.
Describe how scoped assignments limit the cells to which a script action applies.
Use MDX functions to locate the family members for an object, such as a parent or the first child.
List other commonly used MDX functions and choose a function for a given calculation.
Calculated Members
A calculated member is a cube member whose
value is calculated when a user queries the cube
(in other words, at run time) by using an MDX
expression that you define as part of the cube.
Desktop applications and MDX clients can access
the calculated member just as they access other
members of dimensions or measures. A calculated
member can be defined as a combination of cube
data, arithmetic operations, numbers, and
functions.
Name. Specify a descriptive and unique name to identify the new member. Ensure that the name is
meaningful to users who will be browsing the cube.
Parent hierarchy. Specify the dimension that the member appears within. If you place the calculated
member in the Measures hierarchy, it is known as a calculated measure.
Format string. You can select how the value is displayed. For example, you could select Currency or
Percent.
Visibility. If you want users to be able to see the calculated member as they browse the cube, select
True.
Non-empty behavior. This is an important property for performance. See the next section for details.
One way to help to reduce the processing demands of a calculated member is to carefully specify a Non-
empty behavior value. If this value is blank, SQL Server Analysis Services must evaluate the full expression
to determine whether the calculated member is empty. If, by contrast, you specify one or more members
in the Non-empty behavior property, SQL Server Analysis Services trusts that when all of these members
are empty, the calculated member is empty. This means that SQL Server Analysis Services can skip this
calculation. In the expression example above, you could add the [Sale Price] and [Production Cost] to the
Non-empty behavior property, because when they are empty, [Profit] is empty.
The following example shows the code that the Calculated Expressions page displays when you add a
calculated member:
Named Sets
A named set is an MDX expression that returns a
set of dimension members. Named sets can be
defined and saved as part of the cube. Named sets
enable other MDX expressions—for example,
expressions that are issued by clients or custom
applications—to easily access a common set of
data.
By defining a named set, you reduce the amount and complexity of MDX code that must be created in
client applications. As for calculated members, you can use the Calculations tab of the Cube Designer to
create named sets.
The following example creates a set named Core Products that includes only products from the category
Bikes.
Scoped Assignments
When you use the New Calculated Member
button or the New Named Set button on the
Calculations tab of the Cube Designer, you add
script to the definition of the cube that creates
that member or set, according to the options that
you select. You can also use the New Script
Command button to add any other kind of MDX
script to the definition of the cube.
You can nest SCOPE statements. For example, you could scope the script to provide only results from
2014, take some actions, and then scope the script further to provide only results from January 2014, and
then take some more specific actions.
Within the scoped assignment, use the THIS function to refer to all members of the current subcube.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 5-13
In the following example, a SCOPE statement limits the current scope to the fiscal quarters in 2016 and
the Sales Amount Quota measure. The THIS statement is used to apply a calculation to the members of
that scope by multiplying the quotas from the previous year, which are obtained by using the
PARALLELPERIOD function.
THIS = PARALLELPERIOD
(
[Date].[Fiscal].[Fiscal Year], 1,
[Date].[Fiscal].CurrentMember
) * 1.1 ;
END SCOPE
Note: When you are troubleshooting scoped assignments, it is helpful to see which cells are
in the current scope. You can use the BACK_COLOR cell property to highlight the cells in the
current scope.
[Date].[Year].[Quarters].CurrentMember.Parent.Name
ANCESTOR. This function returns the member a specified number of levels above the current
member. When you specify one level above, ANCESTOR returns the same member as PARENT.
However, you can use ANCESTOR to obtain members multiple levels above the current member in a
single operation. ANCESTOR returns a single member. For example, the following expression returns
the year for the current month.
Ancestor([Date].[Year].[Quarters].[Month].CurrentMember, 2).Name
MCT USE ONLY. STUDENT USE PROHIBITED
5-14 Introduction to MDX
CHILDREN. This function returns all of the members, one level below the current member, that have
the current member as their parent.
FIRSTCHILD. This function returns a single member, one level below the current member, that
appears first in the database.
LASTCHILD. This function returns a single member, one level below the current member, that
appears last in the database.
SIBLINGS. This function returns all of the members that have the same parent as the current member.
The members returned include the current member.
FIRSTSIBLING. This function returns the sibling that appears first in the database.
LASTSIBLING. This function returns the sibling that appears last in the database.
HIERARCHY. This function returns the hierarchy that contains an object. The object might be a level
or a member.
LEVEL. This function returns the level that contains a member.
PARALLELPERIOD. This time-based function returns a member from the previous period with the
same relative expression. For example, you could use this function to find a month one year (or four
quarters) earlier than another member, as in the following example:
PARALLELPERIOD([Date].[Calendar].[Calendar Quarter], 4,
[Date].[Calendar].[Month].[October 2016])
NONEMPTY. This function returns only the members of a set that are not empty. This can help to
improve performance by ensuring that a complex calculation is not performed when a key member is
empty. For example, the following code returns a set of all of the customers whose Sales Amount
value was not empty on January 1, 2016:
NONEMPTY([Customer].Members,
{ [Date].[Calendar].[Date].&[20160101], [Measures].[Sales Amount] })
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 5-15
Demonstration Steps
Add a Calculated Member
1. Ensure that you have completed the previous demonstration in this module.
2. On the Start screen, type SQL Server Data Tools 2015, and then press Enter.
3. In SQL Server Data Tools, on the File menu, point to Open, and then click Project/Solution.
4. In the Open Project dialog box, browse to the D:\Demofiles\Mod05\Starter folder, and then
double-click Adventure Works OLAP.sln.
7. Right-click in the Script Organizer pane, and then click New Calculated Member.
8. In the Name text box, type [Total Sales Count].
10. In the Expression text box, type the following MDX expression:
12. In the Non-empty behavior list, select Internet Sales Count and Reseller Sales Count, and then
click OK.
13. On the File menu, click Save All.
14. On the Build menu, click Deploy Solution. If you are prompted to authenticate, use the password
Pa55w.rd, and then click OK.
15. When the deployment is complete, close Visual Studio.
3. In the Server name drop-down list, click MIA-SQL, and then click Connect.
4. In Object Explorer, expand Databases, right-click Adventure Works OLAP, click New Query, and
then click MDX.
SELECT
{
[Measures].[Internet Sales Count],
[Measures].[Reseller Sales Count],
[Measures].[Total Sales Count]
} ON COLUMNS,
[Product].[Categorized Products].[Category] ON ROWS
FROM [Sales]
Categorize Activity
Categorize each item into the appropriate category. Indicate your answer by writing the category number
to the right of each item.
Items
1 PARENT
2 PARALLELPERIOD
3 CHILDREN
4 NAME
5 SIBLINGS
6 CURRENTMEMBER
7 FIRSTSIBLING
8 HIERARCHY
9 LASTCHILD
10 LEVEL
11 ANCESTOR
12 NONEMPTY
Category 1 Category 2
Lesson 3
Using MDX to Query a Cube
Multidimensional data, such as that in an OLAP cube, is often accessed and displayed from Excel in
PivotTables and PivotCharts. It might also be a data source in SQL Server Reporting Services. In this lesson,
you will see how to connect to a cube in SQL Server Analysis Services from these and other tools. After
you have connected to SQL Server Analysis Services, you can issue MDX queries by writing them manually,
or by using user-friendly tools.
Lesson Objectives
After completing this lesson, you will be able to:
Create connection strings to connect to a specific cube in SQL Server Analysis Services.
Create MDX queries by using the tools in Excel and SQL Server Reporting Services.
Advise developers about object models to use for access to SQL Server Analysis Services.
Query a SQL Server Analysis Services cube from Excel.
From a custom application. A developer can write code that uses programmatic interfaces such as
XMLA or ADOMD.NET to send MDX queries to SQL Server Analysis Services. Such code can include
desktop applications, mobile device apps, and many other kinds of custom solution.
Excel, SQL Server Reporting Services, and custom applications will be examined in more detail later in this
module.
A data source. This specifies the instance of SQL Server Analysis Services. You can use an instance
name, a fully qualified domain name, an IP address, or a port number to identify the instance.
An initial catalog. This specifies the SQL Server Analysis Services database to connect to.
A provider. This optional value specifies the version of SQL Server Analysis Services.
Character encoding. This specifies whether strings use UTF-8 or UTF-16 to encode characters in
MDX queries.
An MDX compatibility value. If this value is set to 0 or 1, missing members in ragged hierarchies are
displayed by placeholders. For example, Excel sets this property to 1 and displays an empty cell for
missing members. If this value is set to 2, placeholders are not returned.
SQL Server Analysis Services does not support SQL Server Authentication, so you must use Windows®
integrated authentication. Depending on the client, this may be Kerberos or NTLM authentication. You
can use the following connection string properties to control authentication:
EffectiveUserName. Use this setting to impersonate a different user for the duration of the
connection. Specify the user account in domain\username format. Note that the connection is made
as the currently logged-on user, who must have administrative permission for SQL Server Analysis
Services.
Use Encryption for Data. When this value is true, all queries and results are encrypted on the
network between the client and the server.
User ID. Use this account to connect to SQL Server Analysis Services. If this value is not specified, the
client uses the currently logged-on Windows user account. This setting must be used with Password.
2. In the Connect to Server dialog box, in the Server type drop-down list, select Analysis Services.
3. On the Login tab, in the Server name text box, type the name or fully qualified domain name of the
SQL Server Analysis Services server. To connect to an instance other than the default instance, use the
Server\Instance format.
4. Click Connect.
Note: You can only use Windows authentication to connect to SQL Server Analysis Services,
not SQL Server Authentication. Your current Windows account must be authorized to access the
database and cube.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 5-19
4. In the Data Connection Wizard, in the Server name text box, type the name of the Analysis Services
server to connect to, and then click Next.
5. From the drop-down list, select the SQL Server Analysis Services database.
6. Select the cube from the list, and then click Finish.
Note: The precise steps for this procedure might vary depending on your version of Excel.
For more information about connecting Excel to SQL Server Analysis Services, see Connect to or import
data from SQL Server Analysis Services:
Connect to or import data from SQL Server Analysis Services
http://aka.ms/Bnxvey
Design mode. This mode is for those who prefer to construct MDX queries by graphical means. The
user interface includes the following elements:
o Select Cube button. Use this button to select the current cube.
o Metadata pane. This pane displays dimensions, measures, and key performance indicators (KPIs)
in the current cube. You can drag members from this pane onto the data pane to formulate a
query.
o Calculated Members pane. This pane displays calculated members in the current cube. As for
the Metadata pane, you can drag members from this pane onto the data pane.
o Filter pane. Use this pane to create filters from dimensions and measures to limit the data that is
returned.
o Data pane. This is where the results for the current query are displayed.
MCT USE ONLY. STUDENT USE PROHIBITED
5-20 Introduction to MDX
Query mode. This mode is for those who prefer to construct queries by writing MDX text. The user
interface includes the following elements:
o Select Cube button. This is the same button that appears in Design mode.
o Metadata pane. As for Design mode, this pane displays dimensions, measures, and KPIs. In
Query mode, however, it also displays MDX functions and template queries, which you can drag
onto the query pane.
o Query pane. This pane displays the current query as MDX query text. You can formulate queries
by typing them manually into this pane, by dragging elements from the Metadata pane, or by a
combination of both operations.
o Data pane. This pane displays the results for the current query as it is displayed in the query
pane.
For more information on how to use the MDX Query Designer in Excel, see Analysis Services MDX Query
Designer (Power Pivot):
4. In the Connection string text box, type a connection string for the instance of SQL Server Analysis
Services that you want to query. See the previous topic for details of the properties that you should
use.
5. Under Connect using, specify how SQL Server Reporting Services will authenticate with SQL Server
Analysis Services. Remember that you can only use Windows authentication:
o If you select Windows Integrated Security, the current Windows account will be used to
authenticate.
o If you select Credentials supplied by the user running the report, the user will be prompted
for the credentials of a Windows account.
o If you select Credentials stored securely in the report server, the same user account will
always be used to authenticate with SQL Server Analysis Services, regardless of the user who
accesses the report.
o If you select Credentials are not required, SQL Server Reporting Services will authenticate
anonymously with SQL Server Analysis Services. You must ensure that anonymous access is
enabled in SQL Server Analysis Services and also that the unattended execution account is
configured on the report server.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 5-21
When you have created a data source, you can use the MDX Query Designer to formulate queries. This
tool is very similar to the Excel MDX Query Designer.
For more information about creating MDX queries against SQL Server Analysis Services data in SQL Server
Reporting Services, see Analysis Services Connection Type for MDX (SSRS) in Microsoft Docs:
SQL Server Analysis Services OLE DB provider. If you prefer to use the OLE DB standard to access
data, you can use this provider to access a cube.
XMLA. This is an industry-standard protocol based on SOAP and XML—a lower-level protocol that
might require more custom code than ADOMD.NET. However, it is supported by any programming
platform that has support for SOAP and XML.
AMO. Analysis Management Objects (AMO) is a library of managed objects that you can use to
configure SQL Server Analysis Services. You cannot use this library to query a cube—instead, you can
use it to create cubes, dimensions, measures, and other objects from custom code.
For more information about programmatic interfaces for multidimensional data, see Data Access with
MDX in Microsoft Docs:
Programmatic Interfaces
http://aka.ms/Cr0cp5
MCT USE ONLY. STUDENT USE PROHIBITED
5-22 Introduction to MDX
Demonstration Steps
Connect to SQL Server Analysis Services
1. On the Start screen, type Excel 2016, and then press Enter.
4. Click Get External Data, click From Other Sources, and then click From Analysis Services.
6. Select Use the following User name and Password, type the following, and the click Next:
b. Password: Pa55w.rd
7. Ensure that the Adventure Works OLAP database and the Sales cube are selected, and then click
Next.
8. Click Finish.
9. In the Import Data dialog box, ensure that PivotTable Report is selected, and then click OK.
1. In the PivotTable Fields box, under Internet Sales, select Internet Sales Count.
2. Under Reseller Sales, select Reseller Sales Count.
Data source
Initial catalog
Provider
Character encoding
MDX compatibility
MCT USE ONLY. STUDENT USE PROHIBITED
5-24 Introduction to MDX
You want to add several important measures to a cube, but these measures must be calculated from
other, existing measures. These include:
The total revenue from both reseller sales and Internet sales.
You intend to add these measures to the cube by calculating them from existing measures. You also want
to test the cube by using MDX queries in SQL Server Management Studio. Finally, you want to create an
Excel worksheet that draws data from the Sales cube into a worksheet and into a PivotTable.
Objectives
After completing this lab, you will be able to:
Use form view and script view in the Cube Designer to add calculated members.
Write and execute MDX queries in SQL Server Management Studio and Excel.
Password: Pa55w.rd
2. In the Sales.cube cube, use the Calculations tab of the Cube Designer to add a new calculated
member. Use the following information:
o Expression: Take [Internet Cost] away from [Internet Revenue] and then divide the result by
[Internet Cost]
2. Type MDX code to create a second new calculated member. Use the following information:
o Expression: Take [Reseller Cost] away from [Reseller Revenue] and then divide the result by
[Reseller Cost]
o Visible: 1
3. Save your changes, deploy the solution, and then close Visual Studio.
Results: After this exercise, you should have added three calculated members to the Sales cube and
deployed the cube to the MIA-SQL instance of SQL Server Analysis Services.
MCT USE ONLY. STUDENT USE PROHIBITED
5-26 Introduction to MDX
2. Write an MDX query against the [Sales] cube. Return [Internet Revenue], [Reseller Revenue], and
[Total Revenue] on columns, and all of the members of [Product].[Categorized Products] on rows.
Examine the results to ensure that the total is correct for each member.
3. Create and execute a second new query. Use the following information:
o Columns: [Reseller Cost], [Reseller Revenue], and [Reseller Profit]
o Internet Cost
o Internet Revenue
o Internet Profit
o Product Category
o Product Subcategory
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 5-27
o Cube: Sales
o Import the data into a new worksheet
2. In the new PivotTable, choose the Internet Revenue, Reseller Revenue, and Total Revenue
measures for columns, and the Sales Territory dimension for rows.
3. In the worksheet, determine the Total Revenue value for the United Kingdom.
Results: After this exercise, you should have created several test MDX queries in SQL Server Management
Studio and an Excel spreadsheet that connects to the Sales OLAP cube.
MCT USE ONLY. STUDENT USE PROHIBITED
5-28 Introduction to MDX
Review Question(s)
Question: Users often want to aggregate data from Europe and North America in their
reports and spreadsheets. Users who have good MDX skills have been able to do this by
editing MDX queries in their client programs. How can you help users who have no MDX
skills to display this data?
Question: You are testing the Sales cube by writing MDX queries in SQL Server
Management Studio. You would like to compare sales for 2015 with data from the Archived
Sales cube, which includes sales data from 2008 to 2010. How can you add this data to your
query?
MCT USE ONLY. STUDENT USE PROHIBITED
6-1
Module 6
Customizing Cube Functionality
Contents:
Module Overview 6-1
Lesson 1: Implementing Key Performance Indicators 6-2
Module Overview
In this module, you will learn how to customize cube functionality by using several technologies that are
available in SQL Server Analysis Services. By customizing cubes, you can improve the user experience,
making cubes easier to use.
You will learn about key performance indicators (KPIs) and how they can be used to obtain a quick and
accurate summary of business progress. You will find out about actions, and how they enable end users to
go beyond traditional analysis to initiate solutions, and to discover problems and deficiencies. This
module also covers perspectives and how they enable users to see a simplified version of a cube, so that
users can focus on the most relevant data. Finally, you will learn about translations, and how they can be
used to translate various elements of a cube, and enable users to view and understand cube and
dimension data.
Objectives
After completing this module, you will be able to:
Implement KPIs
Implement actions
Implement perspectives
Implement translations
MCT USE ONLY. STUDENT USE PROHIBITED
6-2 Customizing Cube Functionality
Lesson 1
Implementing Key Performance Indicators
In business, a KPI is a quantifiable measurement that is used to understand how well, or badly, an activity
is going. KPIs are mostly evaluated over time. KPIs may be specific to a department, or generic for the
whole organization.
Generic KPI examples might include gross profit or sales turnover measured monthly. Department-specific
KPIs might include staff turnover, and the number of people who have been trained in a month for the
human resources department.
KPIs are often viewed together in a business scorecard to give a summary of the health of a business.
Lesson Objectives
After completing this lesson, you will be able to:
Describe KPIs.
List the elements of a KPI.
Browse a KPI.
Introducing KPIs
In SQL Server Analysis Services, a KPI is a group of
calculations that are used to evaluate a business
activity. KPIs are associated with a measure group
in a cube, and can be compared against a business
goal to provide trend information over time.
Best Practice: Getting a KPI measurement right is a business decision rather than an IT
decision. A KPI must genuinely reflect an outcome that the business wants to achieve.
Care must be taken that the KPI does not encourage damaging behavior. For example,
measuring sales turnover by quarter could result in salespeople booking work before client
contracts have been signed, or agreeing sales at reduced margins. A KPI that measures repeat
purchases, on the other hand, might be a better indicator of customer satisfaction and future
business success.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 6-3
An advantage of calculating KPIs by using SQL Server Analysis Services is that the data is held centrally,
and can be used by different client applications. When KPIs are calculated locally, they might be
calculated by using different datasets, and could be difficult to compare.
SQL Server Analysis Services includes functionality that helps you to define KPI calculations in a
multidimensional cube.
For more information about KPIs, see Key Performance Indicators (KPIs) in Multidimensional Models in
Microsoft Docs:
Elements of a KPI
KPIs in SQL Server Analysis Services consist of
several properties, including:
Value
Goal
Display folder
Parent KPI
Weight
Value
A value is the result of a calculation that is defined by using an MDX expression. This is the actual value of
the KPI and represents the current position.
Goal
A goal expression is a value, or an MDX expression that resolves to a value, that defines the target for the
measure that the value expression describes. For example, a retailer might have a margin goal expression
that has a value of 0.6 (or 60 percent) for accessories, and 0.3 (30 percent) for all other categories.
Margin goal of 60 percent for accessories, and 30 percent for all other categories.
MDX Expression
Case
When [Product].[Category].CurrentMember Is
[Product].[Category].[Accessories]
Then .60
Else .30
End
Status
A status expression evaluates the current status of the KPI value, compared to the goal. The result is
returned within the range of -1 to +1, where -1 is the worst and +1 is the best. The following MDX
expression returns a value of 1 if the KPI value is greater than, or equal to, the goal value. It returns a
MCT USE ONLY. STUDENT USE PROHIBITED
6-4 Customizing Cube Functionality
value of -1 if the KPI value is less than 0.5; otherwise, it returns 0. This means that the status is 1 if the goal
has been reached, 0 if the value is more than halfway toward the goal, and -1 if the value is less than
halfway toward the goal.
The KPI value is compared to the Goal value to return a Status value.
MDX Expression
Case
When KpiValue( "Gross Profit Margin" ) /
KpiGoal ( "Gross Profit Margin" ) >= 1
Then 1
When KpiValue( "Gross Profit Margin" ) /
KpiGoal ( "Gross Profit Margin" ) < 0.5
Then -1
Else 0
End
Trend
A trend expression is used to evaluate the current trend of the value expression compared to the goal
expression. The trend expression helps a business user to understand whether a KPI value is getting better
or worse over time, relative to the goal expression.
You can also associate graphical devices with a trend expression to help business users to quickly
understand the trend.
The following code returns a value of 1 if the gross profit margin is increasing over the last year, -1 if it is
decreasing, and 0 if it is the same.
Parent KPI. This property defines the parent of the current KPI. The browser displays the KPI as a
child while allowing the parent to access the values of the child. This feature enables you to have KPIs
that are based on other KPIs.
Weight. You can apply a weight to adjust the importance of a child KPI against its siblings.
Current time member. This is an MDX expression that defines the current time member for the KPI.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 6-5
Browsing KPIs
KPIs in SQL Server Analysis Services are server-
based, so they can be used by different client
applications. The business logic is within SQL
Server Analysis Services, and stored in the cube. In
addition, client applications can use MDX
expressions with the cube data to retrieve parts of
the KPI—such as the value or goal—to use in
expressions, statements, and scripts.
Demonstration Steps
Create a KPI
1. Ensure that the 20768C-MIA-DC and 20768C-MIA-SQL virtual machines are both running, and then
log on to 20768C-MIA-SQL as ADVENTUREWORKS\Student with the password Pa55w.rd.
4. Start Microsoft® Visual Studio®, and then in the D:\Demofiles\Mod06 folder, open the
Adventure Works OLAP.sln solution.
MCT USE ONLY. STUDENT USE PROHIBITED
6-6 Customizing Cube Functionality
7. If the Account Password dialog box appears, enter the password Pa55w.rd for
ADVENTUREWORKS\ServiceAcct, and then click OK.
9. In Solution Explorer, double-click Sales.cube to open it in the Cube Designer, and then click the
Calculations tab.
10. In the Script Organizer pane, select [Reseller Profit], and then note that this calculated member
calculates reseller gross margin as a percentage of revenue.
11. In the Cube Designer, click the KPIs tab, and then, on the Cube menu, click New KPI.
12. In the Name box, type Reseller Margin, and then in the Associated measure group list, select
Reseller Sales.
13. In the Calculation Tools pane, on the Metadata tab, expand Measures, expand Reseller Sales, and
then drag the Reseller Profit measure to the Value Expression box.
14. In the Goal Expression box, type 0.1 (this sets a gross margin target of 10 percent).
15. Check that Gauge is selected in the Status indicator list, and then type the following MDX
expression in the Status expression box (you can copy this from New_KPI_Demo.txt in the demo
folder):
Case
When
KpiValue("Reseller Profit")/KpiGoal("Reseller Profit")>=.95
Then 1
When
KpiValue("Reseller Profit")/KpiGoal("Reseller Profit")<.95
And
KpiValue("Reseller Profit")/KpiGoal("Reseller Profit")>=.5
Then 0
Else -1
End
16. Check that Standard arrow is selected in the Trend indicator list, and then type the following
expression in the Trend expression box (you can copy this from New_KPI_Demo.txt in the demo
folder):
Case
When IsEmpty(ParallelPeriod([Order Date].[Calendar Date].[Calendar Year],
1, [Order Date].[Calendar Date].CurrentMember))
Then 0
When [Measures].[Reseller Profit] = (ParallelPeriod([Order Date].[Calendar
Date].[Calendar Year],
1, [Order Date].[Calendar Date].CurrentMember), [Measures].[Reseller Profit])
Then 0
When [Measures].[Reseller Profit] >
(ParallelPeriod([Order Date].[Calendar Date].[Calendar Year],
1, [Order Date].[Calendar Date].CurrentMember), [Measures].[Reseller Profit])
Then 1
Else -1
End
1. On the Build menu, click Deploy Solution. If you are prompted for impersonation credentials, enter
the password Pa55w.rd for ADVENTUREWORKS\ServiceAcct.
3. In the cube browser, click the KPIs tab, and then on the Cube menu, point to Show KPIs in, and then
click Browser. The KPI is shown based on the total overall margin.
4. In the top pane of the KPI browser, in the Dimension list, select Sales Territory, in the Hierarchy list,
select Sales Territory, in the Operator list, select Equal, and then in the Filter Expression list,
expand All, select North America, and then click OK.
5. Click anywhere in the KPI browser pane to update the values for the Reseller Margin KPI. The updated
values indicate the overall margin for sales in North America.
6. Amend the KPI criteria again. In the top pane of the KPI browser, in the Dimension list, select Order
Date, in the Hierarchy list, click Calendar Date, in the Operator list, select Equal, and then in the
Filter Expression list, expand All, select 2006, and then click OK.
7. Click anywhere in the KPI browser pane to update the values for the Reseller Margin KPI. The updated
values indicate the overall Reseller margin for sales in 2006.
2. In Microsoft Excel®, in the PivotTable Fields pane, under Reseller Sales, select Reseller Profit. The
overall gross margin is shown in the PivotTable.
3. In the PivotTable Fields pane, under Order Date, drag Order Date.Calendar Date to the Rows
area. The gross margin for each year is shown.
4. In the PivotTable Fields pane, expand KPIs, expand Reseller Margin, and then select Goal. The
Reseller Margin goal is displayed in the PivotTable.
Question: What KPIs are used in your business? Do you have KPIs in your department? Does
the KPI generally have a positive effect on employee behavior? Can you think of any KPIs
that have had unwanted results?
MCT USE ONLY. STUDENT USE PROHIBITED
6-8 Customizing Cube Functionality
Lesson 2
Implementing Actions
In SQL Server Analysis Services, an action is a stored MDX statement that can be presented to and
employed by client applications. An action enables SQL Server Analysis Services to interact with other
applications, providing information that can be used to perform a task, such as opening a web page or
displaying data. The action is defined on the server and used by a client application.
Lesson Objectives
After completing this lesson, you will be able to:
Describe actions.
Implement actions.
Introducing Actions
An action is an MDX statement that is saved as
part of a cube definition, and can be used by
client applications. Actions are stored on the
server, and perform some action that is required
on the client side. For example, an action might be
to drill through and return a rowset, or to display a
web page in a browser. The action is stored in the
SQL Server Analysis Services database, so it is
important to test whether the client application
supports the action and can correctly interpret the
events of the action.
The target type could be level members, cells, hierarchy, hierarchy members, or others. The target object
is specific to the target type. For example, if the target type is hierarchy, the target object is any one of the
defined hierarchies in the cube.
A condition is implemented as a Boolean MDX statement that evaluates to true or false. If the statement
returns true, the action is performed; if it returns false, the action is not performed.
By saving and reusing actions, end users can go beyond traditional analysis, which finishes with data
presentation. Actions enable users to look for solutions to issues that they discover as they work with the
data. Actions enable a business intelligence application to go beyond the cube.
You can be flexible when you create actions. For example, an action can launch an application, retrieve
information from a database, or open a web page in a browser.
You can configure actions to be triggered from almost any part of a cube, including dimensions, levels,
members, and cells, or to create multiple actions for the same portion of a cube.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 6-9
Types of Actions
SQL Server Analysis Services supports different
types of actions:
o Attribute members
o Cells
o Cube
o Dimension members
o Hierarchy
MCT USE ONLY. STUDENT USE PROHIBITED
6-10 Customizing Cube Functionality
o Hierarchy members
o Level
o Level members
o Proprietary. This performs an operation by using an interface other than those listed here.
To create a new drill-through action, on the Cube menu, click New Drillthrough Action, and then
specify the drill-through columns that are required.
To create a reporting action, on the Cube menu, click New Reporting Action, and then specify the
Server Name, Server Path, and Report Format values.
Note: For Server Path, specify the path to the report on the instance of SQL Server
Reporting Services. For example, AdventureWorks/YearlyInternetSales. For Report Format, select
HTML5, HTML3, Excel, or PDF based on the client tool that your users are most likely to use to
access your report.
Verify the correctness of the statement by placing a mark in the column to the right.
Statement Answer
Lesson 3
Implementing Perspectives
Cubes can be complex for users to explore in SQL Server Analysis Services.
A single cube can represent the contents of a complete data warehouse, with multiple measure groups
that represent multiple fact tables, and multiple dimensions based on multiple dimension tables. Although
cubes are powerful, they can be daunting. A user might only need to interact with a small part of the cube
to satisfy their business intelligence and reporting requirements.
In SQL Server Analysis Services, you can use a perspective to reduce the perceived complexity of a cube.
Lesson Objectives
After completing this lesson, you will be able to:
Describe perspectives.
Implement perspectives.
Introducing Perspectives
A perspective is a view of a cube, helping users to
focus on a specific aspect of cube data.
Objects in a cube that are not visible to the user through a perspective can still be directly referenced and
retrieved by using XML for Analysis (XMLA), MDX, or Data Mining Extensions (DMX) statements.
Perspectives do not restrict access to objects in a cube and should not be used as such. Instead, use
perspectives to provide a better experience for users as they work with cube data.
MCT USE ONLY. STUDENT USE PROHIBITED
6-12 Customizing Cube Functionality
Perspectives
http://aka.ms/K7c015
Naming a Perspective
When you create a perspective, the name defaults to Perspective. Additional perspectives default to
Perspective 1, Perspective 2, and so on. You should change the name to something meaningful that
describes the purpose of the perspective to business users. Then use the checkboxes to define which
measures, dimension attributes and hierarchies, KPIs, named sets, and calculated members to include in
the perspective.
Removing a Perspective
You can remove a perspective by:
Clicking any cell in the column for the perspective that you want to delete. Then, on the Cube menu,
click Delete Perspective.
Right-clicking any cell in the perspective that you want to delete, and then clicking Delete
Perspective on the shortcut menu.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 6-13
Lesson 4
Implementing Translations
Multilanguage support in SQL Server Analysis Services is accomplished by using language translations. In
this lesson, you will be introduced to the concepts that are involved in using translations, and how to
implement cube and dimension translations.
Lesson Objectives
After completing this lesson, you will be able to:
Describe translations.
Introducing Translations
A translation is a mechanism to change the
displayed labels and captions from one language
to another.
Translating elements of a cube into a different
language enables more users to view and
understand the cube's metadata. Translations are
available for all objects in SQL Server Analysis
Services, and can also be used to display an
alternative column. Therefore, if you have data in
multiple languages, a different column could be
displayed for an attribute in each language.
A simple translation object is composed of a
language ID number—an integer with the language ID—and a translated caption that is the translated
text.
In SQL Server Analysis Services, a cube translation is a language-specific representation of the name of a
cube object, such as a caption or display folder. There is no automatic translation functionality, so you
must provide text for each label in each language.
Translations provide server support for applications that can support multiple languages. For others, the
default language is displayed.
The collation and language information for the client computer is stored in a locale identifier (LCID). The
following process takes place when a client connects to the cube:
On connection, the client passes the LCID to the instance of SQL Server Analysis Services.
The instance uses the LCID to determine which set of translations to use when providing metadata for
objects in SQL Server Analysis Services to each business user.
If an object in SQL Server Analysis Services does not contain the specified translation, the default
language is used to deliver content to the client.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 6-15
For more information about implementing translations, see Translation support in Analysis Services in
Microsoft Docs:
Translation support in Analysis Services
http://aka.ms/Divre7
Dimensions
KPIs
Named sets
Calculated members
To create a cube translation, click the New
Translation button on the toolbar of the
Translations tab in the Cube Designer. To remove
a translation, select it, and then click Delete Translation.
Dimension
Attributes
In addition to specifying translated values for object names, you can also translate attribute members by
specifying another column in the dimension table that contains translated values. Select New Caption
Column to display the Attribute Data Translation dialog box, and then define a new caption column
when you modify an attribute in the Translation Details grid. For example, you could specify a caption
column of French Month Name for the Month attribute of the Time dimension. You can use the Edit
Caption Column and Delete Caption Column buttons to modify or delete caption columns.
Question: What do you think are the advantages and disadvantages of implementing
translations in a cube?
MCT USE ONLY. STUDENT USE PROHIBITED
6-16 Customizing Cube Functionality
Some users are complaining that the cube is too complex for their needs. These users typically only want
to analyze sales amount by customer, and would like to view the measures and dimensions that are
needed to support this requirement. Finally, the company employs several senior sales managers who
would like to view cube data and metadata in French, their first language.
Objectives
After completing this lab, you will be able to:
Implement an action
Implement a perspective
Implement a translation
Password: Pa55w.rd
2. If you are prompted for impersonation credentials, enter the password Pa55w.rd for
ADVENTUREWORKS\ServiceAcct.
3. Open Sales.cube, and then add a drillthrough action named Internet Sales Details.
4. The action should use the Internet Sales measure group members.
5. The action should return the specified drill-through columns from the following dimensions:
2. In the Cube Designer, select the Browser tab, and then on the Cube menu, click Analyze in Excel.
c. Product.Categorized Products
4. Right-click the sales amount for Bikes in 2007, point to Additional Actions, and then click
Drillthrough to Order Details to test the drill-through action.
5. When you have finished, close Excel without saving the workbook.
Results: After this exercise, you should have a new drill-through action in the solution.
1. Create a Perspective
2. Browse a Perspective
4. Add a perspective named Reseller Sales. The perspective should include only cube objects that are
relevant to reseller sales:
3. Click the ellipsis (…) above the Metadata pane to select the Internet Sales perspective.
a. Expand Internet Sales, and then drag Internet Revenue to the query results pane.
b. Expand the Customer dimension, and then drag Yearly Income to the query results area.
6. In Excel, in the PivotTable Fields pane, select Reseller Revenue from Reseller Sales and Business
Type from Reseller.
7. When you have finished browsing the perspectives, close Excel without saving the workbook.
Results: After this exercise, you should have defined a new perspective in the solution.
3. Browse Translations
Note: To type é, press Alt+130. Check that Num Lock is on. Otherwise, type the translation
without the accents.
3. To display hidden attributes, click the Show All Attributes toolbar icon.
4. To configure attribute translation columns, click the France (French) language column for the
attribute. Select FrenchMonthName.
5. Save the Date dimension when you have finished.
2. Use the Browser tab of the Cube Designer to browse the cube, reconnecting if necessary.
4. View the Revenu d’Internet measure by the Date de Vente.Date du Calendrier hierarchy.
5. Verify that the French translations are used for the captions and month attribute values.
Results: After this exercise, you should have French data and metadata in the cube.
Question: When you apply the translation feature to a cube, what appears in the specified
language?
Review Question(s)
Question: Can you think of scenarios in your own business where the use of the cube
enhancements discussed in this module would help business users?
MCT USE ONLY. STUDENT USE PROHIBITED
7-1
Module 7
Implementing a Tabular Data Model by Using SQL Server
Analysis Services
Contents:
Module Overview 7-1
Lesson 1: Introduction to Tabular Data Models in SQL Server Analysis Services 7-2
Lab: Implementing a Tabular Data Model in SQL Server Analysis Services 7-26
Module Overview
You can install SQL Server® Analysis Services in tabular mode and create tabular data models that
information workers can access by using tools such as Microsoft® Excel® and Power View.
This module describes tabular data models in SQL Server Analysis Services and explains how to develop a
tabular data model by using SQL Server Data Tools.
Objectives
After completing this module, you will be able to:
Describe considerations for tabular databases.
Lesson 1
Introduction to Tabular Data Models in SQL Server
Analysis Services
This lesson describes tabular data models in SQL Server Analysis Services and explains how you can use
SQL Server Data Tools to create a tabular data model.
Lesson Objectives
After completing this lesson, you will be able to:
Describe the options for creating a tabular data model in SQL Server Analysis Services.
Explain the benefits of using SQL Server Data Tools to develop a tabular data model.
The relational model is widely understood and relatively intuitive, so the barrier to entry for relational
database developers and information workers wanting to develop analysis solutions, is lower for
tabular models than for multidimensional models. This helps companies to minimize costs by taking
advantage of their existing internal expertise to create data analysis solutions.
Tabular data models are generally simpler in design than multidimensional models, so companies can
achieve a faster time to deployment for BI applications.
Creators of tabular models can use the Data Analysis Expressions (DAX) language to create measures and
calculated columns, and to implement security. DAX is similar to the formulas that are used in Excel
workbooks, so information workers who already use Excel should find it relatively easy to learn and use.
Tabular data models are generally easy to create because their structure enables developers to interact
directly with data, tables, and relationships without having to create complex additional structures, such as
dimensions and cubes. Tabular data models help to reduce development effort, enabling developers to
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-3
get applications into production more quickly, and making it possible for companies to take advantage of
a wider pool of talent to develop solutions in SQL Server Analysis Services. Relational models are generally
more widely understood than their multidimensional equivalents, so in-house relational database
developers should quickly adapt to creating tabular data models with minimal training.
You can create tabular data models by using the PowerPivot add-in in Excel, or by using SQL Server Data
Tools. You can use SQL Server Management Studio to manage tabular data model databases in SQL
Server Analysis Services after deploying them.
Note: This module focuses on tabular data models in databases in SQL Server Analysis
Services, which are typically created by BI developers as part of a managed enterprise BI solution.
Information workers can use the PowerPivot add-in to create their own tabular data models in
Excel workbooks for personal analysis or to share with colleagues in Microsoft SharePoint®
Server. If these PowerPivot data models become important to the business in the future, they can
be imported into a tabular database in SQL Server Analysis Services and managed centrally by IT.
For more information about PowerPivot, you can attend course number 20778B, Analyzing Data
with Power BI.
Options for Creating a Tabular Data Model Project in SQL Server Analysis
Services
A tabular data model in SQL Server Analysis
Services is a database that is stored on an instance
of SQL Server Analysis Services, running in tabular
mode. You can install an instance of SQL Server
Analysis Services in multidimensional, PowerPivot
for SharePoint, or tabular mode. To create tabular
databases, you must install at least one instance of
SQL Server Analysis Services that runs in tabular
mode.
You can create a tabular data model project for SQL Server Analysis Services by using the SQL Server Data
Tools project templates. Each of the three tabular data model templates enables you to create a project in
a different way:
Analysis Services Tabular Project. This template creates a new, empty tabular data model. You must
import data and metadata from your data sources to populate the model.
Import from PowerPivot. This template creates a new tabular data model by using the tabular data
model that is embedded in a PowerPivot for Excel workbook. The Import from PowerPivot option
extracts the data and metadata from the specified workbook and uses this to populate the new
model.
Import from Server (Tabular). This template creates a new tabular data model from an existing
tabular data model in SQL Server Analysis Services. It extracts the data and metadata from the
specified database and uses these to populate the new model.
MCT USE ONLY. STUDENT USE PROHIBITED
7-4 Implementing a Tabular Data Model by Using SQL Server Analysis Services
Before you create a tabular data model project, you must ensure that there is an instance of SQL Server
Analysis Services running in tabular mode that is available for the project to use during development. The
instance of SQL Server Analysis Services can be local or located on a network. A local instance will typically
provide better performance during the development phase, and makes it possible to work with the model
offline. However, a network instance offers easier collaboration if several developers are involved,
particularly if the project is integrated with Team Foundation Server.
You can also create a tabular data model by using the Restore from PowerPivot option in SQL Server
Management Studio. This method enables you to create a tabular data model database directly from a
PowerPivot for Excel workbook, without having to use SQL Server Data Tools. Like the Import from
PowerPivot template in SQL Server Data Tools, the Restore from PowerPivot option extracts the data
and metadata from the specified PowerPivot for Excel workbook and uses this to populate the tabular
data model database.
Key Features
The key features that you can configure in a tabular database in SQL Server Analysis Services are:
DirectQuery mode, which passes queries directly to the underlying data source instead of using the
in-memory storage engine.
Row-level and object-level security, which enable you to implement security at a granular level.
Partitions, which enable you to manage large tables more efficiently.
Using SQL Server Data Tools to Develop a Tabular Data Model in SQL
Server Analysis Services
SQL Server Data Tools is based on Microsoft Visual
Studio®. It is a comprehensive single
development environment for all of your BI
projects, including projects in SQL Server
Reporting Services, and multidimensional and
tabular projects in SQL Server Analysis Services. It
supports a range of features to enable you to
manage the full project development life cycle,
including:
When you create a tabular data model in SQL Server Data Tools, the tabular model designer opens
automatically. It consists of several windows, including:
Solution Explorer. This window displays the project and its contents. By default, the contents are the
References object and the Model.bim file. You can set the properties of the project, such as the
deployment server or the query mode, from this window.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-5
Designer window. This window displays a visual representation of the model, offering two different
views:
o Data view. This view displays one table at a time, showing the columns and the data that the
table contains. You can select the table that you want to view by clicking the appropriate tab. The
data view contains the measure grid, which you can use to create measures and key performance
indicators (KPIs). You can also create calculated columns in the data view by adding a DAX
expression to the formula bar.
o Diagram view. This view presents the tables in a schema-like diagram. It shows the columns and
hierarchies in each table, and the relationships between the tables. You can also use this view to
create and manage hierarchies.
Properties window. This window displays the properties of the object that you select.
Error list. This window displays errors and other messages that relate to the model.
Output window. This window displays status information that relates to builds and deployments.
The tabular model designer also contains extra menu items, including Model, Table, and Column.
After creating a tabular data model in SQL Server Data Tools, you can import the necessary data and
metadata by using the Get Data functionality. This creates all of the metadata structures that underpin a
tabular data model. You do not need to create data source views, dimensions, or cubes.
This naming format ensures that every workspace database has a unique name.
The workspace database is an in-memory database that contains all of the data and metadata for the
project while it is being developed. All of the changes that you make to the model in SQL Server Data
Tools, such as creating hierarchies or adding linked tables, result in updates to the workspace database.
Deploying the model creates a new database—a renamed copy of the workspace database—on the
designated instance of SQL Server Analysis Services.
You cannot create tabular data model projects by using the Import from PowerPivot template.
MCT USE ONLY. STUDENT USE PROHIBITED
7-6 Implementing a Tabular Data Model by Using SQL Server Analysis Services
You cannot use the Backup to disk option in the Data Backup property.
You might experience slower performance because of the latency introduced by using a remote
server.
The Workspace Server property enables you to specify the instance of SQL Server Analysis Services
that hosts the workspace database.
The Workspace Retention property defines what happens to the in-memory workspace database
when you close a tabular data model project. The default Workspace Retention setting is Unload
from memory, which removes the database from memory and stores it on disk. This setting frees up
memory, but the model takes longer to load when you reopen the project. You can also configure the
Workspace Retention setting to keep the workspace database both in memory and on disk when
you close a project, or to delete it completely. If you choose this last option, the workspace database
is recreated every time you open the project.
Note: The default host for new workspace databases is defined in the Default workspace
server setting on the Workspace Database page. To access the Workspace Database page, on
the Tools menu, click Options, and then, in the Options dialog box, expand Analysis Services
Tabular Designers, and click Workspace Database.
Question: What are the advantages and disadvantages of tabular models when compared to
multidimensional models?
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-7
Lesson 2
Creating a Tabular Data Model
A tabular data model consists of multiple tables, usually linked by using relationships. Columns in the
tables can be used as attributes and measures that enable business users to aggregate key business
values. You can organize the attributes by which values are aggregated into hierarchies to enable drill-
down and drill-up analysis.
Lesson Objectives
After completing this lesson, you will be able to:
Importing Tables
The first step in creating a tabular data model is to
import tables of data from one or more sources.
Tabular models using compatibility level of 1400
or higher use the Get Data feature to specify the
data to use. The available data sources for a
tabular model include:
File
o Excel
o Text/CSV
o XML
o JSON
Database
o Oracle database
o MySQL database
Azure®
Online Services
Other
o ODBC
o OLE DB
When importing from a database, you can filter tables to exclude columns that are not required for your
analysis. You should always aim to only import the necessary data into the data model to ensure optimal
performance and simplify the end-user experience. You should also provide a friendly name, or alias, for
the tables that you import. Tables in databases do not usually have easy-to-understand names, so
providing a friendly name will make the data easier for the end user to interpret.
You can import tables by using the Get Data feature in SQL Server Data Tools. To access this, on the
Model menu, click Import From Data Source.
Defining Measures
Measures are numeric values in your data model
that users can aggregate to analyze business
performance. Unlike traditional multidimensional
data models, in which measures can only be
defined as part of a measure group—usually
based on a fact table—tabular data models enable
you to define measures for any numeric column in
any table.
You can define measures in the Measure Grid area of the tabular model designer in SQL Server Data
Tools. Measures are usually based on a simple DAX function that is applied to a numeric column. For
example, a measure named Revenue could be defined as the sum of values in the SalesAmount column
by using the DAX expression Revenue:=Sum([SalesAmount]).
Sum is the most common aggregate function that is used to define measures, but you can also use
Average, Count, Max, Min, and many others. You can also define more complex measures that reference
multiple columns, or use custom algorithms.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-9
Demonstration Steps
Create a Tabular Data Model Project
1. Ensure that the 20768C-MIA-DC and 20768C-MIA-SQL virtual machines are both running, and then
log on to 20768C-MIA-SQL as ADVENTUREWORKS\Student with the password Pa55w.rd.
4. Start SQL Server Data Tools 2015, and then on the File menu, point to New, and then click Project.
5. In the New Project dialog box, type the following values, and then click OK:
o Name: TabularDemo
o Location: D:\Demofiles\Mod07
6. If the Tabular model designer dialog box is displayed, type the following values, and then click OK:
2. In the Get Data window, select SQL Server database, and then click Connect.
3. On the SQL Server database page, type the following values, and then click OK:
o Server: MIA-SQL
6. On the Navigator page, select the following source tables, and then click OK:
o DimCustomer
o DimDate
o DimGeography
MCT USE ONLY. STUDENT USE PROHIBITED
7-10 Implementing a Tabular Data Model by Using SQL Server Analysis Services
o DimProduct
o DimProductCategory
o DimProductSubcategory
o FactInternetSales
7. In the Query Editor, in the Queries list, click DimCustomer table and change the Name property to
Customer.
8. On the Columns menu, click Choose Columns, clear the check box for each of the following
columns, and then click OK:
o Title
o MiddleName
o NameStyle
o Suffix
o SpanishEducation
o FrenchEducation
o SpanishOccupation
o FrenchOccupation
9. In the Queries list, click DimDate and change the Name property to Date.
10. On the Columns menu, click Choose Columns, clear the check box for each of the following
columns, and then click OK:
o SpanishDayNameOfWeek
o FrenchDayNameOfWeek
o SpanishMonthName
o FrenchMonthName
o CalendarSemester
o FiscalSemester
11. In the Queries list, click DimGeography and change the Name property to Geography.
12. In the Queries list, click DimProduct and change the Name property to Product.
13. In the Queries list, click DimProductCategory and change the Name property to Product
Category.
14. In the Queries list, click DimProductSubCategory and change the Name property to Product
Subcategory.
15. In the Queries list, click FactInternetSales and change the Name property to Internet Sales.
16. On the toolbar, click Import, and then wait for the data to be imported. When the data has been
imported successfully, click Close.
17. Click each of the tabs in the model designer to see the data that has been imported into each table.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-11
1. Click the Internet Sales tab, and then click the first empty cell in the measure grid under the
SalesAmount column.
Revenue:=SUM([SalesAmount])
4. Widen the SalesAmount column, and then note that the measure is calculated and displayed as a
currency value. The formatting has been inherited from the column.
5. Select the cell that contains the Revenue measure, and then press F4 to display the properties pane.
View the Format property, which is set to Currency.
6. Create a second measure named Cost in the measure grid under the TotalProductCost column
based on the following expression, and format the Cost measure as currency:
Cost:=Sum([TotalProductCost])
2. In the Analyze in Excel dialog box, ensure that Current Windows User is selected and that the
(Default) perspective is specified, and then click OK.
3. When Excel opens, in the PivotTable Fields pane, note that the measures that you defined are
displayed under an Internet Sales measure group. The Internet Sales table is also shown in this
pane, and contains the columns in the table, including those on which the aggregated measures are
based. Some users might find this confusing so, in a future refinement of the data model, the columns
that are not useful for analysis should be hidden.
5. In the Date table, select CalendarYear so that the revenue in the PivotTable is aggregated by year.
Note that there is no indication in the Date table that tells the user if the values that are displayed
represent the order date, the due date, or the ship date that is associated with the order.
6. In the Date table, select EnglishMonthName so that the revenue is further broken down into
monthly totals. Note that the months are shown in alphabetical order instead of chronological order.
8. Keep SQL Server Data Tools open for the next demonstration.
MCT USE ONLY. STUDENT USE PROHIBITED
7-12 Implementing a Tabular Data Model by Using SQL Server Analysis Services
Managing Relationships
When you import data from a table in a relational
database, you can choose to automatically import
additional tables that have a relationship with that
table. The import process identifies related tables
by analyzing their foreign-key relationships.
However, data analysts frequently need to analyze
data that comes from multiple sources and for
which explicit relationships are not defined. You
can manually create, edit, and delete relationships
as required in tabular data model projects.
Tabular data models support multiple relationships between tables. For example, date and fact tables in
data warehouses often have multiple relationships such as order date, due date, and delivery date.
However, only one relationship is marked as being active between the tables. When you view multiple
relationships in the diagram view of the data model designer, the active relationship shows as an
unbroken line, and inactive relationships appear as dotted lines.
If you need to implement a “role-playing dimension”, in which multiple relationships between a fact table
and a dimension table must be active concurrently, you must import the dimension table multiple times,
assigning a different name each time, and create individual relationships between the fact table and each
copy of the dimension table. For example, if you needed to implement order date, due date, and delivery
date role-playing dimensions based on a date dimension table, you would need to import the date
dimension table three times, assigning an appropriate name to each copy of the table. You would then
create three individual relationships between each of the keys that were used for order date, due date,
and delivery date in the fact table, and the appropriate copy of the date dimension table.
Configuring Columns
The columns in the tables that you import into a
tabular data model become the attributes by
which analysts can aggregate measures for
analysis. For example, a Customer table might
include City and Gender columns, enabling
analysts to aggregate numerical measures such as
revenue by city, or order quantity by customer
gender.
Manage relationships.
Demonstration Steps
Manage Relationships
1. Ensure that you have completed the previous demonstration in this module.
2. In SQL Server Data Tools, with the Model.bim pane visible, on the Model menu, point to Model
View, and then click Diagram View. The tables are shown as a schema diagram, with lines between
them to denote relationships. Note that there are three relationships between the Internet Sales
table and the Date table.
3. Double-click the solid line between the Internet Sales and Date tables. Note the columns that are
used to define this relationship, and that this is an active relationship, and then click Cancel.
4. Double-click each of the dotted lines between the Internet Sales and Date tables, and then click
Cancel. In each case, note the columns that are used to define these relationships and that these are
inactive relationships, and then click Cancel.
MCT USE ONLY. STUDENT USE PROHIBITED
7-14 Implementing a Tabular Data Model by Using SQL Server Analysis Services
5. Right-click each dotted relationship line in turn, and then click Delete. When you are prompted to
permanently delete the relationship from the model, click Delete from Model.
6. Double-click the remaining solid line between the Internet Sales and Date tables.
7. In the Edit Relationship dialog box, in the Columns list for the Internet Sales table, select
OrderDateKey and then click OK (if it is already selected, click Cancel), This ensures that the active
relationship is based on the order date, not the shipping date or due date.
8. Right-click the Date table title bar, click Rename, and then rename the table to Order Date.
10. On the Navigator page, select the DimDate table, and then click OK.
11. In the Query Editor, in the Queries list, click DimDate table and change the Name to Ship Date.
12. On the Columns menu, click Choose Columns, clear the following columns, and then click OK:
o SpanishDayNameOfWeek
o FrenchDayNameOfWeek
o SpanishMonthName
o FrenchMonthName
o CalendarSemester
o FiscalSemester
13. Click Import, and then wait for the table to be imported. When it has been imported successfully,
click Close.
14. Arrange the diagram so that you can see the Ship Date and Internet Sales tables, and then drag the
ShipDateKey column from the Internet Sales table to the DateKey column in the Ship Date table
to create the relationship. If the Ship Date table does not appear, refresh the page.
Rename and Hide Columns
1. Click the title bar of the Order Date table, and then click its Maximize icon.
2. In the maximized Order Date table, click the DateKey column, hold down CTRL, click the
DayNumberOfWeek and MonthNumberOfYear columns to select them, right-click any of the
selected columns, and then click Hide from Client Tools.
3. In the maximized Order Date table, right-click the FullDateAlternateKey column, click Rename, and
then rename the column to Date.
1. On the Model menu, point to Model View, and then click Data View.
3. On the Column menu, point to Sort, and then click Sort by Column.
4. In the Sort by Column dialog box, in the Sort column, ensure that Weekday is selected, in the By
column, select DayNumberOfWeek, and then click OK.
6. On the Column menu, point to Sort, and then click Sort by Column.
7. In the Sort by Column dialog box, in the Sort column, ensure that Month is selected, in the By
column, select MonthNumberOfYear, and then click OK.
2. In the Analyze in Excel dialog box, ensure that Current Windows User is selected and that the
(Default) perspective is specified, and then click OK.
3. When Excel opens, in the PivotTable Fields pane, note that the measures that you defined are still
displayed under an Internet Sales measure group, but that the Internet Sales table is no longer
shown here because all other columns have been hidden.
5. In the Order Date table, select CalendarYear so that the revenue in the PivotTable is aggregated by
year based on the order date.
6. In the Order Date table, select Month so that the revenue is further broken down into monthly
totals. Note that the months are now shown in chronological order.
7. In the Order Date table, select CalendarQuarter, and then note that the quarter is shown under
each month.
8. In the PivotTable Fields pane, in the Rows area, drag CalendarQuarter so that it is above Month,
and the PivotTable shows the correct hierarchy for year, quarter, and month. This user experience
could be improved by enabling users to select a hierarchy that automatically enables them to drill
down to the correct levels.
9. Close Excel without saving the workbook.
10. Keep SQL Server Data Tools open for the next demonstration.
Creating Hierarchies
A hierarchy is a collection of attributes from a
single table and it is organized as parent and child
nodes. You create hierarchies to simplify the end-
user experience and enable drill-up and drill-down
aggregations. For example, you might have
Product Category, Subcategory, and Product
Name columns in a table. These values represent a
natural hierarchy in which you can organize data,
enabling users to view aggregations such as total
sales revenue at the Product Category, Product
Subcategory, and Product Name levels. Another
MCT USE ONLY. STUDENT USE PROHIBITED
7-16 Implementing a Tabular Data Model by Using SQL Server Analysis Services
You can manage hierarchies for data in a table by maximizing the table in the diagram view of the data
model designer. To create a hierarchy, on the title bar of the maximized table, click the Create Hierarchy
icon. To add a column to a hierarchy, in the maximized table, right-click the column, point to Add to
Hierarchy, and then click the name of the hierarchy.
Hierarchies with a differing number of levels are called ragged hierarchies. By default, these hierarchies
display blanks for levels with no data. You can set the Hide Members property of the hierarchy to Hide
blank members to stop displaying these levels.
Create a hierarchy.
Demonstration Steps
Create a Hierarchy
1. Ensure that you have completed the previous demonstrations in this module.
2. In SQL Server Data Tools, with the Model.bim pane visible, on the Model menu, point to Model
View, and then click Diagram View.
3. Maximize the Order Date table, and then on its title bar, click the Create Hierarchy icon. Name the
new hierarchy Calendar Date.
4. Drag the CalendarYear column to the Calendar Date hierarchy.
8. Restore the Order Date table, and then on the File menu, click Save All.
2. In the Analyze in Excel dialog box, ensure that Current Windows User is selected and that the
(Default) perspective is specified, and then click OK.
3. When Excel opens, select the Revenue measure so that it is summarized in the PivotTable.
4. In the Order Date table, select Calendar Date so that the revenue in the PivotTable is aggregated by
year.
5. In the PivotTable, expand the years to show the revenue by quarter, expand the quarters to view
revenue by month, and then expand the months to view revenue for individual dates.
7. Keep SQL Server Data Tools open for the next demonstration.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-17
Verify the correctness of the statement by placing a mark in the column to the right.
Statement Answer
Lesson 3
Using a SQL Server Analysis Services Tabular Model in an
Enterprise BI Solution
SQL Server Analysis Services includes tabular data model capabilities that can be useful in an enterprise BI
scenario. It enables you to define perspectives as subsets of the data model for specific user groups, and
partition the tables in the data model to improve data refresh processing performance. There is also a
choice of query modes to help you to optimize the right balance of query and processing performance,
and the ability to define security restrictions on a data model.
Lesson Objectives
After completing this lesson, you will be able to:
Perspectives
Tabular data models can contain large numbers of
tables and measures, which can make it difficult
for users to work with the data in a client tool such
as Excel. You can simplify the user experience by
creating perspectives that display only a subset of
the tables, columns, and measures in a model. For
example, the tables in your tabular data model
might contain many different types of data, such
as human resources, sales, products, promotions,
and financial data. However, users who want to
analyze sales performance will probably not need
to view the financial or human resources tables, so
you could create a perspective where these are explicitly excluded. When users connect to the model with
this perspective, they will not see the excluded tables in their client application.
Creating Perspectives
You can create a perspective in a tabular data model by using the Perspectives dialog box in SQL Server
Data Tools. To open this dialog box, on the Model menu, click Perspectives, and then click Create and
Manage.
When you create a perspective, you must provide a name for it and specify the tables, measures, and
columns to include. When users connect to the model, they will be able to select the perspective that they
want to use. You should ensure that the names that you give to perspectives are descriptive and easy to
understand. To speed up the process, you can also create a perspective by copying an existing similar one.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-19
Partitions
Partitions enable you to manage large tables more
efficiently. You can divide a table into logical units
that you can load or reload individually. For
example, you could use a large table called Sales
in your tabular data model with a data warehouse
fact table, which is updated daily, as the source. In
this example, the data would quickly go out of
date. You could refresh the data in Sales, but this
operation is time-consuming because it reloads all
of the rows from the source table. To keep Sales
synchronized with the source table more
efficiently, you could create partitions that divide
up the table, perhaps by using the month or year of the order date. Then, you would only need to
regularly refresh the partition that contains the most recent data, updating the other partitions only when
required.
Note: Partitions in tabular data models are not intended to improve query performance in
the way that partitions in other types of databases can. Partitioning can, however, improve the
performance of data model processing by enabling you to process only partitions that contain
new or updated data.
Creating Partitions
Every table that you import into a tabular data model has a single partition that is associated with it by
default. This enables you to refresh each table separately. During the development stage, you can create a
new partition in a tabular data model by performing the following steps:
1. In SQL Server Data Tools, in the tabular model designer, on the Table menu, and then click
Partitions.
2. In the Partition Manager dialog box, select the table for which you want to create a partition, and
then click New. You can also create a partition by copying an existing one.
3. To select the rows to include in the partition, use the Table Preview pane, or use the Query Editor
pane to define a Transact-SQL query. The partitions that you create in this way are added to the
workspace database for the project.
For tabular data models that are deployed to an instance of SQL Server Analysis Services, you can create
and manage partitions by using SQL Server Management Studio.
MCT USE ONLY. STUDENT USE PROHIBITED
7-20 Implementing a Tabular Data Model by Using SQL Server Analysis Services
Process Add. This option updates tables or partitions by only adding new data.
You can process partitions by using the Process Partitions dialog box. To access the Process Partitions
dialog box in SQL Server Data Tools, on the Model menu, point to Process, and then click Process
Partitions. To access the Process Partition(s) dialog box in SQL Server Management Studio, right-click
the table that you need to update, point to Partitions, and then click Process.
You can also use SQL Server Management Studio to process tabular databases, tables, or partitions. For
example, to process a database, right-click the database, and then click Process Database, select a
processing type, and then click OK.
Note: When you process a table or database with more than one partition, the partitions
are processed in parallel in order to maximize performance. By using the TMSL Sequence
command, you can specify sequential processing, in which each partition is processed in turn but
this is beyond the scope of this course.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-21
For more information about the Sequence command, see Sequence command (TMSL) in Microsoft Docs:
DirectQuery Mode
The xVelocity engine provides in-memory storage
and data processing for very fast query handling,
and is appropriate for most tabular data models in
SQL Server Analysis Services. However, you can
also configure a tabular data model to bypass the
xVelocity engine and route queries directly to the
underlying data source by using DirectQuery
mode. This option might be suitable in the
following circumstances:
For tabular data models that need to contain up-to-date information and for which frequent
processing is impractical. DirectQuery retrieves source data directly, providing access to the most
recent data.
For organizations that have invested in high-specification data warehouse hardware that can deliver
excellent performance. DirectQuery enables companies to take advantage of their hardware
performance while still providing access to data through a tabular data model. In this situation, you
should test thoroughly to determine whether you can achieve the best performance by relying on the
data warehouse hardware or by using the xVelocity engine.
DirectQuery only supports a single data source, which must be a SQL Server relational database, an
Oracle relational database, or a Teradata relational database.
You cannot use certain DAX functions, such as those for time intelligence, in the model. Others, such
as certain statistical functions, might behave differently in DirectQuery mode.
There are limitations to the Multidimensional Expressions (MDX) that you can use in DirectQuery
mode.
For further details about the limitations of features that you can use in DirectQuery mode, see the
Restrictions section of DirectQuery Mode (SSAS Tabular) in Microsoft Docs:
DirectQuery Mode (SSAS Tabular)
http://aka.ms/M6m6uz
MCT USE ONLY. STUDENT USE PROHIBITED
7-22 Implementing a Tabular Data Model by Using SQL Server Analysis Services
Database Permissions
You can use Role Manager to define database permissions for roles. You can define permissions that allow
five levels of access to a tabular data model database. They are:
Read. This permission gives role members read access to the data, but they cannot see the model in
SQL Server Management Studio.
Read and Process. This permission gives role members read access to the database and allows them
to process data, but they cannot see the model in SQL Server Management Studio.
Process. This permission gives role members the ability to process data in the database.
Administrator. This permission gives role members rights to read, process, and modify the data.
None. This permission prevents role members from accessing the data.
You can also define database permissions for roles by using SQL Server Management Studio.
Row-Level Security
You can create DAX expressions that filter the rows that role members can see. DAX filters are expressions
that evaluate to TRUE or FALSE. Rows that evaluate to TRUE are visible to role members. For example, the
expression in the following code example filters the Region column in the Sales Territory table:
='Sales Territory'[Region]="France"
The rows that contain the value France evaluate to TRUE, so they are visible to role members. Rows that
contain other values in the Region column are not visible.
You can only define DAX filters for roles that have the Read and Read and Process database permissions.
Roles that have None or Process permissions cannot view any data, so filters are irrelevant. Roles that
have the Administrator permission can view all data. You can test the database permissions and row-
level filters that you define by using the Analyze in Excel option in SQL Server Data Tools, and
connecting as a specific role.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-23
Object-Level Security
You can also use object-level security for tables and columns to restrict access to sensitive data and object
names when you do not want a user to know that a table exists. You configure object-level security using
JSON-based metadata, Tabular Model Scripting Language (TMSL), or Tabular Object Model (TOM), setting
the metadataPermission property of the tablePermissions or columnPermissions object.
You can control this process by using the Deployment Options and Deployment Server settings in the
project properties in SQL Server Data Tools. To access the project properties, in Solution Explorer, right-
click the project, and then click Properties.
Processing Option. Use this setting to define how the new database is processed. There are three
options:
o Default. When you select this option, SQL Server Analysis Services detects the state of the
database and processes the data and metadata accordingly.
o Full. When you select this option, SQL Server Analysis Services processes all data and metadata.
o Do Not Process. When you select this option, SQL Server Analysis Services deploys only the
metadata.
Transactional Deployment. By default, SQL Server Analysis Services will deploy objects even if
processing for those objects fails. You can use this option to force deployment to fail if processing
fails.
Server. Use this option to specify the name of the deployment server.
Edition. Use this option to specify the edition of the instance of SQL Server Analysis Services on the
deployment server.
Database. Use this option to specify the name of the database on the deployment server.
Model Name. Use this option to specify the name that client tools see when they connect to the
model.
MCT USE ONLY. STUDENT USE PROHIBITED
7-24 Implementing a Tabular Data Model by Using SQL Server Analysis Services
For further details about how to create a BI semantic model connection, see Create a BI Semantic Model
Connection to a Tabular Model Database in Microsoft Docs:
Create a BI Semantic Model Connection to a Tabular Model Database
http://aka.ms/jc2xy0
Demonstration Steps
Deploy a Tabular Data Model Project
1. Ensure that you have completed the previous demonstrations in this module.
2. In SQL Server Data Tools, in Solution Explorer, right-click the TabularDemo project, and then click
Properties.
3. In the TabularDemo Property Pages dialog box, type the following values, and then click OK:
o Server: localhost\SQL2
o Database: DemoDB
4. On the Build menu, click Deploy TabularDemo. If you are prompted for impersonation credentials,
type the user name ADVENTUREWORKS\ServiceAcct and the password Pa55w.rd, and then click
OK.
5. In the Deploy dialog box, when deployment has completed, click Close.
2. On the Data tab, in Get External Data area, in the From Other Sources drop-down list, select From
Analysis Services.
3. In the Data Connection Wizard dialog box, in the Server name box, type MIA-SQL\SQL2, ensure
that Use Windows Authentication is selected, and then click Next.
4. On the Select Database and Table page, ensure that the DemoDB database and the Internet Sales
cube are selected, and then click Next.
5. On the Save Data Connection File and Finish page, click Finish.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-25
6. In the Import Data dialog box, ensure that the Existing worksheet option is selected, and then click
OK.
8. In the PivotTable Fields pane, under Order Date, select the Calendar Date hierarchy.
9. In the PivotTable Fields pane, under Geography, drag EnglishCountryRegionName to the
Columns area.
10. Explore the data in the PivotTable. When you have finished, close Excel without saving the workbook.
Objectives
After completing this lab, you will be able to:
Password: Pa55w.rd
4. Create Measures
o DimDate
o DimEmployee
o DimGeography
o DimProduct
o DimProductCategory
o DimProductSubcategory
o DimReseller
o FactResellerSales
2. Filter the following tables to remove the columns listed below:
DimDate
o SpanishDayNameOfWeek
o FrenchDayNameOfWeek
o DayNumberOfYear
o WeekNumberOfYear
o SpanishMonthName
o FrenchMonthName
o CalendarSemester
o FiscalSemester
DimEmployee
o SalesTerritoryKey
o NameStyle
o Title
o HireDate
o BirthDate
o LoginID
o EmailAddress
o Phone
o MaritalStatus
o EmergencyContactName
o EmergencyContactPhone
o SalariedFlag
o Gender
o PayFrequency
MCT USE ONLY. STUDENT USE PROHIBITED
7-28 Implementing a Tabular Data Model by Using SQL Server Analysis Services
o Baserate
o VacationHours
o SickLeaveHours
o CurrentFlag
o SalesPersonFlag
o StartDate
o EndDate
o Status
DimGeography
o SpanishCountryRegionName
o FrenchCountryRegionName
o IpAddressLocator
DimProduct
o WeightUnitMeasureCode
o SizeUnitMeasureCode
o SpanishProductName
o FrenchProductName
o FinishedGoodsFlag
o SafetyStockLevel
o ReorderPoint
o DaysToManufacture
o ProductLine
o DealerPrice
o Class
o Style
o ModelName
o FrenchDescription
o ChineseDescription
o ArabicDescription
o HebrewDescription
o ThaiDescription
o GermanDescription
o JapaneseDescription
o TurkishDescription
o StartDate
o EndDate
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-29
o Status
DimProductCategory
o SpanishProductCategoryName
o FrenchProductCategoryName
DimProductSubcategory
o SpanishProductSubcategoryName
o FrenchProductSubcategoryName
DimReseller
o OrderFrequency
o OrderMonth
o FirstOrderYear
o LastOrderYear
o ProductLine
o AddressLine1
o AddressLine2
o AnnualSales
o BankName
o MinPaymentType
o MinPaymentAmount
o AnnualRevenue
o YearOpened
FactResellerSales
o DueDateKey
o PromotionKey
o CurrencyKey
o SalesTerritoryKey
o RevisionNumber
o CarrierTrackingNumber
o CustomerPONumber
o DueDate
o Quantity:=Sum([OrderQuantity])
o Cost:=Sum([TotalProductCost])
o Revenue:=Sum([SalesAmount])
MCT USE ONLY. STUDENT USE PROHIBITED
7-30 Implementing a Tabular Data Model by Using SQL Server Analysis Services
2. Format the Quantity measure as a whole number that includes a thousand separator, and ensure that
the Cost and Revenue measures are formatted as currency values.
o Aggregated measures from the Reseller Sales table are easily confused with the columns on
which they are based.
Results: After this exercise, you should have created a tabular data model project.
1. Configure Relationships
2. Rename and Hide Columns
4. Create Hierarchies
2. Make the active relationship the one based on the order date, delete all other relationships between
these tables, and then rename the Date table to Order Date.
3. Open the existing connection to the AdventureWorksDW database, and then import the DimDate
table again:
o Use the ADVENTUREWORKS\ServiceAcct account with the password Pa55w.rd if you are
prompted for impersonation credentials.
o Use the friendly name Ship Date for the DimDate table.
o Filter the table to delete the following columns:
SpanishDayNameOfWeek
FrenchDayNameOfWeek
DayNumberOfYear
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-31
WeekNumberOfYear
SpanishMonthName
FrenchMonthName
CalendarSemester
FiscalSemester
4. Create a relationship between the Reseller Sales and Ship Date tables based on the ShipDateKey
and DateKey columns.
2. In the Reseller table, hide the ResellerKey, GeographyKey, and ResellerAlternateKey columns, and
then rename the columns as shown in the following table:
NumberEmployees Employees
DepartmentName Department
MCT USE ONLY. STUDENT USE PROHIBITED
7-32 Implementing a Tabular Data Model by Using SQL Server Analysis Services
4. In the Order Date table, hide the DateKey, DayNumberOfWeek, and MonthNumberOfYear
columns, and then rename the columns as shown in the following table:
FullDateAlternateKey Date
EnglishDayNameOfWeek Weekday
EnglishMonthName Month
5. In the Ship Date table, hide the DateKey, DayNumberOfWeek, and MonthNumberOfYear
columns, and then rename the columns as shown in the following table:
FullDateAlternateKey Date
EnglishDayNameOfWeek Weekday
EnglishMonthName Month
EnglishDescription Description
2. In the Order Date table, configure the sort orders of the following columns:
o Country or Region
o State or Province
o City
o Postal Code
2. In the Order Date table, create a hierarchy named Calendar Date that contains the following fields:
o Calendar Year
o Calendar Quarter
o Month
o Day of Month
MCT USE ONLY. STUDENT USE PROHIBITED
7-34 Implementing a Tabular Data Model by Using SQL Server Analysis Services
3. In the Order Date table, create a second hierarchy named Fiscal Date that contains the following
fields:
o Fiscal Year
o Fiscal Quarter
o Month
o Day of Month
2. When you have finished, close Excel without saving the workbook.
Results: After completing this exercise, you should have a tabular data model that includes renamed
columns, custom sort orders, and specific relationships between tables.
2. Create a Perspective
3. Set the Before 2008 partition to only show records in the Reseller Sales table that have an order
date before 2008.
4. Set the Since 2008 partition to only show records in the Reseller Sales table that have an order date
that is greater than or equal to January 1, 2008.
5. Use SQL Server Data Tools to process both partitions, using Process Full mode.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 7-35
2. View the data model in Excel by using the Products Analysis perspective. Note that only the tables
that you specified for the perspective are visible.
3. When you have finished, close Excel without saving the workbook.
2. Set a row filter, so that the new role only shows reseller sales where the value of the Category column
in the Product Category table is Bikes, and the value of the Country or Region Code column in the
Geography table is US.
3. View the data model in Excel by using the US Bike Sales role. Note that the reseller data is only
showing where the location is the United States and product category is Bikes.
4. When you have finished, close Excel without saving the workbook.
o The project should be deployed to the localhost\SQL2 instance of SQL Server Analysis Services.
o The deployed database should be named AdventureWorksTab.
2. Build and deploy the project, and then close SQL Server Data Tools.
o Use the From Analysis Services source on the Data tab of the ribbon.
o Connect to the MIA-SQL\SQL2 instance of SQL Server Analysis Services by using Windows
authentication.
2. Explore the data in the PivotTable. When you have finished, close Excel without saving the workbook.
Results: After this exercise, you should have deployed the tabular data model project.
MCT USE ONLY. STUDENT USE PROHIBITED
7-36 Implementing a Tabular Data Model by Using SQL Server Analysis Services
Module 8
Introduction to Data Analysis Expressions (DAX)
Contents:
Module Overview 8-1
Lesson 1: DAX Fundamentals 8-2
Module Overview
You can extend Microsoft® SQL Server® Analysis Services tabular data models by using the Data Analysis
Expressions (DAX) language. DAX is a highly flexible language that enables you to create measures and
calculated columns for use in PivotTable tables and PivotChart charts.
Objectives
This module explains the fundamentals of the DAX language. It also explains how you can use DAX to
create calculated columns and measures, and how you can use them in your tabular data models.
Lesson 1
DAX Fundamentals
To use DAX effectively, you should understand the components of the language and its capabilities. This
lesson explains the fundamentals of DAX and provides an overview of its functionality.
Lesson Objectives
After completing this lesson, you will be able to:
Overview of DAX
The DAX language consists of a library of
functions, operators, and constants—you can use
these to create formulas that define the calculated
columns and measures to extend the functionality
of tabular data models. DAX was introduced in the
first version of the PowerPivot for Excel® add-in,
as the language for writing the formulas that
define business logic in PowerPivot for Excel
workbooks. In SQL Server, you can use DAX in
tabular data models in SQL Server Analysis
Services, in addition to those you create in
PowerPivot for Excel workbooks, and in Power BI
Desktop.
DAX Syntax
DAX is based on the Microsoft Excel formula syntax and uses a range of functions, operators, and values.
However, unlike formulas in Excel, DAX does not work on individual cells or ranges of cells. Instead, you
use it to work with the relational columns and tables that you import into a tabular data model. DAX also
includes more advanced functionality provided by Excel formulas. The similarity between DAX and Excel
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-3
formulas minimizes the learning time for information workers who want to learn to use DAX, enabling
faster adoption of the language and reducing the need for training.
For links to the DAX documentation, see Data Analysis Expressions (DAX) Reference in the Microsoft
Developer Network:
DAX Functions
DAX provides a range of functions you can use to
build formulas. Many of these functions are the
same as or similar to those used to build formulas
in Excel. DAX, however, includes many additional
functions that help you to create much more
complex and sophisticated reports than you can
by using only Excel functions. For example, DAX
includes functions that can navigate table
relationships, take account of context to calculate
values in PivotTable tables, or compare time
periods to produce the desired result. A DAX
formula can contain multiple functions that can be
nested within other functions (up to 64 levels deep).
Note: You should avoid having too many levels of nesting in your formulas because it
makes them difficult to understand and troubleshoot.
Information. These functions include PATH, ISBLANK, and ISERROR. They enable you to test row
values to see whether they match a type of value, such as an error or a null, and to handle
relationships in a table. This category also includes functions such as USERNAME, which you can use
to implement row-level security in SQL Server Analysis Services tabular data models.
Filter and value. These functions include CALCULATE, ALL, and FILTER. You can use them to
manipulate data in a variety of ways, such as modifying the context for calculations, or using the
relationships between tables to return specific results. There is no direct equivalent of these functions
in Excel.
Logical. These functions include TRUE, IF, SWITCH, and NOT. With these functions, you can perform
logical tests on expressions to return information about the state of the tested values, and to use
conditional logic.
Mathematical and trigonometric. These functions include ROUND, FLOOR, and POWER. They are
similar to the mathematical and trigonometric functions in Excel.
Statistical and aggregation. These functions include SUM, COUNT, RANKX, and DISTINCTCOUNT.
They are similar to aggregation functions in Excel.
MCT USE ONLY. STUDENT USE PROHIBITED
8-4 Introduction to Data Analysis Expressions (DAX)
Date and time. These functions include DATE, MONTH, and YEAR. They are equivalent to date and
time functions in Excel.
Navigation and Lookup. DAX is designed to work with multiple tables and columns in a tabular data
model. It provides functions such as RELATEDTABLE, USERELATIONSHIP, CROSSJOIN, and
LOOKUPVALUE, which you can use to combine data from multiple tables. You can also use functions
such as PATH and PATHITEM to define navigable hierarchies of column values in a single table.
For complete documentation about the functions supported by DAX, see DAX Function Reference in the
Microsoft Developer Network:
DAX functions use tables and columns as inputs. To avoid ambiguity, you should use fully qualified
names when referencing columns. A fully qualified name uniquely identifies a column because it
includes the name of the table to which the column belongs. Use square brackets around the column
names and single straight quotation marks around table names that contain spaces; for example,
'Order Date'[Calendar Year]. You can use unqualified names to refer to columns in the same table.
For example, when used in the context of the Order Date table, the 'Order Date'[Calendar Year]
column can be referenced as [Calendar Year].
When you are writing and referencing one measure to another, you should enclose the measure
name in square brackets; for example, [Total Profit].
Although DAX formulas are similar to Excel formulas, there are two important differences:
Excel formulas can reference ranges of cells or individual cells. DAX formulas can only act on
complete tables or columns of data. To work with a subset of rows in a table or column, you must use
a filter function to restrict the data.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-5
The data types supported by DAX formulas are not identical to the data types recognized by Excel
formulas.
For more information about DAX syntax, see DAX Syntax Reference in the Microsoft Developer Network:
Operators
DAX operators are very similar to operators in Excel formulas. The following operators are supported by
DAX:
Arithmetic:
o +. Addition
o -. Subtraction
o *. Multiplication
o /. Division
o ^. Exponentiation
Comparison:
o =. Equal
o <. Less than
Text concatenation:
Logical:
o ||. Logical OR
For more information about DAX operators, see DAX Operator Reference in the Microsoft Developer
Network:
Data Types
DAX will implicitly convert data types where possible, so there is no need to explicitly convert a column to
a different data type. For example, if you enter a date as a string and use that value in a date function,
DAX will attempt to convert the data type to Date. There are no DAX functions for explicitly converting
data types.
MCT USE ONLY. STUDENT USE PROHIBITED
8-6 Introduction to Data Analysis Expressions (DAX)
I8 (eight-byte integer).
String.
Date/time.
Currency.
BLANK. Represents a blank or missing value or an empty cell in an Excel worksheet. You can test for
blank values by using the ISBLANK function.
Table. Used by functions that either require a table as input or return a table.
Note: BLANK and NULL are not the same thing. Handling of BLANK data types varies,
depending upon the operation that you perform. For example, BLANK + 5 = 5, but BLANK * 5 =
BLANK. However, in the SQL Server Database Engine, both NULL + 5 and NULL * 5 result in a
NULL value. Database Engine NULL values are implicitly converted to BLANK values when you
import data into a tabular data model.
Aggregations
Information workers are typically interested in
finding answers to questions such as: "How much
revenue did the company generate though its
Internet sales channel in April?" or: "What was the
best-selling product in France last year?" To
answer these kinds of questions, you must group
and aggregate data. You group data by using
values that give meaning and context, such as
Product Category or Sales Region. These values
are usually stored in the tables you import from
data sources. You can aggregate data by using
DAX aggregation functions. The following are
commonly used aggregation functions:
SUM
Adds up the values in a numeric column, providing a single total for that column.
For example, the following code totals all the values in the Sales Amount column in the Reseller Sales
table:
DAX SUM
=SUM('Reseller Sales'[Sales Amount])
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-7
SUMX
Filters and then adds up the values in a numeric column, returning a single total for that filtered column.
For example, the following code returns the total of the Freight column in the Internet Sales table, but
the calculation only includes rows for which the SalesTerritoryKey value is 5:
DAX SUMX
=SUMX(FILTER('Internet Sales', 'Internet Sales'[SalesTerritoryKey]=5),[Freight])
COUNT
Returns a count of the number of rows that are not blank for columns containing either numbers or dates.
COUNTA is similar, but returns a count of the number of rows that are not blank for columns containing
non-numeric values.
For example, the following code returns a count of the rows in the Order Date column in the Reseller
Sales table:
DAX COUNT
=COUNT('Reseller Sales'[Order Date])
COUNTAX
Filters and then counts the number of values that are not blank in a column and returns a single count for
that filtered column. The COUNTX function works in the same way as COUNTAX, but only counts numeric
values. The COUNTBLANK function returns the number of blank values in a column, and the
COUNTROWS function counts the number of rows in a table.
For example, the following code returns the number of rows in the Phone column in the Reseller table,
where the value in the Status column is set to "Active":
DAX COUNTX
=COUNTAX(FILTER('Reseller',[Status]="Active"),[Phone])
The following code example returns the maximum value for the Sales Amount column in the Reseller Sales
table:
DAX MAX
=MAX('Reseller Sales'[Sales Amount])
Return the maximum and minimum values in a column in a table filtered by using an expression.
For example, the following code returns the minimum value for the Freight column in the Internet Sales
table for which the corresponding SalesTerritoryKey value is 5:
DAX MINX
=MINX(FILTER('Internet Sales', [SalesTerritoryKey] = 5),[Freight])
MCT USE ONLY. STUDENT USE PROHIBITED
8-8 Introduction to Data Analysis Expressions (DAX)
AVERAGE
Returns the mean of all values in a numeric column. The AVERAGEA function does the same thing as
AVERAGE, but also handles non-numeric data types.
For example, the following code returns the average value in the Total Product Cost column in the
Reseller Sales table:
DAX AVERAGE
=AVERAGE('Reseller Sales'[Total Product Cost])
AVERAGEX
Enables you to supply an expression to obtain the average of values that are not neatly contained in a
single column.
For example, the following code sums the Freight and TaxAmt values for each row in the Internet Sales
table, and then calculates the average value:
DAX AVERAGEX
=AVERAGEX('Internet Sales', 'Internet Sales'[Freight]+ 'Internet Sales'[TaxAmt])
Using Aggregations
When you add a column to the Values area in the PowerPivot Field List in a PowerPivot for Excel
worksheet, column values are automatically summed and the total added to the PivotTable table or
PivotChart chart that you are using. If you need to summarize the data differently, you can select another
type of aggregation, such as COUNT, MIN, or AVERAGE, from a list. The DAX formula is then
automatically created for you. When you need to create aggregations more complex than this, you can
create a measure.
For a complete list of statistical and aggregate functions in DAX, see Statistical Functions (DAX) in the
Microsoft Developer Network:
Context
When you create a DAX measure or calculated
column, you define a field you can use in a
PivotTable or a PivotChart. However, the specific
values appearing in any given PivotTable or
PivotChart will depend on the context, such as the
columns and rows added to a PivotTable or a
PivotChart, or the slicers that are enabled at the
time. For example, if you create a PivotTable and
add only the Sum of Sales Amount measure to
the Values area and nothing to the Row Labels
area, you will see a single value representing the
total sales amount for all categories, years, and
countries in the Reseller Sales channel. If you then add Calendar Year to the Row Labels area, you will
see multiple values, each one a total for a given year. Even though the same measure is used in both
cases, the displayed value changes to reflect the context. This context-aware behavior makes it possible to
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-9
perform dynamic analysis of data quickly and easily, without needing to reconfigure PivotTables or
PivotCharts whenever you add a new measure.
It is important to be aware of context when you create measures and calculated columns. If you do not
take context into account, you might find your reports do not aggregate data in the way you intended,
and are inaccurate and misleading.
Every DAX expression has two contexts; a row context, and a filter context.
Row Context
The row context of a DAX expression corresponds to a single row in the source data. Row context is used
when you use functions that operate on two or more columns in the same row.
For example, the formula in the following code references the First Name and Last Name columns in the
Employee table:
The calculated column evaluates the expression for each row. It uses the row context to obtain the values
in the First Name and Last Name columns for each row, and then uses these values to create a new
value for each row by concatenating them. Row context is important when using any function that
evaluates an expression for each row in a table, such as SUMX.
Filter Context
The filter context of a DAX expression is made up of all the filters that are applied to the data when the
expression is evaluated. Filter context is most obviously seen in PivotTables; when you add columns to the
Rows or Columns area of a PivotTable, aggregated columns in the Values are split according to the row
and column values. The row and column values define the filter context for each value cell. PivotTable
slicers also affect the filter context by excluding some values from the PivotTable.
Filter context is important in DAX because you can use DAX functions to modify the row and query
contexts by creating filters in formulas. You can use the FILTER function to produce a subset of rows on
which you can perform a calculation. For example, you might filter by specifying a product category, then
aggregate the sales amount for that category only. You can override filters by using the ALL and
ALLEXCEPT functions. ALL forces all filters to be ignored, and ALLEXCEPT helps you to selectively override
them by specifying particular columns to retain in the filter context—all other columns are ignored.
Query Context
When you add a measure to a PivotTable, the xVelocity engine evaluates the measure value for each cell.
The evaluation takes account of the query context to calculate these values for a given cell. Query context
is determined by the row labels, column labels, filters, and slicers that apply to the PivotTable table.
Removing or adding a new slicer, row label, or column label, will change the filter context; the PowerPivot
engine must take account of the new context that is performing the calculation for each row in the query.
For more information about context, see the Context in DAX Formulas section in Understanding DAX in
Tabular Models (SSAS Tabular) in Microsoft Docs:
DAX Queries
DAX includes extensions that help you to write
queries that retrieve data. Client reporting tools,
such as Power View, use DAX to query tabular
data models in SQL Server Analysis Services. It is
unlikely that you will need to write DAX queries
manually, but a basic understanding can help with
troubleshooting.
Simple EVALUATE
EVALUATE('Reseller Sales')
Queries can include FILTER to return a reduced result set, similar to the way in which a WHERE clause
returns a reduced result set in SQL Server.
The following code example returns all the rows from the Reseller Sales table where the OrderDateKey
value is greater than 20040101:
The following code example returns all the rows from the Reseller Sales table where the OrderDateKey
value is greater than 20040101. The results are ordered by Sales Amount:
For more information about DAX queries, see DAX Queries in the Microsoft Developer Network:
DAX Queries
http://aka.ms/Rnt1dc
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-11
Lesson 2
Using DAX to Create Calculated Columns and Measures in
a Tabular Data Model
DAX creates calculated columns and measures that you can then use in PivotTable tables and PivotChart
charts in PowerPivot for Excel workbooks. This lesson shows you how to create DAX calculated columns
and measures using a variety of functions, including time intelligence functions and functions that
manipulate table relationships. This lesson also shows you how to create KPIs with DAX.
Lesson Objectives
At the end of this lesson, you will be able to:
Use measures.
Use DAX KPIs.
Calculated Columns
A calculated column is a named column that you
populate by using a DAX formula. The formula will
usually refer to other columns, either in the same
table or in a different, related table, but you can
also create calculated columns based on measures,
or on other calculated columns.
The following code example creates a column that
calculates profit by subtracting the value in the
Total Product Cost column from the value in the
Sales Amount column. You could use this DAX
expression to create a calculated column named
Sales Profit.
You can create calculated columns in a tabular data model just as you can in an Excel workbook. In the
Data View window of a data model designer, select the table to which you want to add the column, and
then click Add Column. You can then name the column and type the DAX formula in the formula bar,
which will determine the contents of the column. The xVelocity engine performs the calculation
immediately to populate the column. By default, the engine recalculates columns automatically if the
source data changes.
Note: The formula used to create a calculated column applies to every row. You cannot
apply the formula only to selected data ranges, as you can in Excel worksheets.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-13
Calculated columns calculate a value for every row in a table. This can take a long time when tables
contain a large number of rows.
Changing the names of columns referenced by a calculated column will cause an error.
For more information about DAX calculated columns, see Calculated Columns in Microsoft Docs:
Calculated Columns
http://aka.ms/She68f
Measures
A measure is a named formula that can
encapsulate complex business logic, usually by
aggregating one or more numerical values.
The following example defines a measure named
Profit that calculates the sum of the Sales Profit
column:
For more information about DAX measures, see Measures in Microsoft Docs:
Measures
http://aka.ms/K55jub
KPIs
KPIs are used to compare measures with a given
goal or target value to assess business
performance. For example, a business might set a
profit margin goal of 15 percent, and use a KPI to
indicate how actual sales results compare.
In tabular data models, KPIs are defined based on
measures, and can consist of the following
elements:
Base Value: the actual value being assessed,
calculated by a measure.
Status Thresholds: the status is an indicator of the base value’s performance against the target value.
You can set thresholds that establish the status, based on the percentage of the target value achieved
by the base value. For example, you could use a red indicator if the base value is below 20 percent of
the target value; a yellow indicator if it is between 20 and 80 percent; and a green indicator if it is
above 80 percent.
For more information about working with DAX KPIs, see KPIs in Microsoft Docs:
KPIs
http://aka.ms/Cle5ry
Create measures.
Create a KPI.
Demonstration Steps
Create Calculated Columns
1. Ensure that the 20768C-MIA-DC and 20768C-MIA-SQL virtual machines are both running, and log
on to the 20768C-MIA-SQL virtual machine as ADVENTUREWORKS\Student with the password
Pa55w.rd.
2. In the D:\Demofiles\Mod08 folder, right-click Setup.cmd and click Run as administrator. When
prompted, click Yes.
3. Start Visual Studio 2015 and open the TabularDemo.sln solution in the D:\Demofiles\Mod08
folder.
4. If the Tabular model designer dialog box appears, in the Workspace server list, specify
localhost\SQL2 and then click OK.
7. On the Model menu, point to Process, and click Process All. If you are prompted for impersonation
credentials, specify the user name ADVENTUREWORKS\ServiceAcct with the password Pa55w.rd
and click OK.
8. In the Data Processing dialog box, when all of the tables have been processed, click Close.
9. On the Customer tab, in the first empty column after the existing columns, double-click Add
Column and name the new column Full Name.
10. With the Full Name column selected, in the formula bar, enter the following DAX expression:
Wait for the table to finish updating, and note the calculated values in the new column.
11. Click the FirstName column heading, hold Shift and click the LastName column heading, and then
right-click either of the selected column headings and click Hide from Client Tools.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-15
12. On the Internet Sales tab, in the first empty column after the existing columns, double-click Add
Column and name the new column SalesProfit.
13. With the SalesProfit column selected, in the formula bar, enter the following DAX expression:
=[SalesAmount]-[TotalProductCost]
Wait for the table to finish updating, and note the calculated values in the new column.
Create Measures
1. On the Internet Sales tab, click the first empty cell in the measure grid under the SalesProfit
column.
Profit:=SUM([SalesProfit])
3. Select the cell containing the Profit measure, and press F4 to display the properties pane. Then set the
Format property to Currency.
4. Click the empty cell in the measure grid under the Profit measure.
Margin:=[Profit]/[Revenue]
6. Select the cell containing the Margin measure, and press F4 to display the properties pane. Then set
the Format property to Percentage.
7. Right-click the SalesProfit column header and click Hide from Client Tools.
Create a KPI
1. On the Internet Sales tab, click the empty cell in the measure grid under the Margin measure.
3. Select the cell containing the Margin measure, and press F4 to display the properties pane. Then set
the Format property to Percentage.
4. On the Internet Sales tab, right-click the cell in the measure grid containing the Margin measure
and click Create KPI.
5. In the Key Performance Indicator (KPI) dialog box, note that the KPI base measure (value) is
defined by the Margin measure. Then, under Target, ensure that Measure is selected and select
Target Margin.
6. Set the first status threshold to 65% and the second to 90%.
2. In the Analyze in Excel dialog box, ensure that Current Windows User is selected and that the
(Default) perspective is specified, and click OK.
3. In Excel, in the PivotTable Fields pane, in the Internet Sales table, select the Profit and Margin
measures so that they are summarized in the PivotTable.
4. In the PivotTable Fields pane, in the Customer table, select Full Name so that the PivotTable shows
profit and margin by customer.
5. In the PivotTable Fields pane, expand KPIs, expand Margin, and select Status so that an indicator
shows the KPI status for each customer.
Multiple Relationships
Most data models consist of multiple tables that
are related, based on common key values. There
are many cases where a DAX expression needs to
combine data from related tables, and DAX
provides some functions to support this
requirement.
DAX LOOKPVALUE
LOOKUPVALUE('Date'[Fiscal Year], [Full Date], [Registration Date])
The LOOKUPVALUE does not require an existing relationship between tables; it simply looks up a column
value based on the specified value for another column in the same table.
If a relationship is defined between two tables, a more effective way to look up related values is to use the
RELATED function.
For example, if a Product table is related to a Product Category table, based on a common
CategoryKey column, you could use the following expression to return the Category Name value from
the Category table into a calculated column in the Product table:
DAX RELATED
RELATED('Product Category'[Category Name])
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-17
Note that the RELATED function does not require that you specify a lookup value. It automatically uses
the active relationship between the tables to find the related value. The RELATED function works well
when you need to look up a single value from the “many” side of a one-to-many relationship. In the
example above, each category exists once in the Product Category table but many times in the Product
table.
For more information about the RELATED function, see RELATED Function (DAX) in the Microsoft
Developer Network:
Occasionally, you might want to aggregate many related values from the “one” side of the relationship.
For example, in the Product Category table, you might want to create a calculated column named
Product Count containing the total number of products in each category. To accomplish this task, you
can use the RELATEDTABLE function shown in the following example:
DAX RELATEDTABLE
COUNTX(RELATEDTABLE('Product'), [ProductKey])
For more information about the RELATEDTABLE function, see RELATEDTABLE Function (DAX) in the
Microsoft Developer Network:
Note: USERELATIONSHIP does not create a relationship. The relationship must already exist
for you to use it.
For example, the following code calculates the sum of the Sales Amount column based on shipping date:
DAX USERELATIONSHIP
=CALCULATE(SUM(Reseller Sales[Sales Amount]), USERELATIONSHIP('Reseller
Sales'[ShipDateKey], 'Date'[DateKey]))
Note: You can only use USERELATIONSHIP with other functions that accept a filter as an
argument, such as CALCULATE in the previous example.
MCT USE ONLY. STUDENT USE PROHIBITED
8-18 Introduction to Data Analysis Expressions (DAX)
For more information about the USERELATIONSHIP function, see USERELATIONSHIP Function (DAX) in the
Microsoft Developer Network:
For more information about working with relationships in tabular models, see Relationships (SSAS Tabular)
in Microsoft Docs:
Demonstration Steps
Retrieve a Value from an Unrelated Table
1. Ensure that you have completed the previous demonstration.
2. In Visual Studio, with the Model.bim pane open in data view, on the Customer tab, after the existing
columns, double-click the Add Column header and enter the column name First Fiscal Year.
3. With the First Fiscal Year column selected, in the formula bar, enter the following DAX expression:
Wait for the table to finish updating, and note the calculated values in the new column.
2. With the Country-Region column selected, in the formula bar, enter the following DAX expression:
=RELATED('Geography'[CountryRegionCode])
Wait for the table to finish updating, and note the calculated values in the new column.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-19
1. On the Customer tab, after the existing columns, double-click the Add Column header and enter the
column name Order Count.
2. With the Order Count column selected, in the formula bar, enter the following DAX expression:
Wait for the table to finish updating, and note the calculated values in the new column.
3. In Excel, in the PivotTable Fields pane, in the Internet Sales table, select the Revenue measure.
4. In the PivotTable Fields pane, in the Customer table, select First Fiscal Year so that the PivotTable
shows sales revenue by customer, based on the first year in which customers made a purchase.
5. In the PivotTable Fields pane, in the Customer table, clear First Fiscal Year and select Country-
Region so that the PivotTable shows sales revenue by customer country or region.
6. In the PivotTable Fields pane, in the Customer table, clear Country-Region and select Order
Count so that the PivotTable shows sales revenue by customer, based on the number of orders
placed.
The date table should have a continuous range of dates without gaps.
The date table column that uses the date data type should use “day” as the lowest level of granularity.
Relationships between a table containing a measure and a date table do not need to be based on
columns that use the date data type to support time intelligence functionality. Instead, you can base these
relationships on columns containing integer values. This is useful because it is likely that the databases
you use as sources for analysis will contain fact and date tables that are related by columns using the
MCT USE ONLY. STUDENT USE PROHIBITED
8-20 Introduction to Data Analysis Expressions (DAX)
integer data type—particularly if the source database is a data warehouse. For example, in the
AdventureWorksDW database, the FactResellerSales table relates to the DimDate table on the
DateKey column. To handle time intelligence correctly when integers are used in relationships, you must
manually mark the date table as Date Table and specify the column in the table that contains the date
values. This column must use the date data type.
NEXTMONTH, NEXTQUARTER, NEXTYEAR. These functions return a table that contains a range of
dates representing the time period after the current context.
SAMEPERIODLASTYEAR, PARALLELPERIOD. You can use these functions to compare measure values
across the same period in different timespans; for example, to compare sales for a month in the
current year with sales in the same month in the previous year.
TOTALMTD, TOTALQTD, TOTALYTD. These functions calculate a running total for the corresponding
time period. For example, you could use TOTALQTD to calculate sales for the quarter so far.
For more information about DAX time intelligence functions, see Time Intelligence Functions (DAX) in the
Microsoft Developer Network:
Demonstration Steps
Mark a Table As a Date Table
2. In Visual Studio, with the Model.bim pane open in data view, click the Order Date tab.
3. On the Table menu, point to Date and click the Mark As Date Table.
4. In the Mark As Date Table dialog box, select the Date column, and click OK.
2. Click the first empty cell in the measure grid, then in the formula bar, enter the following DAX
expression:
3. Select the cell containing the Previous Year Revenue measure, and press F4 to display the properties
pane. Then set the Format property to Currency.
4. In the PivotTable Fields pane, in the Order Date table, drag Calendar Date to the Rows area so
that the PivotTable shows sales revenue and previous year revenue for each year.
5. Expand 2007 and 2008, and note that the revenue for each quarter in 2007 is shown as the previous
year revenue for the same quarters in 2008.
<id_columnName> refers to the key column in a table. For example, in an Employees table, the key
column might be EmployeeID.
<parent_columnName> refers to the parent column for a key column in a table. For example, in the
Employees table, this might be ManagerID.
There are other DAX functions similar to PATHITEM that are used to work with other aspects of
hierarchical data, including PATHITEMREVERSE, PATHLENGTH, and PATHCONTAINS. For more
information about all the DAX hierarchy functions, see Parent and Child Functions (DAX) in the Microsoft
Developer Network:
<path> refers to a column that contains the results of the PATH function. In the example of an
Employees table, this could be a column named EmployeeLevels.
<type> is an optional parameter that can be used to determine the data type that the result should
be returned in. A value of 0 is text—which is the default—and a value of 1 is an integer data type.
You can use the LOOKUPVALUE and PATHITEM functions together to create a parent-child hierarchy.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-23
An additional calculated measure can be created in a calculated column that contains the following code
to populate the Name value for an employee’s immediate manager:
The calculated measure to create the second level of the employee hierarchy in a second calculated
column is shown in the following code example:
Design Considerations
When you design parent-child hierarchies in analytical data models, consider the following points:
Ensure that the parent and child keys are of compatible data types.
For the best query and processing performance, ensure that a self-join relationship exists between the
parent key and the child.
Because the manager levels are hard coded, you may need to change the data model if the
organizational structure changes—to allow more levels of management than the model defines.
For more information about working with parent-child hierarchies, see Understanding Functions for
Parent-Child Hierarchies in DAX in the Microsoft Developer Network:
http://aka.ms/Dqba35
USERELATIONSHIP
RELATEDTABLE
RELATED
LOOKUPVALUE
MCT USE ONLY. STUDENT USE PROHIBITED
8-24 Introduction to Data Analysis Expressions (DAX)
Objectives
At the end of this lab, you will be able to:
Create a KPI that uses a DAX expression for the target value.
To improve the presentation of data, you want to concatenate your employees’ first name, middle name,
and last name fields. You want to make profit more visible by creating a calculated value that subtracts a
product’s cost from its selling price. Furthermore, you want to create a calculation to improve the
categorization of products.
2. View the model, running a script in the server if prompted, then process the model using the
impersonation credentials ADVENTUREWORKS\ServiceAcct with the password Pa55w.rd.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-25
3. In the Employee table, create a custom column named Employee Name that concatenates the first
name, middle name (if there is one), and last name of the employee. You can use the following DAX
expression to do this:
=[First Name] & IF(ISBLANK([Middle Name]), "", CONCATENATE(" ", [Middle Name])) &
CONCATENATE(" ", [Last Name])
4. After you have defined the Employee Name column, hide the First Name, Middle Name, and Last
Name columns from client tools and save the data model.
=[SalesAmount]-[TotalProductCost]
2. After you have defined the SalesProfit column, confirm that its data type has been automatically
detected as Currency, and then save the model.
=RELATED('Product Subcategory'[Subcategory])
=RELATED('Product Category'[Category])
o Category
o Subcategory
o Product Name
4. Hide all columns in the Product Subcategory and Product Category tables from client tools.
2. Verify that the calculated columns work as expected, and then close Excel without saving the
workbook. Leave Visual Studio open for the next exercise.
MCT USE ONLY. STUDENT USE PROHIBITED
8-26 Introduction to Data Analysis Expressions (DAX)
Results: After this exercise, you should have a calculated column named Employee Name in the
Employee table, a calculated measure named SalesProfit in the Reseller Sales table, and a hierarchy
named Categorized Products in the Product table.
Profit
Margin
Previous Year Revenue
Profit:=SUM([SalesProfit])
Margin:=[Profit]/[Revenue]
2. Verify that the measures you created all work as expected, and then close Excel without saving the
workbook. Leave Visual Studio open for the next exercise.
Results: At the end of this exercise, the Reseller Sales table should contain the following measures:
Profit
Margin
2. Create a KPI
2. Format the Revenue Goal measure as Currency and hide it from client tools.
3. Save the data model.
2. Configure the KPI to use the Revenue Goal measure as the target value, and set status thresholds at
75% and 95%.
3. When you have created the KPI, save the data model.
2. Verify that the KPI indicates the status appropriately for the quarters and months in 2008, and then
close Excel without saving the workbook. Leave Visual Studio open for the next exercise.
Results: At the end of this exercise, the Reseller Sales table should include a measure named Revenue
Goal and a KPI based on the Revenue Goal measure.
MCT USE ONLY. STUDENT USE PROHIBITED
8-28 Introduction to Data Analysis Expressions (DAX)
=PATH([EmployeeKey], [ParentEmployeeKey])
o Level2
o Level3
o Level4
2. Expand Employee Hierarchy to view sales totals for managers and their subordinates. Note that the
personal revenue for sales managers is shown with a blank employee name under the total for that
sales manager.
3. When you have finished, close Excel without saving the workbook, and close Visual Studio.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 8-29
Results: At the end of this exercise, the Employee table should include a hierarchy named Employee
Hierarchy.
ENDOFQUARTER
NEXTQUARTER
OPENINGBALANCEQUARTER
PREVIOUSQUARTER
MCT USE ONLY. STUDENT USE PROHIBITED
8-30 Introduction to Data Analysis Expressions (DAX)
Review Question(s)
Question: Will time intelligence functionality be useful to you? What kinds of time-based
analyses might you want to perform? Which are the relevant time intelligence functions that
you might use to achieve this?
MCT USE ONLY. STUDENT USE PROHIBITED
9-1
Module 9
Performing Predictive Analysis with Data Mining
Contents:
Module Overview 9-1
Lesson 1: Overview of Data Mining 9-2
Module Overview
With data mining, you can use the data you own to gain insights that could help you make intelligent
decisions about your business. Microsoft® SQL Server® Analysis Services includes data mining tools that
you can use to identify patterns in your data, helping you to determine why particular things happen and
to predict what might occur in the future. This module introduces data mining, describes how to create a
data mining solution; how to validate data mining models; and how to incorporate data mining results
into Reporting Services reports.
Objectives
After completing this module, you will be able to:
Lesson 1
Overview of Data Mining
Data mining is a type of data analysis that involves using statistical models to reveal connections and
correlations in large sets of data that would otherwise be very difficult, or even impossible, to identify.
This lesson explains the purpose of data mining, and describes the components of a data mining solution,
in addition to the algorithms used to build prediction models.
Lesson Objectives
After completing this lesson, you will be able to:
Describe the different types of data mining algorithms you can use in Analysis Services data mining
solutions.
Data mining can help you to identify trends and patterns that may not be immediately obvious. You can
use data mining to predict unknown values, based on statistics and patterns in previously analyzed sets of
data. This is useful when you are trying to predict and plan for future events.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 9-3
Forecasting. Companies can use data mining to analyze sales patterns to determine, for example,
when a particular product will sell or how stores will profit over time.
Targeted advertising. Organizations can create target marketing and advertising campaigns by
identifying the factors that best predict the customers who are most likely to purchase a given
product, and then targeting the campaign at those individuals.
Risk assessment. Insurance companies can assess the likelihood of a claim being fraudulent by
employing data mining algorithms that use the outcomes of previous claims to create a weighting for
each factor affecting the new claim. Credit ratings agencies can use financial and customer history
data to predict which individuals are most likely to default on a loan.
For a general introduction to data mining on SQL Server, see Data Mining Concepts in Microsoft Docs:
Data Sources
The source data analyzed by a data mining solution is not stored in the solution—instead, the solution
contains bindings to the data sources. When the data mining solution is processed, an aggregated
summary of the source data is generated; the aggregations may be discarded after processing, or stored
in the solution for use in later operations.
You can use an Analysis Services data source view (DSV) to provide your source data definition; a DSV may
contain bindings to, and define relationships between, multiple data sources. Data sources are not
restricted to OLAP and relational data in SQL Server; Analysis Services supports many data sources for
which an OLE DB or .Net data provider is available.
MCT USE ONLY. STUDENT USE PROHIBITED
9-4 Performing Predictive Analysis with Data Mining
For a list of data sources supported by Analysis Services for use in data mining, see Supported Data
Sources (SSAS - Multidimensional) in Microsoft Docs:
Supported Data Sources (SSAS - Multidimensional)
http://aka.ms/Yy2cps
The case table and the mining structure columns that, in turn, express the data and content types.
Different portions of the case table data may be used to train and test data mining models.
For more information about mining structures, see Mining Structures (Analysis Services - Data Mining) in
Microsoft Docs:
Case Table
The case table stores aggregations from source data; the aggregations are used by the data mining
models.
Cases may be simple, in which circumstances each row in the case table corresponds to a case—for
example, if each case relates to a customer. When cases are complex, two or more case tables are
connected with a one-to-many relationship; these are referred to as nested cases, or nested tables.
When you specify the case table, you define the data type and content type for each column. The content
type defines how the values in a column relate to one another. Defining content types makes data mining
models more accurate as, when a content type is specified, the mining model is less likely to make poor
inferences about the statistical relationship between data values.
Continuous. These represent sequences of numeric data on a scale. Examples of continuous data
include temperature and weight.
Cyclical. These represent data that is organized into limited, ordered sets that repeat. Examples of
cyclical data include numbered days of the week or numbered months of the year.
For a full list of content types, see Content Types (Data Mining) in Microsoft Docs:
Key. This indicates a key column containing values that identify each row uniquely.
Input. This indicates that the model should use this column to help forecast values for the predictable
column.
Predict. This indicates the column for which you want to predict values in the mining mode. Its value
is also used as an input.
Predict Only. This indicates the column for which you want to predict values in the mining mode. Its
value is not used as an input.
For example, if you want to predict the amount of money each customer is likely to spend on a
supermarket website, you could use CustomerID as the key column; CustomerSpend as the predictable
column; and various others, containing data such as address, age, and number of children, as input
columns.
For more information on data mining models, see Mining Models (Analysis Services - Data Mining) in
Microsoft Docs:
Regression algorithms. These predict one or more continuous variables, such as profit or loss. The
Microsoft Time Series algorithm is an example that might be used to determine a retail store’s
seasonal sales for the coming year. Microsoft Linear Regression and Microsoft Logistic Regression can
also predict continuous variables.
Segmentation or clustering algorithms. These divide data into groups or clusters of items that have
similar properties. Microsoft Clustering, for example, might be used to divide customers into groups
with similar purchasing habits or preferences.
Association algorithms. These find correlation between different attributes in a data set. The
Microsoft Association algorithm is an example that might be used to describe which items—such as
products being purchased together—are likely to appear in a transaction.
Sequence analysis algorithms. Sequence analysis finds common sequences in data. The Microsoft
Sequence Clustering algorithm is an example that might be used to find common web clickthrough
paths, or the order of placing items in a cart.
For more information about the data mining algorithms included in Analysis Services, see Data Mining
Algorithms (Analysis Services - Data Mining) in Microsoft Docs:
For more information about the plugin architecture for adding third-party data mining algorithms, see
Plugin Algorithms in Microsoft Docs:
Plugin Algorithms
http://aka.ms/Hndiao
Sequencing Activity
Put the following components of a data mining solution in order by numbering each to indicate the
correct sequence from source to target.
Steps
Source data
Lesson 2
Creating a Custom Data Mining Solution
To produce a data mining solution in Analysis Services, you first create a model that describes your
business problem. The model is then trained by running your data through algorithms that generate a
mathematical model. You can then either visually explore the mining model or create prediction queries
against it. Analysis Services data mining structures can use datasets from both relational and
multidimensional databases, and there is a set of algorithms you can use to investigate that data in
various ways.
This lesson describes how to create a data mining structure and data mining model. The lesson also
describes how to edit data models, and introduces the Data Mining Extensions (DMX) language, which
you can use to work with data mining in Analysis Services.
Lesson Objectives
After completing this lesson, you will be able to:
For more information about the Data Mining Wizard, see Data Mining Wizard (Analysis Services - Data
Mining) in Microsoft Docs:
Data Mining Wizard (Analysis Services - Data Mining)
http://aka.ms/Hw9h83
Create a data mining structure and a data mining model using the Data Mining Wizard.
Demonstration Steps
Create a Data Mining Project in Visual Studio
1. Ensure that the 20768C-MIA-DC and 20768C-MIA-SQL virtual machines are both running, and then
log on to 20768C-MIA-SQL as ADVENTUREWORKS\Student with the password Pa55w.rd.
3. In the User Account Control dialog box, click Yes, and then wait for the script to finish.
4. Start Visual Studio 2015 and on the File menu, point to New, and then click Project.
5. In the New Project dialog box, expand Business Intelligence, then click Analysis Services, then
click Analysis Services Multidimensional and Data Mining Project.
6. In the Name box, type Mine AW then type D:\Demofiles\Mod09 in the Location box, then click
OK.
7. In Solution Explorer, right-click Data Sources, and then click New Data Source.
8. In the Data Source Wizard, on the Welcome to the Data Source Wizard page, click Next.
10. In the Connection Manager dialog box, in the Server name field, type MIA-SQL, in the Select or
enter a database name drop-down list, click AdventureWorksDW, and then click OK.
11. On the Select how to define the connection page, click Next.
12. On the Impersonation Information page, click Use a specific Windows user name and password,
then type the following credentials and click Next:
o User name: ADVENTUREWORKS\ServiceAcct
o Password: Pa55w.rd
14. In Solution Explorer, right-click Data Source Views, and then click New Data Source View.
15. In the Data Source View Wizard, on the Welcome to the Data Source View Wizard page, click
Next.
16. On the Select a Data Source page, ensure that Adventure Works DW is selected, and then click
Next.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 9-9
17. On the Select Tables and Views page, in the Available objects list, click ProspectiveBuyer (dbo),
hold the Ctrl key and click vTargetMail (dbo), and click the > button to move the selected objects
to the Included objects list. Then click Next.
18. On the Completing the Wizard page, in the Name field, type AW DW View, and then click Finish.
Create a Data Mining Structure and a Data Mining Model Using the Data Mining Wizard
2. In the Data Mining Wizard, on the Welcome to the Data Mining Wizard page, click Next.
3. On the Select the Definition Method page, ensure that From existing relational database or data
warehouse is selected, and then click Next.
4. On the Create the Data Mining Structure page, ensure that Create mining structure with mining
model is selected, ensure that Microsoft Decision Trees is selected, and then click Next.
5. On the Select a Data Source View page, select AW DW View and click Next.
6. On the Specify Table Types page, in the vTargetMail row, select the check box in the Case column,
and then click Next.
7. On the Specify the Training Data page, in the Mining Model Structure table, select the following
columns and click Next:
o BikeBuyer: Predictable
o CustomerKey: Key
8. On the Specify Columns’ Content and Data Type page, click Detect and review the content type
and data types found. Ensure that the content type of the Bike Buyer column is identified as
Discrete. Then click Next.
9. On the Create Testing Set page, note that the Percentage of data for testing value is 30 percent,
and then click Next.
10. On the Completing the Wizard page, in the Mining structure name box, type Purchase
Prediction.
11. In the Mining model name box, type Purchase Decision Tree, and then click Finish.
12. On the Build menu, click Deploy Mine AW. When deployment completes, close the Deployment
Progress – Mine AW window.
Note: Microsoft has not released a version of the Data Mining tools for Excel 2016. The
following is applicable to Office 2010 and Office 2013 versions.
You can also use the Data Mining Client for Excel add-in to edit data mining structures and models. When
you use the Add Model to Structure Wizard in the Data Mining Client for Excel add-in to edit an
existing structure by adding a new model, you can select and configure a data mining algorithm. You can
use the Manage Mining Structures and Models dialog box to rename, delete, clear, process, export, and
import structures and models.
For more information about using the Data Mining Designer, see Data Mining Designer in Microsoft Docs:
For more information about using the Data Mining Client for Excel to work with data mining structures,
see Advanced Modeling (Data Mining Add-ins for Excel) in Microsoft Docs:
Demonstration Steps
1. Ensure you have completed the previous demonstrations in this module.
2. In Visual Studio Solution Explorer, expand Mining Structures and double-click Purchase
Prediction.dmm.
4. Right-click anywhere in the Mining Models tab, then click New Mining Model.
5. In the New Mining Model dialog box, type Purchase Naive Bayes in the Model name box.
6. In the Algorithm name box, select Microsoft Naive Bayes, then click OK.
7. In the Microsoft Visual Studio dialog box, read the information message about content types
unsupported by the Microsoft Naïve Bayes algorithm, then click Yes.
8. In the Mining Models tab, in the Purchase Naive Bayes column, in the Name Style row, select
Ignore to exclude the column from the model.
9. On the Build menu, click Deploy Mine AW. When deployment completes, close the Deployment
Progress – Mine AW window.
In the Mining Model Viewer, you can refresh data model views and, depending on the viewer used,
perform other tasks, such as filter items, or adjust thresholds.
Browse Models by Using the Data Mining Client for Excel Add-In
You can also browse mining model results by using the Data Mining Client for Excel add-in. To browse a
model, click the Browse in the Model Usage area of the ribbon and then specify the model you want to
view. As with the Mining Model Viewer, the way results are displayed varies depending on the type of
model.
MCT USE ONLY. STUDENT USE PROHIBITED
9-12 Performing Predictive Analysis with Data Mining
For more information about browsing data mining models using the Data Mining Client for Excel, see
Browsing Models in Excel (SQL Server Data Mining Add-ins) in Microsoft Docs:
Browsing Models in Excel (SQL Server Data Mining Add-ins)
http://aka.ms/I2cclr
Demonstration Steps
1. Ensure you have completed the previous demonstrations in this module.
3. In the Connect to Server dialog box, select Analysis Services in the Server Type box, then type
MIA-SQL in the Server name box, then click Connect.
4. In Object Explorer, expand Databases, expand Mine AW, expand Mining Structures, right-click
Purchase Prediction, then click Browse.
5. In the Mining Model drop-down list, ensure that Purchase Naive Bayes is selected, and on the
Dependency Network tab, move the slider gradually from All Links to Strongest Links to see which
factors are the strongest predictors that a customer will purchase a bike.
6. On the Attribute Profiles tab, view the color-coded indicators of the values for each column when
compared to customers with a Bike Buyer value of 1 or 0.
7. On the Attribute Characteristics tab, in the Attribute drop-down list, ensure that Bike Buyer is
selected, and in the Value drop-down list, select 1. Then view the probability for each other column
value when the Bike Buyer value is 1.
8. On the Attribute Discrimination tab, in the Attribute drop-down list, ensure that Bike Buyer is
selected. In the Value 1 drop-down list, select 1, and in the Value 2 drop-down list, select 0. Then
note how values for all other columns favor a particular Bike Buyer value.
9. In the Mining Model drop-down list, select Purchase Decision Tree, and on the Decision Tree tab,
in the Background drop-down list, select 1. Then view the decision tree to see how the other column
values influence a value of 1 for Bike Buyer.
10. Close the Purchase Prediction [Browse] window, and leave SQL Server Management Studio open for
the next demonstration.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 9-13
What Is DMX?
Analysis Services includes the DMX query
language, which you can use to work with data
mining models. DMX is an extension of Transact-
SQL, and can be used to create the structure of
new data mining models, to train these models,
and to browse, manage, and use them to generate
predictions.
DMX is composed of Data Definition Language (DDL) statements, Data Manipulation Language (DML)
statements, and a set of functions and operators.
DDL Statements
You use DDL statements to create and delete data mining structures and models, and to import and
export data mining structures and models. DDL statements include CREATE, ALTER, DROP, IMPORT,
EXPORT, and SELECT INTO statements.
The following code example creates a new mining model that uses the Microsoft Naïve Bayes algorithm.
The Bike Buyer column is defined as the predictable attribute.
DMX DDL
CREATE MINING MODEL [NBSample]
(
CustomerKey LONG KEY,
Gender TEXT DISCRETE,
[Number Cars Owned] LONG DISCRETE,
[Bike Buyer] LONG DISCRETE PREDICT
)
USING Microsoft_Naive_Bayes
DML Statements
You use DML statements to train and browse mining models, and create predictions against them. DML
statements include SELECT statements, SELECT statements with PREDICTION JOIN clauses, and INSERT
INTO statements for training data mining models.
The following code example returns the midpoint, minimum age, and maximum age for all the values in
the Age column:
DMX DML
SELECT DISTINCT [Age] AS [Midpoint Age],
RangeMin([Age]) AS [Minimum Age],
RangeMax([Age]) AS [Maximum Age]
FROM [TM Decision Tree]
To help you build DMX prediction queries, SSMS includes a query builder tool and DMX templates you
can use as the basis for new queries. In the SQL Server Data Tools environment, you access the query
builder tool from the Mining Model Prediction tab of Data Mining Designer.
MCT USE ONLY. STUDENT USE PROHIBITED
9-14 Performing Predictive Analysis with Data Mining
For more information about DMX, see Data Mining Extensions (DMX) Reference in Microsoft Docs:
Demonstration Steps
1. In SSMS Object Explorer, right-click the Purchase Prediction mining structure and click Build
Prediction Query.
2. In the query designer, in the Mining Model pane, click Select Model.
3. In the Select Mining Model dialog box, expand Purchase Prediction, click Purchase Naive Bayes,
and click OK.
4. In the Select Input Table(s) pane, click Select Case Table.
5. In the Select Table dialog box, click ProspectiveBuyer (dbo), and click OK.
6. Under the Mining Model pane, in the Source column, select ProspectiveBuyer table, and then in
the Field column, select EmailAddress.
7. Under the row you just added, in the Source column, click Purchase Naive Bayes mining model, in
the Field column, click Bike Buyer, and in the Criteria/Argument column, type =1.
8. Under the row you just added, in the Source column, click Prediction Function, in the Field column,
click PredictProbability, in the Alias column, type Purchase Probability.
9. In the Mining Model pane, in the Purchase Naïve Bayes model, drag the Bike Buyer column to the
Criteria/Argument column so it contains the value [Purchase Naive Bayes].[Bike Buyer].
10. On the Mining Model menu, click Query to view the DMX code that has been generated.
11. On the Mining Model menu, click Result to view the query results. The query returns the email
address of every prospective customer who is predicted to buy a bike, along with the probability
(expressed as a percentage in fraction format) that this forecast is accurate.
12. Close the Purchase Prediction [Query] window, and leave SQL Server Management Studio open for
the next demonstration.
Verify the correctness of the statement by placing a mark in the column to the right.
Statement Answer
Lesson 3
Validating a Data Mining Model
Validation is the process of assessing how well your mining models perform against real data. It is
important to validate your mining models by understanding their quality and characteristics before you
deploy them into a production environment.
This lesson provides an overview of data mining model validation and describes the criteria for validating
models. It also introduces the tools for model validation that are provided in SQL Server Data Tools and
the Data Mining Client for Excel add-in.
Lesson Objectives
After completing this lesson, you will be able to:
Other factors can affect the validity of a data model, including the quality of the data and the usefulness
of the results to the business.
Accuracy
Data mining models correlate a defined outcome, such as the amount of money a customer will spend,
with input criteria, such as customer age, location, number of items purchased, and so on. The accuracy of
these correlations can be affected by missing, approximate, or incorrect data. It is important to assess the
accuracy of a model so you know how much you can trust the results produced. If you are aware in
advance that a certain percentage of the data contains inaccuracies, you can decide to accept this degree
of inaccuracy in the models you create. Data that qualifies as highly accurate is not necessarily reliable or
useful. For example, you might test a model that predicts future sales for a store, based on previous
performance. The model might be very accurate because the correlations are strong. However, if the
method of calculating profitability used in the model is incorrect, the data produced is neither reliable nor
useful.
MCT USE ONLY. STUDENT USE PROHIBITED
9-16 Performing Predictive Analysis with Data Mining
Reliability
To be regarded as reliable, a data mining model must perform consistently. To assess reliability, you need
to test the data model by using multiple, similar data sets. For each data set, the model should produce
similar results. For example, you could test a model that predicts future sales performance for a store by
using it against data from multiple stores. If one store calculates profitability differently, this will show up
in the testing results.
Usefulness
A data model might be both accurate and reliable, but this does not necessarily mean that the results it
produces are useful to the business. For example, your model might identify a strong correlation between
the profitability of a store and its location, but this might not be useful because it doesn’t explain why that
correlation exists.
For more information about validation of data mining models, see Testing and Validation (Data Mining) in
Microsoft Docs:
Accuracy Charts
Visual Studio, the Data Mining Add-In for Excel,
and SQL Server Management Studio include tools
for validating data mining models.
Visual Studio
You can use the Mining Accuracy Chart tab in the
Data Mining Designer, in the SSDT, to create
charts and reports to help you assess the validity
of data models.
Profit chart. This is a graph that displays the estimated profit or loss identified by the model for a
particular scenario. When you create a profit chart, you specify values for the number of rows to use
in the assessment, the overall cost of the scenario, the cost per row, and the anticipated revenue per
row. For example, in a mailing campaign, you could specify to use 5,000 customer rows, the total cost
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 9-17
of the campaign, the cost per customer, and the revenue per customer. These values are used to
calculate the campaign’s profitability.
Classification matrix. This uses testing data to count and display the number of true and false
positives that a data mining model identifies for a given predicted value. For example, imagine a
Customers table that includes a BikeBuyer column containing values of 1 and 0. The value 1
indicates that the customer purchased a bike, and 0 that they did not. A classification matrix will use
the input columns to calculate whether a customer will be a bike buyer or not, and then compare
these values to the real values in the data. The matrix will display the results, showing the number of
correct and incorrect predictions for each value. Typically, a classification matrix is more accurate
when used with discrete data values.
Cross-validation report. Lift charts, profit charts, and classification matrices are all types of chart that
assess and display the accuracy of models in different ways. A cross-validation report is a different
way of validating a data mining model. To perform cross-validation, Analysis Services first divides a
data set into partitions. It then uses a model to analyze one of the partitions, treating this as the
training set. The other partitions are used to validate the results of this analysis. The process is then
repeated several times, using a different partition as the training set on each occasion.
The Accuracy Chart Wizard enables you to create a lift chart or a scatter plot.
Data Mining Client for Excel (SQL Server Data Mining Add-ins) - Test, Query, and Validate
Models
http://aka.ms/Dlgmem
MCT USE ONLY. STUDENT USE PROHIBITED
9-18 Performing Predictive Analysis with Data Mining
A Lift Chart.
A Profit Chart.
A Classification Matrix.
A Cross-Validation Report.
Demonstration Steps
Create a Lift Chart
2. In SSMS Object Explorer, right-click the Purchase Prediction mining structure and click View Lift
Chart.
3. On the Input Selection tab, note that both mining models are selected with the Bike Buyer column
as predictable, and that the test cases defined in the models themselves will be used for the
validation.
4. Click the Lift Chart tab, and view the lift chart, which compares accuracy for the two mining models
you have created against an ideal model by plotting the number of correct predictions against the
number of cases in the overall sample. As the number of cases increases, the ideal model maintains an
accuracy of 100 percent. However, the models you have created tend to become less accurate the
more cases there are.
5. Review the scores in the Mining Legend pane to see which of your models is the most accurate for
this test data.
2. In the Profit Chart Settings dialog box, enter the following values to reflect a marketing campaign
you are planning, and then click OK:
o Population: 20,000 (this is the number of potential customers you plan to contact).
o Fixed cost: 1,000 (this is the fixed cost of your marketing campaign).
o Individual cost: 3 (this is the cost associated with contacting each customer).
o Revenue per individual: 10 (this is the amount you expect a customer to spend if they respond
positively to the campaign).
3. Review the chart and the Mining Legend pane to evaluate which mining model is likely to generate
the most profitable marketing campaign based on the test data.
o Fold Count: 5 (this is the number of partitions used to group the data for analysis).
o Target State: 1 (this is the desired value for the target attribute).
o Target Threshold: 0.1 (this is a value between 0 and 1 that indicates the level of accuracy
required for a prediction to be considered correct).
3. View the resulting report, and note that for each mining model, the results include the following:
o Classifications for true positives, false positives, true negatives, and false negatives.
Scatter plot
Classification matrix
Lift chart
Cross-validation report
Profit chart
MCT USE ONLY. STUDENT USE PROHIBITED
9-20 Performing Predictive Analysis with Data Mining
Lesson 4
Connecting to and Consuming a Data Mining Model
Results produced by data mining models need to be displayed in useful and comprehensible ways, for the
benefit of data and business analysts.
This lesson describes the options for viewing data mining results and how you can use Reporting Services
reports to render them in a user-friendly format.
Lesson Objectives
After completing this lesson, you will be able to:
Data mining models store data in an Analysis Services database. To connect to an Analysis Services
database and create a data mining report, you create an Analysis Services connection in an SSRS project,
in SSDT. You can then use Query Builder to create the query that retrieves the data to use in the report.
For more information about using DMX to query data models in an SSRS report, see Retrieve Data from a
Data Mining Model (DMX) (SSRS) in Microsoft Docs:
Demonstration Steps
1. Ensure you have completed the previous demonstrations in this module.
2. In Visual Studio, on the File menu, point to New and click Project.
3. In the New Project dialog box, expand Business Intelligence, select Reporting Services, select
Report Server Project Wizard.
4. In the Name field, type Purchase Prediction, in the Location field, type D:\Demofiles\Mod09, and
then click OK.
5. In the Report Wizard, on the Welcome to the Report Wizard page, click Next.
6. On the Select the Data Source page, select New data source, change the Name to AWMine, in the
Type drop-down list, select Microsoft SQL Server Analysis Services, and click Edit.
7. In the Connection Properties dialog box, in the Server name field, type MIA-SQL, in the Select or
enter a database name drop-down list, click Mine AW, and then click OK.
10. In Query Designer, in the Mining Model pane, click Select Model.
11. In the Select Mining Model dialog box, expand Purchase Prediction, click Purchase Naive Bayes,
and click OK.
12. In the Select Input Table(s) pane, click Select Case Table.
13. In the Select Table dialog box, click ProspectiveBuyer (dbo), and click OK.
14. Under the Mining Model pane, in the Source column, select ProspectiveBuyer table, and then in
the Field column, select EmailAddress.
15. Under the row you just added, in the Source column, click Purchase Naive Bayes mining model, in
the Field column, click Bike Buyer, and in the Criteria/Argument column, type =1.
16. Under the row you just added, in the Source column, click Prediction Function, in the Field column,
click PredictProbability, in the Alias column, type Purchase Probability.
17. in the Mining Model pane, from the Purchase Naïve Bayes model, drag the Bike Buyer column to
the Criteria/Argument column so it contains the value [Purchase Naive Bayes].[Bike Buyer], then
click OK.
20. On the Design the Table page, in the Available fields box, click EmailAddress, then click Details >.
21. In the Available fields box, click Purchase_Probability, then click Details >. Click Next.
22. If the Choose the Table Style page appears, click Next.
23. If the Choose the Deployment Location page appears, click Next.
24. On the Completing the Wizard page, type Likely Purchase Email Report in the Report name box,
then click Finish.
MCT USE ONLY. STUDENT USE PROHIBITED
9-22 Performing Predictive Analysis with Data Mining
25. In the report designer, on the Design tab, click the table.
26. In the Row Groups pane, right-click the (table1_Details_Group) drop-down list and click Group
Properties.
27. In the Group Properties dialog box, on the Sorting page, click Add, in the Sort by drop-down list,
select [Purchase_Probability], and in the Order drop-down list, click Z to A. Then click OK.
28. In the Purchase Probability column, right-click [Purchase Probability] and click Text Box
Properties.
29. In the Text Box Properties dialog box, click Number, select Percentage, and click OK.
30. Click the Preview tab to review the report.
Verify the correctness of the statement by placing a mark in the column to the right.
Statement Answer
Objectives
After completing this lab, you will be able to:
Create a data mining structure and a data mining model, then add a data mining model to a data
mining structure.
Password: Pa55w.rd
3. Use the Adventure Works DW data source to create a data source view named Adventure Works
DW DM View that includes the ProspectiveBuyer table and the vTargetMail view.
2. Specify the vTargetMail view from the Adventure Works DW DM View data view as the case table.
o BikeBuyer: Predictable
o CustomerKey: Key
4. All other columns: Input.
5. Have the wizard detect the content and data types of the columns. Ensure that the content type of
the Bike Buyer column is identified as Discrete, and change the Yearly Income column to Discrete.
7. Name the data mining structure Purchase Prediction, and name the data mining model Purchase
Decision Tree.
2. Call the model Purchase – Bayes, and amend the model definition to ignore the Name Style
column.
Results: After this exercise, you should have a data mining structure with two data models.
Results: After this exercise, you should have reviewed the output of data mining models using Visual
Studio.
o Population: 5,000
o Fold Count: 5
o Target State: 1
Results: After this exercise, you should have two validated data mining models in your data mining
structure.
MCT USE ONLY. STUDENT USE PROHIBITED
9-26 Performing Predictive Analysis with Data Mining
1. Create a Report
2. Create a new data source for the AW Data Mining database in the MIA-SQL instance of Analysis
Services.
3. Use the query builder to create a query that uses the Purchase - Bayes model and the
ProspectiveBuyer(dbo) case table. Configure the query to return the following fields:
4. Create a tabular report with all fields in the details section, format it using any style, and name it
Potential Bike Buyers.
5. Sort the report from Z to A by the Purchase Probability column and change the format of the
Purchase Probability column to percentage.
6. Preview the Potential Bike Buyers report, and modify its formatting until you are happy with it.
7. When you have finished working on the report, close Visual Studio.
Results: After this exercise, you should have an SSRS report that predicts bike purchasers.
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 9-27
Review Question(s)
Question: How have you seen, or can you envisage, data mining being used in organizations
where you have worked?
MCT USE ONLY. STUDENT USE PROHIBITED
Developing SQL Data Models 9-29
Course Evaluation
Your evaluation of this course will help Microsoft understand the quality of your learning experience.
Please work with your training provider to access the course evaluation form.
Microsoft will keep your answers to this survey private and confidential and will use your responses to
improve your future learning experience. Your open and honest feedback is valuable and appreciated.
MCT USE ONLY. STUDENT USE PROHIBITED
MCT USE ONLY. STUDENT USE PROHIBITED
L1-1
3. Click Yes when prompted to confirm that you want to run the command file, and then wait for the
script to finish.
o The DimDate table stores values for dates, including details of the calendar and fiscal periods in
which individual dates occur.
o The FactInternetSales and FactResellerSales tables are related to the DimDate table by
multiple fields. These fields represent the order date (the date when the order was placed), the
due date (the date when the order was expected to be in stock), and the ship date (the date
when the order was shipped to the customer).
o Both the DimCustomer and DimReseller tables are related to the DimGeography table, which
stores details of geographical locations. The DimSalesTerritory table is also related to
DimGeography.
o Many tables include multiple language values for the same data value, for example, the DimDate
table stores the English, French, and Spanish words for each month name.
MCT USE ONLY. STUDENT USE PROHIBITED
L1-2 Developing SQL Data Models
o The DimEmployee table is related to itself to represent the fact that each employee has a
manager, who is also an employee.
6. On the File menu, click Save Diagram_0, and then save the diagram as AdventureWorksDW
Schema.
2. Select the Transact-SQL code under the comment Internet sales by year and month, and then click
Execute.
3. View the results of the query, and note the following details:
o The data warehouse contains historical Internet sales orders from July 2005 to July 2008. Reseller
sales in the data warehouse are also recorded for this time period.
o You can use the MonthNumberOfYear column in the DimDate table to sort month names into
chronological order—without this field, it would be difficult (though not impossible) for reporting
clients to sort months other than alphabetically. A similar field named DayNumberOfWeek can
be used to sort weekday names into chronological order.
4. Select the Transact-SQL code under the comment Geographical reseller sales, and then click
Execute.
5. View the results of the query, and note the following details:
o In 2005, Adventure Works only sold to resellers in the United States and Canada.
o In 2006, this was expanded to include France and the United Kingdom.
o In 2007, resellers in Australia and Germany were added.
o By contrast, Adventure Works has sold directly to Internet customers in all of these regions since
2005.
6. Select the Transact-SQL code under the comment Sales by product category, and then click
Execute.
7. View the results of the query, and note the following details:
o Adventure Works sells four categories of product: Accessories, Bikes, Clothing, and Components.
2. In the Connect to Server dialog box, in the Server name field, type MIA-SQL, and then click
Connect.
3. In Object Explorer, under the MIA-SQL Microsoft Analysis Server node, expand Databases, and then
expand Adventure Works OLAP.
4. Under the Adventure Works OLAP database, expand Data Sources. Note that the SQL Server
Analysis Services database includes a data source called Adventure Works Data Warehouse, which
connects to the AdventureWorksDW database that you explored in the previous exercise.
5. Under the Adventure Works OLAP database, expand Cubes. Right-click Internet Sales, and then
click Browse.
6. In the cube browser window, in the Metadata pane, expand Measures, expand Internet Sales
Order, and then drag the Sales Amount measure onto the empty query pane. Click on the text Click
to execute the query, the total Internet sales amount is displayed.
7. In the Metadata pane, expand Order Date, and then drag Order Date.Fiscal Year to the query
pane. Click on the text Click to execute the query, the sales revenue is now aggregated by fiscal
year. In Adventure Works, fiscal years run from July to June, so fiscal year 2006 represents the period
from July 2005 to June 2006.
3. In the Data Connection Wizard dialog box, in the Server name box, type MIA-
SQL.adventureworks.msft, ensure that Use the following User Name and Password is selected,
type the following, and then click Next:
b. Password: Pa55w.rd
4. On the Select Database and Table page, in the Select the database that contains the data you
want drop-down list, select the Adventure Works OLAP database, in the Connect to a specific
cube or table field, click Internet Sales, and then click Next.
5. On the Save Data Connection File and Finish page, click Finish.
6. In the Import Data dialog box, select PivotTable Report, ensure that Existing worksheet is selected
with the cell reference =$A$1, and then click OK.
7. In the PivotTable Fields pane, under Internet Sales Order, select Sales Amount. The total revenue
from Internet sales is displayed in the PivotTable on the worksheet.
8. In the PivotTable Fields pane, in the Values area, in the drop-down list for the Sales Amount field,
click Value Field Settings.
10. In the Format Cells dialog box, select Accounting, click OK.
11. In the Value Field Settings dialog box, click OK. The Internet sales total in the PivotTable on the
worksheet is formatted as a currency value.
12. In the PivotTable Fields pane, under Order Date, select Order Date.Calendar Date. The total
calendar years for the sales are displayed as columns.
13. In the PivotTable Fields pane, drag Order Date.Calendar Date from the Columns area to the Rows
area. The years are now displayed on rows.
14. In the PivotTable, expand 2006. The calendar semesters for the year are shown. Expand H1CY2006 to
reveal the first two quarters, expand Q1 CY 2006 to reveal the first three months, and then expand
January to reveal daily sales totals in January 2006.
4. Move the slicer so that you can see the PivotTable. Note that the Components category is disabled
because there are no sales of components to Internet customers.
5. In the slicer, click Accessories. The PivotTable is filtered to show only sales of accessories. Note that
no accessories were sold in 2005 or 2006.
6. In the slicer, click the Clear Filter icon to remove the filter.
Results: After completing this exercise, you will have used Excel to explore an analytical data model built
on the data warehouse.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-1
3. Click Yes when prompted to confirm that you want to run the command file, and then wait for the
script to finish. Note that the script may take up to several minutes to complete.
3. Click Browse, browse to the D:\Labfiles\Lab02\Starter folder, click Select Folder, and then click OK.
2. In the Data Source Wizard, on the Welcome to the Data Source Wizard page, click Next.
4. In the Connection Manager dialog box, in the Server name box, type localhost.
5. In the Log on to the server area, ensure that Use Windows Authentication is selected.
6. In the Connect to a database area, in the Select or enter a database name box, click
AdventureWorksDW, and then click OK.
8. On the Impersonation Information page, select Use a specific Windows user name and
password.
10. In the Password box, type Pa55w.rd, and then click Next.
11. On the Completing the Wizard page, in the Data source name field, change the value to
Adventure Works Data Warehouse, and then click Finish.
2. On the Welcome to the Data Source View Wizard page, click Next.
3. On the Select a Data Source page, verify that the Adventure Works Data Warehouse data source
is selected, and then click Next.
4. In the Available objects list, click DimCustomer (dbo), and then hold down the Ctrl key and click
DimDate (dbo), DimGeography (dbo), DimProduct (dbo), DimProductCategory (dbo),
DimProductSubcategory (dbo), and FactInternetSales (dbo). Click the right arrow (>) button to
add the selected tables to the Included objects list, and then click Next.
5. On the Completing the Wizard page, in the Name field, type Adventure Works DSV, and then
click Finish. The Data Source View Designer opens automatically.
3. Click the DimCustomer table, change its FriendlyName property to Customer, and then press Enter.
4. Repeat the previous step to edit the FriendlyName property of the following tables (Table name:
FriendlyName):
o DimDate: Date
o DimGeography: Geography
o DimProduct: Product
o DimProductSubcategory:
o Product Subcategory
5. In the diagram, right-click the Customer table, and then click New Named Calculation.
6. In the Create Named Calculation dialog box, in the Column name box, type Full Name.
7. In the Expression box, type the text in the following code example:
CASE
WHEN MiddleName IS NULL THEN
FirstName + ' ' + LastName
ELSE
FirstName + ' ' + MiddleName + ' ' + LastName
END
3. On the Select Creation Method page, verify that Use existing tables is selected, and then click
Next.
6. On the Select Measures page, clear every check box except Order Quantity, Total Product Cost,
Sales Amount, and Internet Sales Count, and then click Next.
7. On the Select New Dimensions page, clear the Internet Sales check box, and then click Next.
8. On the Completing the Wizard page, change the Cube name to Sales, and then click Finish. The
Cube Designer opens automatically.
2. Rename Order Quantity to Internet Order Quantity, and then press Enter.
3. In the Measures pane, right-click the Total Product Cost measure, and then click Rename.
4. Rename Total Product Cost to Internet Cost, and then press Enter.
5. In the Measures pane, right-click Sales Amount, and then click Rename.
3. Hold down the Ctrl key, click StateProvinceName, EnglishCountryRegionName, and PostalCode,
and then drag the selected columns to the Attributes pane.
4. In the Data Source View pane, in the Customer table, click CustomerAlternateKey.
5. Hold down the Ctrl key, click Title, FirstName, MiddleName, LastName, and Full Name.
7. On the File menu, click Save All then close the Customer.dim Dimension Designer.
8. In Solution Explorer, under Dimensions, right-click Product.dim, and then click View Designer.
9. In the Data Source View pane, in the Product table, click ProductAlternateKey. Hold down the Ctrl
key, click EnglishProductName and ListPrice, and then drag the selected columns to the Attributes
pane.
10. In the Data Source View pane, in the Product Subcategory table, click
EnglishProductSubcategoryName, and drag the selected column to the Attributes pane.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-4 Developing SQL Data Models
11. In the Data Source View pane, in the Product Category table, click EnglishProductCategoryName,
and drag the selected column to the Attributes pane.
12. On the File menu, click Save All then close the Product.dim Dimension Designer.
13. In Solution Explorer, under Dimensions, right-click Date.dim, and then click View Designer.
14. In the Data Source View pane, in the Date table, click FullDateAlternateKey. Hold down the Ctrl key,
click EnglishMonthName, MonthNumberOfYear, CalendarQuarter, CalendarYear, and
CalendarSemester and drag the selected columns to the Attributes pane.
15. In the Attributes pane, right-click English Month Name and click Rename. Change the attribute
name to Month.
16. On the File menu, click Save All, and then close the Date.dim designer window.
3. In the Measure Group pane, expand Measures, expand Internet Sales, and then drag the Internet
Revenue measure to the Drag levels or measures here to add to the query area.
4. In the Measure Group pane, drag Internet Sales Count to the right of the Internet Revenue
column.
5. In the Measure Group pane, expand the Order Date dimension, and drag the Order Date.Calendar
Year attribute to the left of the Internet Revenue column. The Cube Browser shows historical sales
amounts and counts for multiple years.
Created a cube.
2. In the Add/Remove Tables dialog box, in the Available objects list, click DimSalesTerritory, click
the right arrow (>) button, and then click OK.
3. In the diagram, click the title bar of the DimSalesTerritory table and press F4.
4. In the Properties pane, change the FriendlyName property to Sales Territory, and then press Enter.
3. On the Select Creation Method page, select Use an existing table, and click Next.
4. On the Specify Source Information page, ensure that the Adventure Works DSV data source view
is selected. In the Main table list, select Sales Territory. Verify that SalesTerritoryKey is selected as
the key column and the name column, and then click Next.
5. On the Select Dimension Attributes page, select SalesTerritoryRegion, SalesTerritoryCountry,
and SalesTerritoryGroup, ensure that the Enable Browsing check box is selected for each of them,
and then click Next.
6. On the Completing the Wizard page, click Finish. The new dimension is opened in the Dimension
Designer.
3. In the Add Cube Dimension dialog box, click Sales Territory, and then click OK.
4. Click the Dimension Usage tab, verify that the value Sales Territory appears in the Dimensions list,
and then next to it, in the Measure Groups list, the value Sales Territory Key appears. This confirms
that the Sales Territory dimension is related to the Internet Sales measure group using the Sales
Territory Key attribute.
2. When deployment has completed successfully, in the Sales.cube Cube Designer, on the Browser tab,
click Reconnect.
3. On the Cube menu, click Analyze in Excel. If you are prompted to enable data connections, click
Enable.
MCT USE ONLY. STUDENT USE PROHIBITED
L2-6 Developing SQL Data Models
4. In the PivotTable Fields pane, beneath the Internet Sales measure, select Internet Revenue.
5. In the PivotTable Fields pane, under the Sales Territory dimension, select Sales Territory Group.
Sales for each territory group are shown.
6. In the PivotTable Fields pane, under the Sales Territory dimension, select Sales Territory Country.
Sales within each sales territory group are broken down for each country.
7. In the PivotTable Fields pane, under the Sales Territory dimension, select Sales Territory Region.
Sales within each sales territory are broken down for each region. Note that some countries do not
include sales regions, so the country is shown at both the country and region levels.
9. In Visual Studio, on the File menu, click Save All, and then close Visual Studio.
Created a dimension.
3. In the User Account Control dialog, click Yes, and wait for the script to finish.
3. In the Attributes pane, click Commute Distance, press the Ctrl key, and click Number Cars Owned
and Number Children At Home, right-click any of the highlighted attributes, and then click Delete.
In the Delete Objects dialog box, click OK.
4. On the File menu, click Save All, then close the Customer.dim Dimension Designer.
5. In Solution Explorer, double-click the Product.dim dimension. Again, users have requested that you
remove some unnecessary attributes from this dimension.
6. In the Attributes pane, click Days To Manufacture, press the Ctrl key, and click Safety Stock Level.
Press Delete and, in the Delete Objects dialog box, click OK.
7. On the File menu, click Save All, then close the Product.dim Dimension Designer.
3. On the Choose Enhancement page, click Define dimension intelligence, and then click Next.
4. On the Define Dimension Intelligence page, in the Dimension type field, click Time.
5. In the Dimension attributes table, select the Include check box for the following attribute types,
and select the corresponding item in the Dimension Attribute column:
o Date: Month
Results: After this exercise, unused attributes in the Customer and Product dimensions will have been
removed; time intelligence will have been added to the Date dimension.
2. On the Dimension Structure tab, in the Attributes pane, drag English Product Category Name into
an empty area of the Hierarchies pane. This creates a new hierarchy named Hierarchy.
3. In the Attributes pane, drag English Product Subcategory Name to the <new level> area beneath
English Product Category Name in the hierarchy.
4. In the Attributes pane, drag English Product Name to the <new level> area beneath English
Product Subcategory Name in the hierarchy.
Note: if a warning is displayed, notifying you that attribute relationships do not exist and
performance may be decreased, ignore it. You will see how to use attribute relationships to optimize
a hierarchy later in this lab.
5. Right-click Hierarchy and click Rename. Then rename the hierarchy to Categorized Products.
6. In the Categorized Products hierarchy, right-click English Product Category Name and click
Rename. Rename the hierarchy level to Category.
7. In the Categorized Products hierarchy, right-click English Product Subcategory Name and click
Rename then rename the hierarchy level to Subcategory.
8. In the Categorized Products hierarchy, right-click English Product Name and click Rename then
rename the hierarchy level to Product.
9. In the Attributes pane, select all the attributes by clicking the first one, and then holding Shift and
clicking the last one. In the Properties pane, set the AttributeHierarchyVisible property to False.
This hides the individual attributes, making the Categorized Products hierarchy the only way to
browse the Product dimension.
10. On the Dimension menu, click Process. If you are prompted to build and deploy the project first,
click Yes. If you are prompted to enter a password, type Pa55w.rd and click OK.
11. In the Process Dimension-Product dialog box, click Run and wait for the dimension to be
processed. Click Close, and click Close again to close the Process Dimension-Product dialog box.
12. On the Browser tab, ensure that the Categorized Products hierarchy is selected and expand the All
level to display the categories.
2. On the Dimension Structure tab, in the Attributes pane, drag Gender into an empty area of the
Hierarchies pane. This creates a new hierarchy named Hierarchy.
3. Right-click Hierarchy and click Rename, then rename the hierarchy to Gender-Marital Status.
4. In the Attributes pane, drag Marital Status to the <new level> area beneath Gender in the Gender-
Marital Status hierarchy.
Note: if a warning is displayed, saying that attribute relationships do not exist and that performance
may be decreased, ignore it. You will see how to use attribute relationships to optimize a hierarchy
later in this lab.
5. On the Dimension menu, click Process. If you are prompted to build and deploy the project first,
click Yes, and if you are prompted to confirm the database will be overwritten, click Yes.
6. In the Process Dimension- Customer dialog box, click Run and wait for the dimension to be
processed. Click Close, and click Close again to close the Process Dimension-Customer dialog box.
7. On the Browser tab, ensure that the Gender-Marital Status hierarchy is selected and expand the All
level to display the gender level. Note that the gender can be F, M, or Unknown.
8. Expand F and M, and note that the marital status level value can be M or S.
1. In Solution Explorer, double-click the Date.dim dimension to open it in the Dimension Designer.
2. In the Properties pane, note that the Type property for this dimension has been set to Time. This
occurred when you added dimension intelligence in the previous exercise.
4. In the Properties pane, scroll down to the Source section, click the KeyColumns field, and then click
the ellipses (…) button.
5. In the Key Columns dialog box, in the Available Columns table, click CalendarYear, and then click
the right arrow (>) icon.
6. Click the up arrow icon to move CalendarYear above CalendarSemester, and then click OK.
7. In the Properties pane, click the NameColumn field, and then click the ellipses (…) button.
8. In the Name Column dialog box, in the Source column field, click CalendarSemester, and then click
OK.
9. In the Properties pane, click the ValueColumn field, and then click the ellipses (…) button.
10. In the Value Column dialog box, in the Source column field, click CalendarSemester, and then click
OK.
12. In the Properties pane, scroll down to the Source section, click the KeyColumns field, and then click
the ellipses (…) button.
13. In the Key Columns dialog box, in the Available Columns table, click CalendarYear, and then click
the right arrow (>) icon.
MCT USE ONLY. STUDENT USE PROHIBITED
L3-4 Developing SQL Data Models
14. Click the up arrow icon to move CalendarYear above CalendarQuarter, and then click OK.
15. In the Properties pane, click the NameColumn field, and then click the ellipses (…) button.
16. In the Name Column dialog box, in the Source column field, click CalendarQuarter, and then click
OK.
17. In the Properties pane, click the ValueColumn field, and then click the ellipses (…) button.
18. In the Value Column dialog box, in the Source column field, click CalendarQuarter, and then click
OK.
19. In the Attributes pane, click Month, and in the Properties pane, scroll down to the Source section,
click the KeyColumns field, and then click the ellipses (…) button.
20. In the Key Columns dialog box, in the Key Columns table, click EnglishMonthName, and then click
the left arrow (<) icon.
21. In the Available Columns table, click CalendarYear, and then click the right arrow (>) icon.
22. In the Available Columns table, click MonthNumberOfYear, then click the right arrow (>) icon.
Ensure that CalendarYear appears above MonthNumberOfYear, and then click OK.
23. In the Properties pane, click the NameColumn field, and then click the ellipses (…) button.
24. In the Name Column dialog box, in the Source column field, click EnglishMonthName, and then
click OK.
25. In the Properties pane, click the ValueColumn field, and then click the ellipses (…) button.
26. In the Value Column dialog box, in the Source column field, click EnglishMonthName, and then
click OK.
27. On the File menu, click Save All.
3. In the Create Attribute Relationship dialog box, in the Source Attribute section, in the Name field,
click Full Date Alternate Key. Then, in the Related Attribute section, in the Name field, click
Month.
4. In the Relationship type field click Rigid (will not change over time), because a particular date will
always be in the same month, and then click OK.
Create a Hierarchy
1. In the Date.dim Dimension Designer, on the Dimension Structure tab, in the Attributes pane, drag
Calendar Year into the Hierarchies pane. A new hierarchy named Hierarchy is created.
2. Right-click Hierarchy and click Rename then rename the hierarchy to Calendar Date.
MCT USE ONLY. STUDENT USE PROHIBITED
L3-5
3. In the Attributes pane, drag the following attributes one-by-one to the <new level> area in the
Calendar Date hierarchy:
o Calendar Semester
o Calendar Quarter
o Month
4. In the Calendar Date hierarchy, right-click Full Date Alternate Key and click Rename. Then rename
the hierarchy level to Day.
5. In the Attributes pane, select Calendar Year, press the Ctrl key, and click Calendar Semester,
Calendar Quarter, Month, and Full Date Alternate Key to select all of these attributes.
6. In the Properties pane, change the AttributeHierarchyVisible property to False. This defines these
attributes as member properties rather than hierarchies in their own right, so that users can only
browse them through the Calendar Date hierarchy.
7. On the Dimension menu, click Process. If you are prompted to build and deploy the project first,
click Yes, and if you are prompted to overwrite the database click Yes.
8. In the Process Dimension-Date dialog box, click Run and wait for the dimension to be processed.
Click Close, and click Close again to close the Process Dimension-Date dialog box.
Results: After this exercise, you should have created a Categorized Products hierarchy and a Gender-
Marital Status hierarchy.
5. On the Dimension menu, click Process. If you are prompted to build and deploy the project first,
click Yes. If you are prompted to overwrite the database, click Yes. In the Process Dimension-Date
dialog, click Run.
6. When processing is complete, click Close and then, in the Process Dimension-Date dialog, click
Close.
7. In the Browser tab, in the Hierarchy drop-down, ensure Calendar Date is selected.
8. In the Dimension menu, click Refresh. Note that the months are now correctly sorted in
chronological order.
MCT USE ONLY. STUDENT USE PROHIBITED
L3-6 Developing SQL Data Models
2. On the Dimension Structure tab, in the Data Source View pane, right-click the Customer table, and
then click Explore Data. Notice the range of values for the YearlyIncome column, and then close the
Explore Customer Table window.
5. On the Dimension Structure tab, in the Attributes pane, click Yearly Income.
6. In the Properties pane, in the DiscretizationMethod box, click Automatic, in the
DiscretizationBucketCount box type 5 and, in the OrderBy list, select Key.
7. On the Dimension menu, click Process. If you are prompted to build and deploy the project first,
click Yes, and if you are prompted to overwrite the database, click Yes.
8. In the Process Dimension-Customer dialog, click Run and then, when processing is complete, click
Close. Click Close in the Process Dimension-Customer dialog.
9. On the Browser tab, click Reconnect and verify that the yearly income is grouped into five ranges,
with a sixth member for unknown values.
3. Click Yes when prompted to confirm that you want to run the command file, and then wait for the
script to finish.
2. In Solution Explorer, right-click Adventure Works DSV.dsv, and then click View Designer.
4. In the Add/Remove Tables dialog box, in the Available objects list, select FactResellerSales (dbo),
and then click the > button to add the selected table to the Included objects list.
5. Click Add Related Tables to add the tables that are related to FactResellerSales, and then click OK.
Note that the tables have been added to the data source view, and then, on the File menu, click Save
All.
9. In the Measures pane, right-click the Fact Reseller Sales measure group, click Rename, and then
change the name of the measure group to Reseller Sales.
10. Expand the Reseller Sales measure group, and then review the names of the measures that it
contains. Note that when the Reseller Sales measure group was set up, measures were created for all
of the numerical fields in the FactResellerSales table.
2. Click the row for the Revision Number measure, and then hold down the Ctrl key and click the rows
for the following measures to select them all:
o Unit Price
o Extended Amount
MCT USE ONLY. STUDENT USE PROHIBITED
L4-2 Developing SQL Data Models
o Discount Amount
o Tax Amt
o Freight
3. Click the Delete button, and then in the Delete Objects dialog box, click OK to remove these
measures.
4. Right-click the Order Quantity measure, click Rename, and then change the name of the measure to
Reseller Order Quantity.
Results: After this exercise, you should have created a new measure group for the FactResellerSales
table, removed unrequired measures, and renamed measures.
2. Wait for the Deployment Completed Successfully message in the Deployment Progress –
Adventure Works OLAP window, and then close the Deployment Progress – Adventure Works OLAP
window.
5. In the Measure Group drop-down list, select Reseller Sales and notice that there is no Customer
dimension, because reseller sales are sold to resellers, which are defined in a different dimension
table.
3. On the Select Creation Method page, ensure that Use an existing table is selected, and then click
Next.
MCT USE ONLY. STUDENT USE PROHIBITED
L4-3
4. On the Specify Source Information page, in the Main table list, select DimReseller, and then click
Next.
5. On the Select Related Tables page, clear Geography and Sales Territory, and then click Next.
6. On the Select Dimension Attributes page, select only the following attributes, and then click Next:
o Reseller Key
o Business Type
o Reseller Name
7. On the Completing the Wizard page, in the Name box, type Reseller, and then click Finish.
8. In the Sales.cube designer, click the Dimension Usage tab.
10. In the Add Cube Dimension dialog box, select Reseller, and then click OK.
11. On the Dimension Usage tab, click the Reseller Key cell at the intersection of the Reseller Sales
measure group and the Reseller dimension, and then click the ellipsis (…) button.
12. In the Define Relationship dialog box, note that a Regular relationship type has been detected, and
then click Cancel.
15. Wait for the Deployment Completed Successfully message in the Deployment Progress –
Adventure Works OLAP window, and then close the Deployment Progress – Adventure Works OLAP
window.
19. Click the Click to execute the query link, notice that there is now a Reseller dimension.
20. Expand Measures, expand Reseller Sales, and then drag Reseller Revenue to the query results area.
21. Expand Reseller, and then drag Business Type to the left of the Reseller Revenue column.
22. Click the Click to execute the query link to see reseller sales revenue broken down by business type.
Results: After this exercise, you should have added a Reseller dimension that uses a regular relationship
with the Reseller Sales measure group to enable you to analyze reseller sales data.
3. Under Standard setting, review each of the storage setting options. When you have finished, drag
the slider to Automatic MOLAP, and then click OK.
4. Repeat the previous steps to configure the Reseller Sales measure group for Automatic MOLAP
proactive caching.
2. Right-click Internet Sales (0 Aggregation Designs), and then click Design Aggregations.
4. On the Review Aggregation Usage page, click Set All to Default, and then click Next.
5. On the Specify Object Counts page, click Count. When the count process has completed, click Next.
6. On the Set Aggregations Options page, select Performance gain reaches, ensure that the value is
set to 30%, and then click Start.
7. When the wizard has designed aggregations for a performance gain of at least 30 percent, click Next.
8. On the Completing the Wizard page, change the name of the aggregation to InternetSalesAgg,
select Save the aggregations but do not process them, and then click Finish.
9. Repeat the previous steps to design Reseller Sales aggregations for a performance gain of 30
percent. Name the aggregation design ResellerSalesAgg.
15. In Object Explorer, expand Databases, expand Adventure Works OLAP, expand Cubes, expand
Sales, expand Measure Groups, expand Internet Sales, and then expand Aggregation Designs.
16. Verify that the InternetSalesAgg aggregation design has been deployed with the cube.
17. Expand Reseller Sales and its Aggregation Designs folder to verify that the ResellerSalesAgg
aggregation design has been deployed with the cube.
18. Close SQL Server Management Studio.
Results: After this exercise, you should have configured proactive caching and defined the storage mode
aggregations for the Internet Sales and Reseller Sales measure groups.
MCT USE ONLY. STUDENT USE PROHIBITED
L5-1
3. Click Yes when prompted to confirm that you want to run the command file, and then wait for the
script to finish.
10. In the Non-empty behavior list, select Internet Revenue and Reseller Revenue, and then click OK.
12. Above the form, click the Script View button, and then check the MDX text that has been added to
the cube.
5. On the Build menu, click Deploy Solution. If you are prompted to overwrite the database, click Yes.
If you are prompted for impersonation credentials, enter the password Pa55w.rd for
ADVENTUREWORKS\ServiceAcct, and then click OK.
Results: After this exercise, you should have added three calculated members to the Sales cube and
deployed the cube to the MIA-SQL instance of SQL Server Analysis Services.
2. In the Connect to Server dialog box, in the Server type drop-down list, select Analysis Services.
3. In the Server name drop-down list, select MIA-SQL, and then click Connect.
4. In Object Explorer, expand Databases, right-click Adventure Works OLAP, point to New Query,
and then click MDX.
SELECT
{
[Measures].[Internet Revenue],
[Measures].[Reseller Revenue],
[Measures].[Total Revenue]
} ON COLUMNS,
[Product].[Categorized Products].Members ON ROWS
FROM [Sales]
SELECT
{
[Measures].[Internet Cost],
[Measures].[Internet Revenue],
[Measures].[Internet Profit]
} ON COLUMNS,
[Customer].[City].Members ON ROWS
FROM [Sales]
4. In the query pane, after the existing code, add the following line of code:
SELECT
{
[Measures].[Reseller Cost],
[Measures].[Reseller Revenue],
[Measures].[Reseller Profit]
} ON COLUMNS,
[Sales Territory].[Sales Territory].Members ON ROWS
FROM [Sales]
4. In the Get & Transform group, click New Query, point to From Database, and then click From SQL
Server Analysis Services Database.
5. In the Microsoft SQL Server Analysis Services Database dialog box, in the Server box, type MIA-
SQL, and click OK.
7. In the Navigator pane, expand Adventure Works OLAP, expand the Sales folder, expand the Sales
cube, and then expand the Internet Sales measure group.
3. Click Get External Data, click From Other Sources, and then click From Analysis Services.
4. In the Data Connection Wizard dialog box, on the Connect to Database Server page, in the Server
name text box, type MIA-SQL, and then click Next.
5. On the Select Database and Table page, ensure that the Adventure Works OLAP database and the
Sales cube are selected, and then click Next.
6. On the Save Data Connection File and Finish page, click Finish.
7. In the Import Data dialog box, click New worksheet, and then click OK.
8. In the PivotTable Fields pane, select Internet Revenue, Reseller Revenue, and Total Revenue.
10. In the worksheet, expand Europe, and note the Total Revenue value for the United Kingdom.
Results: After this exercise, you should have created several test MDX queries in SQL Server Management
Studio and an Excel spreadsheet that connects to the Sales OLAP cube.
MCT USE ONLY. STUDENT USE PROHIBITED
L6-1
3. Click Yes when prompted to confirm that you want to run the command file, and then wait for the
script to finish.
4. If you are prompted for impersonation credentials, enter the password Pa55w.rd for
ADVENTUREWORKS\ServiceAcct, and then click OK.
9. In the Name box, change the name of this action to Internet Sales Details.
10. In the Measure group members list, select Internet Sales.
11. In the Drillthrough Columns box, in the Select dimensions list, select Customer, in the Return
Columns list, select City and Full Name, and then click OK.
12. In the Drillthrough Columns box, in the Select dimensions list, click Order Date, in the Return
Columns list, select Full Date Alternate Key, and then click OK.
13. In the Drillthrough Columns box, in the Select dimensions list, click Product, in the Return
Columns list, select English Product Name, and then click OK.
14. Expand Additional Properties, and then in the Caption box, type Drillthrough to Order Details.
4. On the Cube menu, click Analyze in Excel. If a security notice is displayed, click Enable.
MCT USE ONLY. STUDENT USE PROHIBITED
L6-2 Developing SQL Data Models
5. In Excel, in the PivotTable Fields pane, under Internet Sales, select Internet Revenue.
6. In the PivotTable Fields pane, under Order Date, select Order Date.Calendar Date.
8. In the PivotTable, right-click the sales amount for Bikes in 2007, point to Additional Actions, and
then click Drillthrough to Order Details.
9. View the new worksheet that is generated by the drill-through action, noting that it shows the city,
customer name, and product name for each sale of a bike in 2007.
Results: After this exercise, you should have a new drill-through action in the solution.
3. Clear the first row of the first Perspective Name column, and then type Internet Sales.
4. In the same column, clear the check box for the following objects:
1. The Reseller Sales measure group (this clears all of the measures in this measure group).
5. Clear the first row of the second Perspective Name column, and then type Reseller Sales.
6. In the same column, clear the check box for the following objects:
a. The Internet Sales measure group (this clears all of the measures in this measure group).
2. When deployment has successfully completed, close the Deployment Progress window.
3. In the Cube Designer, click the Browser tab, and then click the Reconnect icon.
4. In the cube selection area above the Metadata pane, click the ellipsis (…), select Internet Sales, and
then click OK.
MCT USE ONLY. STUDENT USE PROHIBITED
L6-3
5. In the Metadata pane, expand Measures, and then note that only the Internet Sales measure group
is shown in this perspective.
6. Expand Internet Sales, and then drag the Internet Revenue measure to the query results area.
7. In the Metadata pane, expand the Customer dimension, and then drag the Yearly Income hierarchy
to the left of the Internet Revenue figure.
9. This displays Internet revenue for customers, broken down by income band.
11. In the Analyze in Excel dialog box, select the Reseller Sales perspective, and then click OK. If a
security notice is displayed, click Enable.
12. In Excel, in the PivotTable Fields pane, note that only the Reseller Sales measures are shown.
13. In the PivotTable Fields pane, under Reseller Sales, select Reseller Revenue.
14. In the PivotTable Fields pane, under Reseller, select Business Type. The PivotTable shows revenue
for reseller sales, broken down by business type.
Results: After this exercise, you should have defined a new perspective in the solution.
3. In the Select Language dialog box, select French (France), and then click OK.
4. In the row for the Calendar Date hierarchy, type Date du Calendrier in the French (France)
translation column.
5. In the row for the Calendar Year level, type Année in the French (France) translation column.
6. Note: To type é, press Alt+130 by using the number pad. Ensure that Num Lock is on. If this
does not work, type the captions without accents.
7. In the row for the Calendar Semester level, type Semestre in the French (France) translation column.
8. In the row for the Calendar Quarter level, type Trimestre in the French (France) translation column.
9. In the row for the Month level, type Mois in the French (France) translation column.
10. In the row for the Day level, type Journée in the French (France) translation column.
11. On the Translation tab toolbar, click Show All Attributes. This reveals the attributes that are hidden
in the dimension.
12. Click the French (France) translation row for the Month attribute, and then click the [.] button.
13. In the Attribute Data Translation dialog box, in the Translation columns list, click
FrenchMonthName, and then click OK.
MCT USE ONLY. STUDENT USE PROHIBITED
L6-4 Developing SQL Data Models
3. On the Cube menu, click New Translation, and then, in the Select Language dialog box, click
French (France), and then click OK.
4. In the row for the Internet Sales measure group, in the French (France) translation column, type
Ventes d'Internet.
5. In the row for the Internet Revenue measure, in the French (France) translation column, type
Revenu d’Internet.
6. In the row for the Order Date dimension, in the French (France) translation column, type Date de
Vente.
3. In the Cube Designer, click the Browser tab, and then click the Reconnect icon.
4. On the toolbar, in the Language list, select French (France).
5. In the Metadata pane, expand Measures, expand Ventes d’Internet, and then drag Revenu
d’Internet to the query results area.
6. In the Metadata pane, expand the Date de Vente dimension, and then drag the Date de
Vente.Date du Calendrier hierarchy to the left of Revenu d’Internet.
7. Click the Click to execute the query link. Note that the captions are displayed in French, and that
the month names in the Mois column are also in French.
Results: After this exercise, you should have French data and metadata in the cube.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-1
3. Click Yes when prompted to confirm that you want to run the command file, and then wait for the
script to finish.
o Name: AWSalesTab
o Location: D:\Labfiles\Lab07\Starter
4. If the Tabular model designer dialog box is displayed, in the Workspace server list, select
localhost\SQL2, in the Compatibility level box, select SQL Server 2017 / Azure Analysis Services
(1400), and then click OK.
2. In the Get Data dialog box, select SQL Server database, and then click Connect.
3. On the SQL Server database page, type the following values, and then click OK:
4. On the Impersonation Information page, in the Impersonate Mode box, select Impersonate
Service Account, and then click Connect.
6. On the Navigator page, select the following source tables, then click OK:
o DimDate
o DimEmployee
o DimGeography
MCT USE ONLY. STUDENT USE PROHIBITED
L7-2 Developing SQL Data Models
o DimProduct
o DimProductCategory
o DimProductSubcategory
o DimReseller
o FactResellerSales
8. In the Query Settings pane, in the Name box, change DimDate to Date, then press enter.
10. In the Choose Columns dialog box, clear the following columns, and then click OK:
o SpanishDayNameOfWeek
o FrenchDayNameOfWeek
o DayNumberOfYear
o WeekNumberOfYear
o SpanishMonthName
o FrenchMonthName
o CalendarSemester
o FiscalSemester
11. In the Queries pane, select DimEmployee.
12. In the Query Settings pane, in the Name box, change DimEmployee to Employee, then press Enter.
o SalesTerritoryKey
o NameStyle
o Title
o HireDate
o BirthDate
o LoginID
o EmailAddress
o Phone
o MaritalStatus
o EmergencyContactName
o EmergencyContactPhone
o SalariedFlag
o Gender
o PayFrequency
o Baserate
MCT USE ONLY. STUDENT USE PROHIBITED
L7-3
o VacationHours
o SickLeaveHours
o CurrentFlag
o SalesPersonFlag
o StartDate
o EndDate
o Status
16. In the Query Settings pane, in the Name box, change DimGeography to Geography, then press
Enter.
o SpanishCountryRegionName
o FrenchCountryRegionName
o IpAddressLocator
20. In the Query Settings pane, in the Name box, change DimProduct to Product, then press Enter.
22. In the Choose Columns dialog box, clear the following columns, and then click OK:
o WeightUnitMeasureCode
o SizeUnitMeasureCode
o SpanishProductName
o FrenchProductName
o FinishedGoodsFlag
o SafetyStockLevel
o ReorderPoint
o DaysToManufacture
o ProductLine
o DealerPrice
o Class
o Style
o ModelName
o FrenchDescription
o ChineseDescription
o ArabicDescription
o HebrewDescription
MCT USE ONLY. STUDENT USE PROHIBITED
L7-4 Developing SQL Data Models
o ThaiDescription
o GermanDescription
o JapaneseDescription
o TurkishDescription
o StartDate
o EndDate
o Status
24. In the Query Settings pane, in the Name box, change DimProductCategory to Product Category,
then press Enter.
o SpanishProductCategoryName
o FrenchProductCategoryName
28. In the Query Settings pane, in the Name box, change DimProductSubcategory to Product
Subcategory, then press Enter.
30. In the Choose Columns dialog box, clear the following columns, and then click OK:
o SpanishProductSubcategoryName
o FrenchProductSubcategoryName
32. In the Query Settings pane, in the Name box, change DimReseller to Reseller, then press enter.
33. On the Columns menu, click Choose Columns.
34. In the Choose Columns dialog box, clear the following columns, and then click OK:
o OrderFrequency
o OrderMonth
o FirstOrderYear
o LastOrderYear
o ProductLine
o AddressLine1
o AddressLine2
o AnnualSales
o BankName
o MinPaymentType
o MinPaymentAmount
MCT USE ONLY. STUDENT USE PROHIBITED
L7-5
o AnnualRevenue
o YearOpened
36. In the Query Settings pane, in the Name box, change FactResellerSales to Reseller Sales, then
press enter.
38. In the Choose Columns dialog box, clear the following columns, and then click OK:
o DueDateKey
o PromotionKey
o CurrencyKey
o SalesTerritoryKey
o RevisionNumber
o CarrierTrackingNumber
o CustomerPONumber
o DueDate
39. On the toolbar, click Import, and then wait for the data to be imported. When the data has been
imported successfully, click Close.
2. On the Column menu, point to AutoSum, click Sum, and then, in the formula bar, modify the
expression that has been generated to name the measure Quantity, as shown in the following
example:
Quantity:=Sum([OrderQuantity])
3. Widen the OrderQuantity column to see the calculated Quantity measure, and then click the cell in
the measure grid that contains the calculated value.
4. Press F4 to view the Properties pane, and then set the Format property to Whole Number, and the
Show Thousand Separator property to True.
6. On the Column menu, point to AutoSum, click Sum, and then modify the expression that is
generated to name the measure Cost, as shown in the following example:
Cost:=Sum([TotalProductCost])
8. Select the cell that contains the calculated Cost measure, and then, in the Properties pane, ensure
that the Format property is set to Currency.
10. On the Column menu, point to AutoSum, click Sum, and then modify the expression that is
generated to name the measure Revenue, as shown in the following example:
Revenue:=Sum([SalesAmount])
11. Widen the SalesAmount column to see the calculated Revenue measure.
12. Select the cell that contains the calculated Revenue measure, and then, in the Properties pane,
ensure that the Format property is set to Currency.
2. In the Analyze in Excel dialog box, ensure that Current Windows User is selected and that the
(Default) perspective is specified, and then click OK.
3. When Excel opens, in the PivotTable Fields pane, note that the measures that you defined are
displayed under a Reseller Sales measure group. The Reseller Sales table is also shown in this pane,
and contains the columns in the table on which the measures are based, which some users might find
confusing. You will fix this problem in the next exercise.
4. Select the Revenue measure, and then note that it is displayed in the PivotTable.
5. In the Geography table, select EnglishCountryRegionName. The revenue is shown for each country
or region, but the column name that is used to display this is not user-friendly.
Results: After this exercise, you should have created a tabular data model project.
2. Double-click the solid line between the Reseller Sales and Date tables, note the columns that are
used to define the relationship, and that this is an active relationship, and then click Cancel.
3. Double-click the dotted line between the Reseller Sales and Date tables, note the columns that are
used to define the relationship, and that this is an inactive relationship, and then click Cancel.
4. If the inactive relationship that you noted above is based on the OrderDateKey column, right-click
the dotted line, and then click Mark as Active so that the active relationship is based on the
OrderDateKey column.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-7
5. Right-click the dotted relationship line (which should now represent the relationship that is based on
the ShipDateKey column), and then click Delete.
7. Right-click the Date table title bar, click Rename, and then rename the table to Order Date.
8. In the Tabular Model Explorer, expand Data Sources, right-click SQL/MIA-
SQL;AdventureWorksDW, and then click Import New Tables.
12. In the Choose Columns dialog box, clear the following columns, and then click OK:
o SpanishDayNameOfWeek
o FrenchDayNameOfWeek
o DayNumberOfYear
o WeekNumberOfYear
o SpanishMonthName
o FrenchMonthName
o CalendarSemester
o FiscalSemester
14. In the Data Processing dialog box, once the data has been successfully imported, click Close.
15. Arrange the diagram so that you can see the Ship Date and Reseller Sales tables, and then drag the
ShipDateKey column from the Reseller Sales table to the DateKey column in the Ship Date table to
create the relationship.
3. Right-click either of the selected columns, and then click Hide from Client Tools.
4. In the maximized Geography table, right-click the StateProvinceCode column, click Rename, and
then rename the column to State or Province Code.
5. Repeat the previous step to rename the following columns in the Geography table:
7. Click the title bar of the Reseller table, and then click its Maximize icon.
8. In the maximized Reseller table, click the ResellerKey column, hold down CTRL, and then click the
GeographyKey column and the ResellerAlternateKey column to select the columns.
9. Right-click any of the selected columns, and then click Hide from Client Tools.
10. In the maximized Reseller table, right-click the BusinessType column, click Rename, and then
rename the column to Business Type.
11. Repeat the previous step to rename the following columns in the Reseller table:
NumberEmployees Employees
14. In the maximized Employee table, click the EmployeeKey column, hold down CTRL, and then click
the ParentEmployeeKey column, the EmployeeNationalIDAlternateKey column, and the
ParentEmployeeNationalIDAlternateKey column to select the columns.
15. Right-click any of the selected columns, and then click Hide from Client Tools.
16. In the maximized Employee table, right-click the FirstName column, click Rename, and then rename
the column to First Name.
17. Repeat the previous step to rename the following columns in the Employee table:
DepartmentName Department
19. Click the title bar of the Order Date table, and then click its Maximize icon.
20. In the maximized Order Date table, click the DateKey column, hold down CTRL, and then click the
DayNumberOfWeek column and the MonthNumberOfYear column to select the columns.
21. Right-click any of the selected columns, and then click Hide from Client Tools.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-9
22. In the maximized Order Date table, right-click the FullDateAlternateKey column, click Rename, and
then rename the column to Date.
23. Repeat the previous step to rename the following columns in the Order Date table:
EnglishDayNameOfWeek Weekday
EnglishMonthName Month
24. Click the Restore icon for the Order Date table.
25. Click the title bar of the Ship Date table, and then click its Maximize icon.
26. In the maximized Ship Date table, click the DateKey column, hold down CTRL, and then click the
DayNumberOfWeek column and the MonthNumberOfYear column to select the columns.
27. Right-click any of the selected columns, and then click Hide from Client Tools.
28. In the maximized Ship Date table, right-click the FullDateAlternateKey column, click Rename, and
then rename the column to Date.
29. Repeat the previous step to rename the following columns in the Ship Date table:
EnglishDayNameOfWeek Weekday
EnglishMonthName Month
30. Click the Restore icon for the Ship Date table.
31. Click the title bar of the Product table, and then click its Maximize icon.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-10 Developing SQL Data Models
32. In the maximized Product table, click the ProductKey column, hold down CTRL, and then click the
ProductAlternateKey column and the ProductSubcategoryKey column to select the columns.
33. Right-click any of the selected columns, and then click Hide from Client Tools.
34. In the maximized Product table, right-click the EnglishProductName column, click Rename, and
then rename the column to Product Name.
35. Repeat the previous step to rename the following columns in the Product table:
EnglishDescription Description
37. Click the title bar of the Product Subcategory table, and then click its Maximize icon.
38. In the maximized Product Subcategory table, click the ProductSubcategoryKey column, hold
down CTRL, and then click the ProductSubcategoryAlternateKey column and the
ProductCategoryKey column to select the columns.
39. Right-click any of the selected columns, and then click Hide from Client Tools.
42. Click the title bar of the Product Category table, and then click its Maximize icon.
43. In the maximized Product Category table, click the ProductCategoryKey column, hold down CTRL,
and then click the ProductCategoryAlternateKey column to select both columns. Right-click either
of the selected columns, and then click Hide from Client Tools.
44. In the maximized Product Category table, right-click the EnglishProductCategoryName column,
click Rename, and then rename the column to Category.
45. Click the Restore icon for the Product Category table.
46. Click the title bar of the Reseller Sales table, and then click its Maximize icon.
47. In the maximized Reseller Sales table, click the ProductKey column, hold down SHIFT, and then click
the ShipDate column to select all columns other than the Quantity, Cost, and Revenue measures
that you created in the previous exercise.
48. Right-click any of the selected columns, and then click Hide from Client Tools.
49. Click the Restore icon for the Reseller Sales table.
3. On the Column menu, point to Sort, and then click Sort by Column.
4. In the Sort by Column dialog box, in the Sort column, ensure that Weekday is selected, in the By
column, select DayNumberOfWeek, and then click OK.
5. On the Ship Date tab, click the column heading for the Month column.
6. On the Column menu, point to Sort, and then click Sort by Column.
7. In the Sort by Column dialog box, in the Sort column, ensure that Month is selected, in the By
column, select MonthNumberOfYear, and then click OK.
8. On the Order Date tab, click the column heading for the Weekday column.
9. On the Column menu, point to Sort, and then click Sort by Column.
10. In the Sort by Column dialog box, in the Sort column, ensure that Weekday is selected, in the By
column, select DayNumberOfWeek, and then click OK.
11. On the Order Date tab, click the column heading for the Month column.
12. On the Column menu, point to Sort, and then click Sort by Column.
13. In the Sort by Column dialog box, in the Sort column, ensure that Month is selected, in the By
column, select MonthNumberOfYear, and then click OK.
2. In the diagram, click the title bar of the Geography table, and then click its Maximize icon.
3. In the title bar of the maximized Geography table, click the Create Hierarchy icon, and then rename
the new hierarchy to Location.
4. In the maximized Geography table, drag the Country or Region column onto the Location
hierarchy, drag the State or Province column onto the Location hierarchy, drag the City column
onto the Location hierarchy, and then drag the Postal Code column onto the Location hierarchy.
7. In the title bar of the maximized Order Date table, click the Create Hierarchy icon, and then rename
the new hierarchy to Calendar Date.
8. In the maximized Order Date table, drag the following columns onto the Calendar Date hierarchy, in
the same order:
o Calendar Year
o Calendar Quarter
o Month
o Day of Month
9. In the title bar of the maximized Order Date table, click the Create Hierarchy icon, and then rename
the new hierarchy to Fiscal Date.
10. In the maximized Order Date table, drag the following columns onto the Fiscal Date hierarchy, in
the same order:
o Fiscal Year
o Fiscal Quarter
MCT USE ONLY. STUDENT USE PROHIBITED
L7-12 Developing SQL Data Models
o Month
o Day of Month
11. Click the Restore icon for the Order Date table.
2. In the Analyze in Excel dialog box, ensure that Current Windows User is selected and that the
(Default) perspective is specified, and then click OK.
3. In Excel, in the PivotTable Fields pane, select Revenue. The total revenue is shown in the PivotTable.
4. In the Order Date table, select the Calendar Date hierarchy. The revenue for each calendar year is
shown.
5. In the PivotTable, expand 2007 to reveal the quarterly revenue, and then expand quarter 3 to show
the monthly revenue. Note that the months are displayed in chronological order.
6. Close Excel without saving the workbook.
Results: After completing this exercise, you should have a tabular data model that includes renamed
columns, custom sort orders, and specific relationships between tables.
3. In the Partition Manager dialog box, ensure that the Reseller Sales table is selected, and then click
New.
4. In the Partition Name box, change the text to Since 2008.
5. In the Partition Name column, click Partition, and then in the Partition Name box, change the text
to Before 2008, and then click OK.
7. In the Partition Manager dialog box, ensure that the Before 2008 partition is selected, and then
click the Design button.
8. In the Query Editor, click the drop-down selector in the OrderDateKey cell, click Number Filters,
and then click Less Than.
9. In the Filter Rows dialog box, in the box to the right of is less than type 20080101, then click OK.
10. On the toolbar, click Import.
11. In the Partition Manager dialog box, click the Since 2008 partition is selected, and then click the
Design button.
12. In the Query Editor, click the drop-down selector in the OrderDateKey cell, click Number Filters,
and then click Greater Than.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-13
13. In the Filter Rows dialog box, in the box to the right of is greater than type 20080101, then click
OK.
16. On the Model menu, point to Process, and then click Process Partitions.
17. In the Process Partitions dialog box, for Mode, select Process Full, in the Process column, select
Before 2008 and Since 2008, and then click OK. If you are prompted for impersonation credentials,
type the user name ADVENTUREWORKS\ServiceAcct and the password Pa55w.rd, and then click
OK.
18. In the Data Processing dialog box, wait until the processing is complete, and then observe how
many rows were transferred for each partition, and then click Close.
2. In the Perspectives dialog box, click New Perspective, and then type Products Analysis.
3. In the Products Analysis column, select Product, Product Category, Product Subcategory,
Reseller Sales, and then click OK.
5. In the Analyze in Excel dialog box, ensure that Current Windows User is selected, for Perspective,
select Products Analysis, and then click OK.
6. In Excel, in the PivotTable Fields pane, note that only the tables that you specified for the
perspective are visible.
3. In the Name column, type US Bike Sales, and then in the Permissions column, select Read and
Process.
4. In the DAX Filter column, for the Geography table, type the DAX expression as shown below:
5. In the DAX Filter column, for the Product Category table, type the DAX expression as shown below,
and then click OK:
='Product Category'[Category]="Bikes"
7. In the Analyze in Excel dialog box, click Role, and then in the drop-down list below Role, select US
Bike Sales, and then click OK.
8. Ensure that the (Default) perspective is specified, and then click OK.
MCT USE ONLY. STUDENT USE PROHIBITED
L7-14 Developing SQL Data Models
9. In Excel, in the PivotTable Fields pane, under Reseller Sales, select Revenue.
13. Note that reseller data is only showing where Location is United States and Category is Bikes.
2. In the AWSalesTab Property Pages dialog box, in the Deployment Server section, verify that the
Server value is localhost\SQL2.
3. Change the Database property to AdventureWorksTab, change the Model Name property to
Reseller Sales, and then click OK.
4. On the Build menu, click Deploy AWSalesTab. If you are prompted for impersonation credentials,
type the user name ADVENTUREWORKS\ServiceAcct and the password Pa55w.rd, and then click
OK.
5. In the Deploy dialog box, when deployment has completed, click Close.
2. On the Data tab, in the Get External Data area, in the From Other Sources drop-down list, select
From Analysis Services.
3. In the Data Connection Wizard dialog box, in the Server name box, type MIA-SQL\SQL2, ensure
that Use Windows Authentication is selected, and then click Next.
4. On the Select Database and Table page, ensure that the AdventureWorksTab database and the
Reseller Sales cube are selected, and then click Next.
5. On the Save Data Connection File and Finish page, click Finish.
6. In the Import Data dialog box, ensure that the Existing worksheet option is selected, and then click
OK.
10. Explore the data in the PivotTable. When you have finished, close Excel without saving the workbook.
Results: After this exercise, you should have deployed the tabular data model project.
MCT USE ONLY. STUDENT USE PROHIBITED
L8-1
3. In the User Account Control dialog box, click Yes, and then wait for the script to finish.
2. If the Tabular model designer dialog box is displayed, in the Workspace server list, select
localhost\SQL2, and then click OK.
3. If the Tabular Model Designer dialog box appears, prompting you to run a script on the server, click
Yes.
5. On the Model menu, point to Process, and click Process All. If the Impersonation Credentials
dialog box appears, use the following credentials, and then click OK:
6. In the Data Processing dialog box, when all of the tables have been processed, click Close.
7. On the Employee tab, after the existing columns, double-click the Add Column header, type
Employee Name, and then press Enter.
8. Click the Employee Name column, click the formula bar, and type the following DAX expression, and
then press Enter:
=[First Name] & IF(ISBLANK([Middle Name]), "", CONCATENATE(" ", [Middle Name])) &
CONCATENATE(" ", [Last Name])
Verify that the new column shows the full employee name (including middle name, if present).
9. Click the First Name column header, and then hold Shift and click the Middle Name column header
to select the First Name, Last Name, and Middle Name columns. Then right-click any of the
selected columns and click Hide from Client Tools.
2. Click the SalesProfit column, then click the formula bar, and type the following DAX expression, and
then press Enter:
=[SalesAmount]-[TotalProductCost]
Wait for the table to finish updating, and note the calculated values in the new column.
3. Press F4 and view the Properties pane to verify that the Data Format property for this column has
been set to Currency.
2. Click Subcategory, click the formula bar and type the following DAX expression, and then press
Enter:
=RELATED('Product Subcategory'[Subcategory])
Scroll down to verify that products with a subcategory are shown with the subcategory name. Note
that some products at the beginning of the table are not members of a subcategory, so have a blank
value in the new column.
3. After the Subcategory column, double-click Add Column, type Category, then press Enter.
4. Click Category, click the formula bar, and type the following DAX expression, and then press Enter:
=RELATED('Product Category'[Category])
Scroll down to verify that products with a category are shown with the category name. Note that
some products at the beginning of the table are not members of a category, so have a blank value in
the new column.
5. On the Model menu, point to Model View, and then click Diagram View.
6. In the diagram, click the title bar of the Product table, then click its Maximize icon.
7. On the title bar of the maximized Product table, click the Create Hierarchy icon, type Categorized
Products, and then press Enter.
8. Drag the following columns from the column list of the Product table to the Categorized Products
hierarchy:
o Category
o Subcategory
o Product Name
10. On the Model menu, point to Model View, and then click Data View.
11. On the Product Subcategory tab, right-click the Subcategory column—which is the only visible
column—and click Hide from Client Tools.
MCT USE ONLY. STUDENT USE PROHIBITED
L8-3
12. In the Product Category table, right-click the Category column—which is the only visible column—
and click Hide from Client Tools.
13. On the File menu, click Save All.
2. In the Analyze in Excel dialog box, ensure that Current Windows User is selected and that the
(Default) perspective is specified, and click OK.
3. In Excel, in the PivotTable Fields pane, under Reseller Sales, select the Revenue measure.
4. Under Product, select Categorized Products so that the PivotTable shows sales revenue for each
product category.
5. Under Employee, drag the Employee Name to the Columns area so that the PivotTable shows sales
revenue for each employee.
6. Expand product categories and subcategories to verify that the hierarchy shows subcategory and
product names.
Results: After this exercise, you should have a calculated column named Employee Name in the
Employee table, a calculated measure named SalesProfit in the Reseller Sales table, and a hierarchy
named Categorized Products in the Product table.
2. In the formula bar, type the following DAX expression, and then press Enter:
Profit:=SUM([SalesProfit])
3. Select the cell containing the Profit measure. In the Properties pane, set the Format property to
Currency.
4. Right-click the column header for the SalesProfit column and click Hide from Client Tools.
Margin:=[Profit]/[Revenue]
MCT USE ONLY. STUDENT USE PROHIBITED
L8-4 Developing SQL Data Models
3. Select the cell containing the Margin measure, and in the Properties pane, set Format to
Percentage.
4. On the File menu, click Save All.
2. On the Table menu, point to Date, and then click Mark As Date Table.
3. In the Mark as Date Table dialog box, in the Date list, ensure is Date selected, and then click OK.
4. On the Reseller Sales tab, click the empty cell in the measure grid under the Revenue measure.
5. In the formula bar, type the following DAX expression, and then press Enter:
6. Select the cell containing the Previous Year Revenue measure, and in the Properties pane, set the
Format property to Currency.
2. In the Analyze in Excel dialog box, ensure that Current Windows User is selected and that the
(Default) perspective is specified, and click OK.
3. In Excel, in the PivotTable Fields section, under Reseller Sales table, select the Revenue, Profit,
Margin, and Previous Year Revenue measures.
4. Under Order Date, drag the Calendar Date hierarchy to the Rows area so that the PivotTable shows
revenue, profit, margin, and previous year revenue for each year.
5. Expand 2006 and 2007, and note that the revenue for each quarter in 2006 is shown as the previous
year revenue for the same quarters in 2007.
6. Close Excel without saving the workbook. Leave Visual Studio open for the next exercise.
Results: At the end of this exercise, the Reseller Sales table should contain the following measures:
Profit
Margin
2. In the formula bar, type the following DAX expression, and then press Enter:
3. Select the cell containing the Revenue Goal measure, and in the Properties pane, set the Format
property to Currency.
4. Right-click the cell containing the Revenue Goal measure, and click Hide from Client Tools.
2. In the Key Performance Indicator (KPI) dialog box, note that the KPI base measure (value) is
defined by the Revenue measure. Under Target, ensure that Measure is selected, and in the list,
select the Revenue Goal measure.
3. On the red, amber, and green bar, drag the first status threshold slider to 75% and the second to
95%. Note the default icon style, and click OK. Notice that the Revenue measure gains an icon in the
measure grid to indicate that it is the basis for a KPI.
4. On the File menu, click Save All.
3. In Excel, in the PivotTable Fields pane, expand KPIs, expand Revenue, and then select the Value,
Goal, and Status check boxes.
4. Under Order Date, drag the Fiscal Date hierarchy to the Rows area so that the PivotTable shows the
KPI data for each year.
5. Expand 2008 and its quarters and months to view the status of the KPI for each month.
6. Close Excel without saving the workbook. Leave Visual Studio open for the next exercise.
Results: At the end of this exercise, the Reseller Sales table should include a measure named Revenue
Goal and a KPI based on the Revenue Goal measure.
MCT USE ONLY. STUDENT USE PROHIBITED
L8-6 Developing SQL Data Models
2. After the existing columns, double-click Add Column, type Path, and then press Enter.
3. Click Path, click the formula bar, type the following DAX expression, and then press Enter:
=PATH([EmployeeKey], [ParentEmployeeKey])
Wait for the table to finish updating, and note the calculated values in the new column.
2. Click Level1, click the formula bar, type the following DAX expression, and then press Enter:
3. In the first empty column to the right, double-click Add Column, type Level2, then press Enter.
4. Click Level2, click the formula bar, type the following DAX expression, and then press Enter:
5. In the first empty column to the right, double-click Add Column, type Level3, then press Enter.
6. Click Level3, click the formula bar, type the following DAX expression, and then press Enter:
7. In the first empty column to the right, double-click Add Column, type Level4, then press Enter.
8. Click Level4, click the formula bar, type the following DAX expression, and then press Enter:
2. Click the Employee table, and then click the Maximize button.
3. In the maximized Employee table, click Create Hierarchy, type Employee Hierarchy, and then press
Enter.
4. Drag the following columns from the column list of the Employee table to the Employee Hierarchy,
in the following order:
a. Level1
b. Level2
c. Level3
d. Level4
MCT USE ONLY. STUDENT USE PROHIBITED
L8-7
5. Click the Path column, hold Shift and click the Level4 column. Then right-click the selected columns
and click Hide from Client Tools.
6. In the title bar, click Restore.
2. In the Analyze in Excel dialog box, ensure that Current Windows User is selected and that the
(Default) perspective is specified, and click OK.
3. In Excel, in the PivotTable Fields section, under Reseller Sales, select the Revenue measure.
4. Under Employee, select Employee Hierarchy so that the PivotTable shows revenue for the top-level
employee.
5. Expand the employee hierarchy to view sales totals for managers and their subordinates. Note that
the personal revenue for sales managers is shown with a blank employee name under the total for
that sales manager.
Results: At the end of this exercise, the Employee table should include a hierarchy named Employee
Hierarchy.
MCT USE ONLY. STUDENT USE PROHIBITED
MCT USE ONLY. STUDENT USE PROHIBITED
L9-1
4. In the User Account Control dialog box, click Yes, and then wait for the script to finish.
2. In the New Project dialog box, expand Business Intelligence, then click Analysis Services, then
click Analysis Services Multidimensional and Data Mining Project.
3. Type AW Data Mining in the Name box, then type D:\Labfiles\Lab09\Starter in the Location box,
and then click OK.
4. In Solution Explorer, right-click Data Sources, and then click New Data Source.
5. In the Data Source Wizard, on the Welcome to the Data Source Wizard page, click Next.
6. On the Select how to define the connection page, click Create a data source based on an
existing or new connection, and then click New.
7. In the Connection Manager dialog box, in the Server name field, type MIA-SQL, in the Select or
enter a database name drop-down list, select AdventureWorksDW, and click OK.
8. In the Data Source Wizard, on the Select how to define the connection page, click Next.
9. On the Impersonation Information page, click Use the service account, and then click Next.
11. In Solution Explorer, right-click Data Source Views, and then click New Data Source View.
12. In the Data Source View Wizard, on the Welcome to the Data Source View Wizard page, click
Next.
13. On the Select a Data Source page, ensure that Adventure Works DW is selected, and then click
Next.
14. On the Select Tables and Views page, in the Available objects list, click ProspectiveBuyer (dbo),
hold the Ctrl key. Click vTargetMail (dbo) and click the > button to move the selected objects to the
Included objects list, and then click Next.
15. On the Completing the Wizard page, in the Name field, type Adventure Works DW DM View,
and then click Finish.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-2 Developing SQL Data Models
2. In the Data Mining Wizard, on the Welcome to the Data Mining Wizard page, click Next.
3. On the Select the Definition Method page, ensure that From existing relational database or data
warehouse is selected, and then click Next.
4. On the Create the Data Mining Structure page, ensure that Create mining structure with mining
model is selected and select the Microsoft Decision Trees data mining technique. Then click Next.
5. On the Select a Data Source View page, select Adventure Works DW DM View and click Next.
6. On the Specify Table Types page, in the vTargetMail row, select the check box in the Case column,
and then click Next.
7. On the Specify the Training Data page, in the Mining model structure table, in the BikeBuyer
row, select the check box in the Predictable column.
8. In the CustomerKey row, select the check box in the Key column; for all other rows, select the Input
check box, and then click Next.
9. On the Specify Columns’ Content and Data Type page, click Detect. Ensure that the content type
of the Bike Buyer column is identified as Discrete, and change the Yearly Income column to
Discrete. Then click Next.
10. On the Create Testing Set page, note that the Percentage of data for testing value is 30 percent,
and then click Next.
11. On the Completing the Wizard page, in the Mining structure name field, type Purchase
Prediction.
12. In the Mining model name field, type Purchase Decision Tree, and then click Finish.
14. When deployment is complete, close the Deployment Progress - AW Data Mining window.
2. In the Purchase Prediction.dmm [Design] window, on the Mining Models tab, right-click
anywhere, and then click New Mining Model.
3. In the New Mining Model dialog box, in the Model name box, type Purchase - Bayes. Select
Microsoft Naive Bayes in the Algorithm name box, and then click OK.
4. In the Microsoft Visual Studio dialog box, read the information message about content types
unsupported by the Microsoft Naïve Bayes algorithm, then click Yes.
5. In the Mining Models tab, in the Purchase - Bayes column, in the Name Style row, select Ignore to
exclude the column from the model.
7. When deployment is complete, close the Deployment Progress - AW Data Mining window.
Results: After this exercise, you should have a data mining structure with two data models.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-3
2. In the Mining Model drop-down list, ensure that Purchase Decision Tree is selected, and on the
Dependency Network tab, move the slider gradually from All Links to Strongest Links to see which
factors are the strongest predictors that a customer will purchase a bike. You might need to move the
Mining Legend window to be able to see the Dependency Network tab.
3. On the Decision Tree tab, in the Background drop-down list, select 1. Then view the decision tree to
see how the other column values influence a value of 1 for Bike Buyer.
4. In the Mining Model drop-down list, select Purchase - Bayes, and on the Attribute Profiles tab,
view the color-coded indicators of the values for each column when compared to customers with a
Bike Buyer value of 1 or 0.
5. On the Attribute Characteristics tab, in the Attribute drop-down list, ensure that Bike Buyer is
selected, and in the Value drop-down list, select 1. Then view the probability for each of the other
column values when the Bike Buyer value is 1.
6. On the Attribute Discrimination tab, in the Attribute drop-down list, ensure that Bike Buyer is
selected. In the Value 1 drop-down list, select 1, and in the Value 2 drop-down list, select 0. Then
note how values for all other columns favor a particular Bike Buyer value.
Results: After this exercise, you should have reviewed the output of data mining models using Visual
Studio.
3. On the Lift Chart tab, review the lift chart, and the detailed data in the Mining Legend window.
The Purchase Decision Tree model is closer to the Ideal Model, and can therefore be considered
more accurate.
o Population: 5,000 (this is the number of potential customers you plan to contact).
MCT USE ONLY. STUDENT USE PROHIBITED
L9-4 Developing SQL Data Models
o Fixed cost: 500 (this is the fixed cost of your marketing campaign).
o Individual cost: 1 (this is the cost associated with contacting each customer).
o Revenue per individual: 150 (this is the amount you expect a customer to spend if they respond
positively to the campaign).
3. Review the chart and the Mining Legend window to evaluate which mining model is likely to
generate the most profitable marketing campaign based on the test data.
2. Review the matrix, noting that for each model it shows the number of times the model predicted a
Bike Buyer value of 1 or 0 on rows, with columns for the actual value of the Bike Buyer column in
the test data.
o Fold Count: 5 (this is the number of partitions used to group the data for analysis).
o Target State: 1 (this is the desired value for the target attribute).
o Target Threshold: 0.7 (this is a value between 0 and 1 that indicates the level of accuracy
required for a prediction to be considered correct).
3. View the resulting report, and note that for each mining model, the results include the following:
o Classifications for true positives, false positives, true negatives, and false negatives.
Results: After this exercise, you should have two validated data mining models in your data mining
structure.
3. In the Name field, type Promotion Targeting, in the Location field, type
D:\Labfiles\Lab09\Starter, and then click OK.
4. In the Report Wizard, on the Welcome to the Report Wizard page, click Next.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-5
5. On the Select the Data Source page, select New data source, change the Name to
AWDataMining.
6. In the Type drop-down list, select Microsoft SQL Server Analysis Services, and click Edit.
7. In the Connection Properties dialog box, in the Server name field, type MIA-SQL, in the Select or
enter a database name drop-down list, click AW Data Mining, and then click OK.
10. In Query Designer, in the Mining Model pane, click Select Model.
11. In the Select Mining Model dialog box, expand Purchase Prediction, click Purchase - Bayes, and
click OK.
12. In the Select Input Table(s) pane, click Select Case Table.
13. In the Select Table dialog box, click ProspectiveBuyer (dbo), and click OK.
14. In the table at the bottom of the query designer, in the Source column, select ProspectiveBuyer
table, and then in the Field column, in the drop-down list, click FirstName.
15. Repeat step 14 to add five more rows to the table by using the settings in the following table, and
then click OK:
17. On the Select the Report Type page, select Tabular, and click Next.
18. On the Design the Table page, move all the columns into the Details area, and click Next.
19. On the Completing the Wizard page, change the Report name to Potential Bike Buyers and click
Finish.
20. In the Row Groups pane, click the (table1_Details_Group) drop-down list and click Group
Properties.
21. In the Group Properties dialog box, on the Sorting tab, click Add, in the Sort by drop-down list,
click [Purchase_Probability], and in the Order drop-down list, click Z to A. Then click OK.
22. In the report design pane, in the Purchase Probability column, right-click [Purchase Probability]
and click Text Box Properties.
23. In the Text Box Properties dialog box, click Number, select Percentage, and click OK.
MCT USE ONLY. STUDENT USE PROHIBITED
L9-6 Developing SQL Data Models
24. Click the Preview tab to review the Potential Bike Buyers report.
25. When you have finished working on the report, close Visual Studio.
Results: After this exercise, you should have an SSRS report that predicts bike purchasers.