Vous êtes sur la page 1sur 705

O F F I C I A L M I C R O S O F T L E A R N I N G P R O D U C T

10778A
Implementing Data Models and Reports
with Microsoft® SQL Server® 2012
ii Implementing Data Models and Reports with Microsoft® SQL Server® 2012

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.

© 2012 Microsoft Corporation. All rights reserved.


Microsoft and the trademarks listed at http://www.microsoft.com/about/legal/en/us/IntellectualProperty
/Trademarks/EN-US.aspx are trademarks of the Microsoft group of companies. All other trademarks are
property of their respective owners

Product Number: 10778A

Part Number: X18-29140

Released: 5/2012
MICROSOFT LICENSE TERMS
OFFICIAL MICROSOFT LEARNING PRODUCTS
MICROSOFT OFFICIAL COURSE Pre-Release and Final Release Versions

These license terms are an agreement between Microsoft Corporation and you. Please read them. They apply to
the Licensed Content named above, which includes the media on which you received it, if any. These license
terms also apply to any updates, supplements, internet based services and support services for the Licensed
Content, unless other terms accompany those items. If so, those terms apply.

BY DOWNLOADING OR USING THE LICENSED CONTENT, YOU ACCEPT THESE TERMS. IF YOU DO NOT ACCEPT
THEM, DO NOT DOWNLOAD OR USE THE LICENSED CONTENT.

If you comply with these license terms, you have the rights below.

1. DEFINITIONS.

a. “Authorized Learning Center” means a Microsoft Learning Competency Member, Microsoft IT Academy
Program Member, or such other entity as Microsoft may designate from time to time.

b. “Authorized Training Session” means the Microsoft-authorized instructor-led training class using only
MOC Courses that are conducted by a MCT at or through an Authorized Learning Center.

c. “Classroom Device” means one (1) dedicated, secure computer that you own or control that meets or
exceeds the hardware level specified for the particular MOC Course located at your training facilities or
primary business location.

d. “End User” means an individual who is (i) duly enrolled for 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 MOC Course and any other content accompanying this agreement.
Licensed Content may include (i) Trainer Content, (ii) sample code, and (iii) associated media.

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, (ii) currently certified as a
Microsoft Certified Trainer under the Microsoft Certification Program, and (iii) holds a Microsoft
Certification in the technology that is the subject of the training session.

g. “Microsoft IT Academy Member” means a current, active member of the Microsoft IT Academy
Program.

h. “Microsoft Learning Competency Member” means a Microsoft Partner Network Program Member in
good standing that currently holds the Learning Competency status.

i. “Microsoft Official Course” or “MOC Course” means the Official Microsoft Learning Product instructor-
led courseware that educates IT professionals or developers on Microsoft technologies.
j. “Microsoft Partner Network Member” or “MPN Member” means a silver or gold-level Microsoft Partner
Network program member in good standing.

k. “Personal Device” means one (1) device, workstation or other digital electronic device that you
personally own or control that meets or exceeds the hardware level specified for the particular MOC
Course.

l. “Private Training Session” means the instructor-led training classes provided by MPN Members for
corporate customers to teach a predefined learning objective. 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.

m. “Trainer Content” means the trainer version of the MOC Course and additional content designated
solely for trainers to use to teach a training session using a MOC Course. Trainer Content may include
Microsoft PowerPoint presentations, instructor notes, lab setup guide, demonstration guides, beta
feedback form and trainer preparation guide for the MOC Course. To clarify, Trainer Content does not
include virtual hard disks or virtual machines.

2. INSTALLATION AND 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 four separate sets of installation and use rights. Only one set of rights apply to you.

a. If you are a Authorized Learning Center:


i. If the Licensed Content is in digital format for each license you acquire you may either:
1. install one (1) copy of the Licensed Content in the form provided to you on a dedicated, secure
server located on your premises where the Authorized Training Session is held for access and
use by one (1) End User attending the Authorized Training Session, or by one (1) MCT teaching
the Authorized Training Session, or
2. install one (1) copy of the Licensed Content in the form provided to you on one (1) Classroom
Device for access and use by one (1) End User attending the Authorized Training Session, or by
one (1) MCT teaching the Authorized Training Session.
ii. You agree that:
1. you will acquire a license for each End User and MCT that accesses the Licensed Content,
2. each End User and MCT will be presented with a copy of this agreement and each individual
will agree that their use of the Licensed Content will be subject to these license terms prior to
their accessing the Licensed Content. Each individual will be required to denote their
acceptance of the EULA in a manner that is enforceable under local law prior to their accessing
the Licensed Content,
3. for all Authorized Training Sessions, you will only use qualified MCTs who hold the applicable
competency to teach the particular MOC Course that is the subject of the training session,
4. you will not alter or remove any copyright or other protective notices contained in the
Licensed Content,
5. you will remove and irretrievably delete all Licensed Content from all Classroom Devices and
servers at the end of the Authorized Training Session,
6. you will only provide access to the Licensed Content to End Users and MCTs,
7. you will only provide access to the Trainer Content to MCTs, and
8. any Licensed Content installed for use during a training session will be done in accordance
with the applicable classroom set-up guide.

b. If you are a MPN Member.


i. If the Licensed Content is in digital format for each license you acquire you may either:
1. install one (1) copy of the Licensed Content in the form provided to you on (A) one (1)
Classroom Device, or (B) one (1) dedicated, secure server located at your premises where
the training session is held for use by one (1) of your employees attending a training session
provided by you, or by one (1) MCT that is teaching the training session, or
2. install one (1) copy of the Licensed Content in the form provided to you on one (1)
Classroom Device for use by one (1) End User attending a Private Training Session, or one (1)
MCT that is teaching the Private Training Session.
ii. You agree that:
1. you will acquire a license for each End User and MCT that accesses the Licensed Content,
2. each End User and MCT will be presented with a copy of this agreement and each individual
will agree that their use of the Licensed Content will be subject to these license terms prior
to their accessing the Licensed Content. Each individual will be required to denote their
acceptance of the EULA in a manner that is enforceable under local law prior to their
accessing the Licensed Content,
3. for all training sessions, you will only use qualified MCTs who hold the applicable
competency to teach the particular MOC Course that is the subject of the training session,
4. you will not alter or remove any copyright or other protective notices contained in the
Licensed Content,
5. you will remove and irretrievably delete all Licensed Content from all Classroom Devices and
servers at the end of each training session,
6. you will only provide access to the Licensed Content to End Users and MCTs,
7. you will only provide access to the Trainer Content to MCTs, and
8. any Licensed Content installed for use during a training session will be done in accordance
with the applicable classroom set-up guide.

c. If you are an End User:


You may use the Licensed Content solely for your personal training use. If the Licensed Content is in
digital format, for each license you acquire you may (i) install one (1) copy of the Licensed Content in
the form provided to you on one (1) Personal Device and install another copy on another Personal
Device as a backup copy, which may be used only to reinstall the Licensed Content; or (ii) print one (1)
copy of the Licensed Content. You may not install or use a copy of the Licensed Content on a device
you do not own or control.
d. If you are a MCT.
i. For each license you acquire, you may use the Licensed Content solely to prepare and deliver an
Authorized Training Session or Private Training Session. For each license you acquire, you may
install and use one (1) copy of the Licensed Content in the form provided to you on one (1) Personal
Device and install one (1) additional copy on another Personal Device as a backup copy, which may
be used only to reinstall the Licensed Content. You may not install or use a copy of the Licensed
Content on a device you do not own or control.

ii. Use of Instructional Components in Trainer Content. You may customize, in accordance with the
most recent version of the MCT Agreement, those portions of the Trainer Content that are logically
associated with instruction of a training session. If you elect to exercise the foregoing rights, you
agree: (a) that any of these customizations will only be used for providing a training session, (b) any
customizations will comply with the terms and conditions for Modified Training Sessions and
Supplemental Materials in the most recent version of the MCT agreement and with this agreement.
For clarity, any use of “customize” refers only to changing the order of slides and content, and/or
not using all the slides or content, it does not mean changing or modifying any slide or content.

2.2 Separation of Components. The Licensed Content components are licensed as a single unit and you
may not separate the components and install them on different devices.

2.3 Reproduction/Redistribution Licensed Content. Except as expressly provided in the applicable


installation and use rights above, you may not reproduce or distribute the 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 Programs. The Licensed Content may contain third party programs or services. These
license terms will apply to your use of those third party programs or services, unless other terms accompany
those programs and services.

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 that respective component and supplements the terms described in this Agreement.

3. PRE-RELEASE VERSIONS. If the Licensed Content is a pre-release (“beta”) version, in addition to the other
provisions in this agreement, then these terms also apply:

a. Pre-Release Licensed Content. This Licensed Content is a pre-release version. It may not contain the
same information and/or work the way a final version of the Licensed Content will. We may change it
for the final version. We also may not release a final version. Microsoft is under no obligation to
provide you with any further content, including the final release version of the Licensed Content.

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 software, 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 software,
technologies, or products to third parties because we include your feedback in them. These rights
survive this agreement.

c. Term. If you are an Authorized Training Center, MCT or MPN, you agree to cease using all copies of the
beta version of the Licensed Content upon (i) the date which Microsoft informs you is the end date for
using the beta version, or (ii) sixty (60) days after the commercial release of the Licensed Content,
whichever is earliest (“beta term”). Upon expiration or termination of the beta term, you will
irretrievably delete and destroy all copies of same in the possession or under your control.

4. INTERNET-BASED SERVICES. Classroom Devices located at Authorized Learning Center’s physical location
may contain virtual machines and virtual hard disks for use while attending an Authorized Training
Session. You may only use the software on the virtual machines and virtual hard disks on a Classroom
Device solely to perform the virtual lab activities included in the MOC Course while attending the
Authorized Training Session. Microsoft may provide Internet-based services with the software included
with the virtual machines and virtual hard disks. It may change or cancel them at any time. If the
software is pre-release versions of software, some of its Internet-based services may be turned on by
default. The default setting in these versions of the software do not necessarily reflect how the features
will be configured in the commercially released versions. If Internet-based services are included with the
software, they are typically simulated for demonstration purposes in the software and no transmission
over the Internet takes place. However, should the software be configured to transmit over the Internet,
the following terms apply:
a. Consent for Internet-Based Services. The software features described below connect to Microsoft or
service provider computer systems over the Internet. In some cases, you will not receive a separate
notice when they connect. You may switch off these features or not use them. By using these features,
you consent to the transmission of this information. Microsoft does not use the information to identify
or contact you.
b. Computer Information. The following features use Internet protocols, which send to the appropriate
systems computer information, such as your Internet protocol address, the type of operating system,
browser and name and version of the software you are using, and the language code of the device
where you installed the software. Microsoft uses this information to make the Internet-based services
available to you.
• Accelerators. When you use click on or move your mouse over an Accelerator, the title and full web
address or URL of the current webpage, as well as standard computer information, and any content
you have selected, might be sent to the service provider. If you use an Accelerator provided by
Microsoft, the information sent is subject to the Microsoft Online Privacy Statement, which is
available at go.microsoft.com/fwlink/?linkid=31493. If you use an Accelerator provided by a third
party, use of the information sent will be subject to the third party’s privacy practices.
• Automatic Updates. This software contains an Automatic Update feature that is on by default. For
more information about this feature, including instructions for turning it off, see
go.microsoft.com/fwlink/?LinkId=178857. You may turn off this feature while the software is
running (“opt out”). Unless you expressly opt out of this feature, this feature will (a) connect to
Microsoft or service provider computer systems over the Internet, (b) use Internet protocols to send
to the appropriate systems standard computer information, such as your computer’s Internet
protocol address, the type of operating system, browser and name and version of the software you
are using, and the language code of the device where you installed the software, and (c)
automatically download and install, or prompt you to download and/or install, current Updates to
the software. In some cases, you will not receive a separate notice before this feature takes effect.
By installing the software, you consent to the transmission of standard computer information and
the automatic downloading and installation of updates.
• Auto Root Update. The Auto Root Update feature updates the list of trusted certificate authorities.
you can switch off the Auto Root Update feature.
• Customer Experience Improvement Program (CEIP), Error and Usage Reporting; Error Reports. This
software uses CEIP and Error and Usage Reporting components enabled by default that
automatically send to Microsoft information about your hardware and how you use this software.
This software also automatically sends error reports to Microsoft that describe which software
components had errors and may also include memory dumps. You may choose not to use these
software components. For more information please go to
<http://go.microsoft.com/fwlink/?LinkID=196910>.
• Digital Certificates. The software uses digital certificates. These digital certificates confirm the
identity of Internet users sending X.509 standard encrypted information. They also can be used to
digitally sign files and macros, to verify the integrity and origin of the file contents. The software
retrieves certificates and updates certificate revocation lists. These security features operate only
when you use the Internet.
• Extension Manager. The Extension Manager can retrieve other software through the internet from
the Visual Studio Gallery website. To provide this other software, the Extension Manager sends to
Microsoft the name and version of the software you are using and language code of the device
where you installed the software. This other software is provided by third parties to Visual Studio
Gallery. It is licensed to users under terms provided by the third parties, not from Microsoft. Read
the Visual Studio Gallery terms of use for more information.
• IPv6 Network Address Translation (NAT) Traversal service (Teredo). This feature helps existing
home Internet gateway devices transition to IPv6. IPv6 is a next generation Internet protocol. It
helps enable end-to-end connectivity often needed by peer-to-peer applications. To do so, each
time you start up the software the Teredo client service will attempt to locate a public Teredo
Internet service. It does so by sending a query over the Internet. This query only transfers standard
Domain Name Service information to determine if your computer is connected to the Internet and
can locate a public Teredo service. If you
· use an application that needs IPv6 connectivity or
· configure your firewall to always enable IPv6 connectivity

by default standard Internet Protocol information will be sent to the Teredo service at Microsoft at
regular intervals. No other information is sent to Microsoft. You can change this default to use non-
Microsoft servers. You can also switch off this feature using a command line utility named “netsh”.
• Malicious Software Removal. During setup, if you select “Get important updates for installation”,
the software may check and remove certain malware from your device. “Malware” is malicious
software. If the software runs, it will remove the Malware listed and updated at
www.support.microsoft.com/?kbid=890830. During a Malware check, a report will be sent to
Microsoft with specific information about Malware detected, errors, and other information about
your device. This information is used to improve the software and other Microsoft products and
services. No information included in these reports will be used to identify or contact you. You may
disable the software’s reporting functionality by following the instructions found at
www.support.microsoft.com/?kbid=890830. For more information, read the Windows Malicious
Software Removal Tool privacy statement at go.microsoft.com/fwlink/?LinkId=113995.
• Microsoft Digital Rights Management. If you use the software to access content that has been
protected with Microsoft Digital Rights Management (DRM), then, in order to let you play the
content, the software may automatically request media usage rights from a rights server on the
Internet and download and install available DRM updates. For more information, see
go.microsoft.com/fwlink/?LinkId=178857.
• Microsoft Telemetry Reporting Participation. If you choose to participate in Microsoft Telemetry
Reporting through a “basic” or “advanced” membership, information regarding filtered URLs,
malware and other attacks on your network is sent to Microsoft. This information helps Microsoft
improve the ability of Forefront Threat Management Gateway to identify attack patterns and
mitigate threats. In some cases, personal information may be inadvertently sent, but Microsoft will
not use the information to identify or contact you. You can switch off Telemetry Reporting. For
more information on this feature, see http://go.microsoft.com/fwlink/?LinkId=130980.
• Microsoft Update Feature. To help keep the software up-to-date, from time to time, the software
connects to Microsoft or service provider computer systems over the Internet. In some cases, you
will not receive a separate notice when they connect. When the software does so, we check your
version of the software and recommend or download updates to your devices. You may not receive
notice when we download the update. You may switch off this feature.
• Network Awareness. This feature determines whether a system is connected to a network by either
passive monitoring of network traffic or active DNS or HTTP queries. The query only transfers
standard TCP/IP or DNS information for routing purposes. You can switch off the active query
feature through a registry setting.
• Plug and Play and Plug and Play Extensions. You may connect new hardware to your device, either
directly or over a network. Your device may not have the drivers needed to communicate with that
hardware. If so, the update feature of the software can obtain the correct driver from Microsoft and
install it on your device. An administrator can disable this update feature.
• Real Simple Syndication (“RSS”) Feed. This software start page contains updated content that is
supplied by means of an RSS feed online from Microsoft.
• Search Suggestions Service. When you type a search query in Internet Explorer by using the Instant
Search box or by typing a question mark (?) before your search term in the Address bar, you will see
search suggestions as you type (if supported by your search provider). Everything you type in the
Instant Search box or in the Address bar when preceded by a question mark (?) is sent to your
search provider as you type it. In addition, when you press Enter or click the Search button, all the
text that is in the search box or Address bar is sent to the search provider. If you use a Microsoft
search provider, the information you send is subject to the Microsoft Online Privacy Statement,
which is available at go.microsoft.com/fwlink/?linkid=31493. If you use a third-party search
provider, use of the information sent will be subject to the third party’s privacy practices. You can
turn search suggestions off at any time in Internet Explorer by using Manage Add-ons under the
Tools button. For more information about the search suggestions service, see
go.microsoft.com/fwlink/?linkid=128106.
• SQL Server Reporting Services Map Report Item. The software may include features that retrieve
content such as maps, images and other data through the Bing Maps (or successor branded)
application programming interface (the “Bing Maps APIs”). The purpose of these features is to
create reports displaying data on top of maps, aerial and hybrid imagery. If these features are
included, you may use them to create and view dynamic or static documents. This may be done only
in conjunction with and through methods and means of access integrated in the software. You may
not otherwise copy, store, archive, or create a database of the content available through the Bing
Maps APIs. you may not use the following for any purpose even if they are available through the
Bing Maps APIs:
• Bing Maps APIs to provide sensor based guidance/routing, or
• Any Road Traffic Data or Bird’s Eye Imagery (or associated metadata).
Your use of the Bing Maps APIs and associated content is also subject to the additional terms and
conditions at http://www.microsoft.com/maps/product/terms.html.
• URL Filtering. The URL Filtering feature identifies certain types of web sites based upon predefined
URL categories, and allows you to deny access to such web sites, such as known malicious sites and
sites displaying inappropriate or pornographic materials. To apply URL filtering, Microsoft queries
the online Microsoft Reputation Service for URL categorization. You can switch off URL filtering. For
more information on this feature, see http://go.microsoft.com/fwlink/?LinkId=130980
• Web Content Features. Features in the software can retrieve related content from Microsoft and
provide it to you. To provide the content, these features send to Microsoft the type of operating
system, name and version of the software you are using, type of browser and language code of the
device where you run the software. Examples of these features are clip art, templates, online
training, online assistance and Appshelp. You may choose not to use these web content features.
• Windows Media Digital Rights Management. Content owners use Windows Media digital rights
management technology (WMDRM) to protect their intellectual property, including copyrights. This
software and third party software use WMDRM to play and copy WMDRM-protected content. If the
software fails to protect the content, content owners may ask Microsoft to revoke the software’s
ability to use WMDRM to play or copy protected content. Revocation does not affect other content.
When you download licenses for protected content, you agree that Microsoft may include a
revocation list with the licenses. Content owners may require you to upgrade WMDRM to access
their content. Microsoft software that includes WMDRM will ask for your consent prior to the
upgrade. If you decline an upgrade, you will not be able to access content that requires the upgrade.
You may switch off WMDRM features that access the Internet. When these features are off, you can
still play content for which you have a valid license.
• Windows Media Player. When you use Windows Media Player, it checks with Microsoft for
· compatible online music services in your region;
· new versions of the player; and
· codecs if your device does not have the correct ones for playing content.

You can switch off this last feature. For more information, go to
www.microsoft.com/windows/windowsmedia/player/11/privacy.aspx.
• Windows Rights Management Services. The software contains a feature that allows you to create
content that cannot be printed, copied or sent to others without your permission. For more
information, go to www.microsoft.com/rms. you may choose not to use this feature
• Windows Time Service. This service synchronizes with time.windows.com once a week to provide
your computer with the correct time. You can turn this feature off or choose your preferred time
source within the Date and Time Control Panel applet. The connection uses standard NTP protocol.
• Windows Update Feature. You may connect new hardware to the device where you run the
software. Your device may not have the drivers needed to communicate with that hardware. If so,
the update feature of the software can obtain the correct driver from Microsoft and run it on your
device. You can switch off this update feature.
c. Use of Information. Microsoft may use the device information, error reports, and malware reports to
improve our software and services. We may also share it with others, such as hardware and software
vendors. They may use the information to improve how their products run with Microsoft software.
d. Misuse of Internet-based Services. You may not use any Internet-based service in any way that could
harm it or impair anyone else’s use of it. You may not use the service to try to gain unauthorized access
to any service, data, account or network by any means.

5. 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:
• install more copies of the Licensed Content on devices than the number of licenses you acquired;
• allow more individuals to access the Licensed Content than the number of licenses you acquired;
• publicly display, or make the Licensed Content available for others to access or use;
• install, sell, publish, transmit, encumber, pledge, lend, copy, adapt, link to, post, rent, lease or lend,
make available or distribute the Licensed Content to any third party, except as expressly permitted
by this Agreement.
• 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;
• access or use any Licensed Content for which you are not providing a training session to End Users
using the Licensed Content;
• access or use any Licensed Content that you have not been authorized by Microsoft to access and
use; or
• transfer the Licensed Content, in whole or in part, or assign this agreement to any third party.

6. 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. You may not remove or obscure any copyright, trademark or patent notices that
appear on the Licensed Content or any components thereof, as delivered to you.

7. 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.
8. LIMITATIONS ON SALE, RENTAL, ETC. AND CERTAIN ASSIGNMENTS. You may not sell, rent, lease, lend or
sublicense the Licensed Content or any portion thereof, or transfer or assign this agreement.

9. SUPPORT SERVICES. Because the Licensed Content is “as is”, we may not provide support services for it.

10. 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 any termination of this agreement, you
agree to immediately stop all use of and to irretrievable delete and destroy all copies of the Licensed
Content in your possession or under your control.

11. 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.

12. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates and support services are
the entire agreement for the Licensed Content.

13. APPLICABLE LAW.


a. United States. If you acquired the Licensed Content in the United States, Washington state law governs
the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws
principles. The laws of the state where you live govern all other claims, including claims under state
consumer protection laws, unfair competition laws, and in tort.

b. Outside the United States. If you acquired the Licensed Content in any other country, the laws of that
country apply.

14. 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.

15. DISCLAIMER OF WARRANTY. THE LICENSED CONTENT IS LICENSED "AS-IS," "WITH ALL FAULTS," AND "AS
AVAILABLE." YOU BEAR THE RISK OF USING IT. MICROSOFT CORPORATION AND ITS RESPECTIVE
AFFILIATES GIVE NO EXPRESS WARRANTIES, GUARANTEES, OR CONDITIONS UNDER OR IN RELATION TO
THE LICENSED CONTENT. YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS UNDER YOUR LOCAL LAWS
WHICH THIS AGREEMENT CANNOT CHANGE. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS,
MICROSOFT CORPORATION AND ITS RESPECTIVE AFFILIATES EXCLUDE ANY IMPLIED WARRANTIES OR
CONDITIONS, INCLUDING THOSE OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON-INFRINGEMENT.

16. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. TO THE EXTENT NOT PROHIBITED BY
LAW, YOU CAN RECOVER FROM MICROSOFT CORPORATION AND ITS SUPPLIERS ONLY DIRECT
DAMAGES UP TO USD$5.00. YOU AGREE NOT TO SEEK TO RECOVER ANY OTHER DAMAGES, INCLUDING
CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES FROM MICROSOFT
CORPORATION AND ITS RESPECTIVE SUPPLIERS.
This limitation applies to
o anything related to the Licensed Content, services made available through the Licensed Content, or
content (including code) on third party Internet sites or third-party programs; and
o claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence,
or other tort to the extent permitted by applicable law.

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.

LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES DOMMAGES. Vous


pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement
à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres dommages, y
compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices.
Cette limitation concerne:
• tout ce qui est relié au le contenu sous licence , aux services ou au contenu (y compris le code)
figurant sur des sites Internet tiers ou dans des programmes tiers ; et
• les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité
stricte, de négligence ou d’une autre faute dans la limite autorisée par la loi en vigueur.

Elle s’applique également, même si Microsoft connaissait ou devrait connaître l’éventualité d’un tel dommage.
Si votre pays n’autorise pas l’exclusion ou la limitation de responsabilité pour les dommages indirects,
accessoires ou de quelque nature que ce soit, il se peut que la limitation ou l’exclusion ci-dessus ne s’appliquera
pas à votre égard.

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.

Revised March 2012


xiv Implementing Data Models and Reports with Microsoft® SQL Server® 2012
Implementing Data Models and Reports with Microsoft® SQL Server® 2012 xv

Acknowledgments
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.

Graeme Malcolm – Lead Content Developer


Graeme Malcolm is a Microsoft SQL Server subject matter expert and professional content developer at
Content Master—a division of CM Group Ltd. As a Microsoft Certified Trainer, Graeme has delivered
training courses on SQL Server since version 4.2; as an author, Graeme has written numerous books,
articles, and training courses on SQL Server; and as a consultant, Graeme has designed and implemented
business solutions based on SQL Server for customers all over the world.

Geoff Allix – Content Developer


Geoff Allix is a Microsoft SQL Server subject matter expert and professional content developer at Content
Master—a division of CM Group Ltd. Geoff is a Microsoft Certified IT Professional for SQL Server with
extensive experience in designing and implementing database and BI solutions on SQL Server
technologies, and has provided consultancy services to organizations seeking to implement and optimize
data warehousing and OLAP solutions.

Martin Ellis – Content Developer


Martin Ellis is a Microsoft SQL Server subject matter expert and professional content developer at Content
Master—a division of CM Group Ltd. Martin is a Microsoft Certified Technical Specialist on SQL Server and
an MCSE. He has been working with SQL Server since version 7.0, as a DBA, consultant and Microsoft
Certified Trainer, and has developed a wide range of technical collateral for Microsoft Corp. and other
technology enterprises.

Chris Testa-O’Neill – Technical Reviewer


Chris Testa-O’Neill is a Senior Consultant at Coeo (www.coeo.com), a leading provider of SQL Server
Managed Support and Consulting in the UK and Europe. He is also a Microsoft Certified Trainer, Microsoft
Most Valuable Professional for SQL Server, and lead author of Microsoft E-Learning MCTS courses for SQL
Server 2008. Chris has spoken at a range of SQL Server events in the UK, Europe, Australia and the United
States. He is also one of the organizers of SQLBits, SQLServerFAQ and a UK Regional Mentor for SQLPASS.
You can contact Chris at chris@coeo.com , @ctesta_oneill or through his blog at
http://www.coeo.com/sql-server-events/sql-events-and-blogs.aspx
xvi Implementing Data Models and Reports with Microsoft® SQL Server® 2012

Contents
Module 1: Introduction to Business Intelligence and Data Modeling
Lesson 1: Introduction to Business Intelligence 1-3
Lesson 2: The Microsoft Business Intelligence Platform 1-11
Lab 1: Reporting and Analyzing Data 1-23

Module 2: Implementing Reports with SQL Server Reporting Services


Lesson 1: Introduction to Reporting Services 2-3
Lesson 2: Creating a Report with Report Designer 2-12
Lesson 3: Grouping and Aggregating Data in a Report 2-24
Lab 2A: Creating a Report with Report Designer 2-35
Lesson 4: Showing Data Graphically 2-42
Lesson 5: Filtering Reports By Using Parameters 2-56
Lesson 6: Publishing and Viewing a Report 2-64
Lab 2B: Enhancing and Publishing a Report 2-71

Module 3: Supporting Self Service Reporting


Lesson 1: Introduction to Self Service Reporting 3-3
Lesson 2: Shared Data Sources and Datasets 3-11
Lesson 3: Report Parts 3-22
Lab 3: Implementing Self Service Reporting 3-32

Module 4: Managing Report Execution and Delivery


Lesson 1: Managing Report Security 4-3
Lesson 2: Managing Report Execution 4-10
Lesson 3: Subscriptions and Data Alerts 4-17
Lesson 4: Troubleshooting Reporting Services 4-31
Lab 4: Configuring Report Execution and Delivery 4-37

Module 5: Creating Multidimensional Databases


Lesson 1: Introduction to Multidimensional Analysis 5-4
Lesson 2: Creating Data Sources and Data Source Views 5-15
Lesson 3: Creating a Cube 5-21
Lesson 4: Overview of Cube Security 5-28
Lab 5: Creating a Multidimensional Database 5-39

Module 6: Working with Cubes and Dimensions


Lesson 1: Configuring Dimensions 6-3
Lesson 2: Defining Attribute Hierarchies 6-12
Lesson 3: Sorting and Grouping Attributes 6-21
Lab 6: Defining Dimensions 6-25
Implementing Data Models and Reports with Microsoft® SQL Server® 2012 xvii

Module 7: Working with Measures and Measure Groups


Lesson 1: Working with Measures 7-3
Lesson 2: Working with Measure Groups 7-10
Lab 7: Configuring Measures and Measure Groups 7-24

Module 8: Introduction to MDX


Lesson 1: MDX Fundamentals 8-3
Lesson 2: Adding Calculations to a Cube 8-12
Lesson 3: Using MDX to Query a Cube 8-24
Lab 8: Using MDX 8-29

Module 9: Customizing Cube Functionality


Lesson 1: Working with Key Performance Indicators 9-3
Lesson 2: Working with Actions 9-11
Lesson 3: Working with Perspectives 9-16
Lesson 4: Working with Translations 9-19
Lab 9: Customizing a Cube 9-24

Module 10: Implementing a Tabular Data Model with Microsoft PowerPivot


Lesson 1: Introduction to Tabular Data Models and PowerPivot
Technologies 10-3
Lesson 2: Creating a Tabular Data Model by Using PowerPivot for Excel 10-13
Lesson 3: Sharing a PowerPivot Workbook and Using PowerPivot Gallery 10-26
Lab 10: Using PowerPivot for Excel 10-32

Module 11: Introduction to DAX


Lesson 1: DAX Fundamentals 11-3
Lesson 2: Using DAX to Create Calculated Columns and Measures in a
Tabular Data Model 11-15
Lab 11: Creating Calculated Columns and Measures by Using DAX 11-29

Module 12: Implementing an Analysis Services Tabular Data Model


Lesson 1: Introduction to Analysis Services Tabular Data Model Projects 12-3
Lesson 2: Developing an Analysis Services Tabular Data Model in
SQL Server Data Tools 12-13
Lab 12: Working with an Analysis Services Tabular Data Model 12-27

Module 13: Creating Data Visualizations with Power View


Lesson 1: Introduction to Power View 13-3
Lesson 2: Visualizing Data with Power View 13-10
Lab 13: Creating Interactive Reports with Power View 13-25
xviii Implementing Data Models and Reports with Microsoft® SQL Server® 2012

Module 14: Performing Predictive Analysis with Data Mining


Lesson 1: Overview of Data Mining 14-3
Lesson 2: Creating a Data Mining Solution 14-13
Lesson 3 Validating a Data Mining Model 14-19
Lesson 4: Consuming Data Mining Data 14-26
Lab 14: Using Data Mining to Support a Marketing Campaign 14-34

Appendix: Lab Answer Keys


Module 1 Lab: Reporting and Analyzing Data L1-1
Module 2 Lab A: Creating a Report with Report Designer L2-5
Module 2 Lab B: Enhancing and Publishing a Report L2-11
Module 3 Lab: Implementing Self Service Reporting L3-21
Module 4 Lab: Configuring Report Execution and Delivery L4-29
Module 5 Lab: Creating a Multidimensional Database L5-35
Module 6 Lab: Defining Dimensions L6-43
Module 7 Lab: Configuring Measures and Measure Groups L7-51
Module 8 Lab: Using MDX L8-57
Module 9 Lab: Customizing a Cube L9-61
Module 10 Lab: Using PowerPivot for Excel L10-65
Module 11 Lab: Creating Calculated Columns and Measures by
Using DAX L11-75
Module 12 Lab: Working with an Analysis Services Tabular Data Model L12-81
Module 13 Lab: Creating Interactive Reports with Power View L13-91
Module 14 Lab: Using Data Mining to Support a Marketing Campaign L14-97
About This Course xix

About This Course


This section provides you with a brief description of the course, audience, suggested prerequisites, and
course objectives.

Course Description
This course describes how to empower information workers through self-service analytics and reporting.
Students will learn how to implement multidimensional analysis solutions, create PowerPivot and tabular
data models, deliver rich data visualizations with Power View and Microsoft® SQL Server® Reporting
Services, and discover business insights by using data mining.

Audience
This course is intended for database professionals who need to fulfill a Business (BI) Intelligence Developer
role to create analysis and reporting solutions. Primary responsibilities include:
• Implementing reporting solutions by using SQL Server Reporting Services.

• Implementing multidimensional databases by using SQL Server Analysis Services.

• Creating tabular semantic data models for analysis by using SQL Server Analysis Services.
• Create visualizations of data by using Power View.

• Create data mining solutions by using SQL Server Analysis Services.

Student Prerequisites
This course requires that you meet the following prerequisites:
• At least 2 years’ experience of working with relational databases, including:

• Designing a normalized database.

• Creating tables and relationships.


• Querying with Transact-SQL.

• Some basic knowledge of data warehouse schema topology (including star and snowflake schemas).

• Some exposure to basic programming constructs (such as looping and branching).

• 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.

• Create reports with Reporting Services.


• Create reusable report items that simplify self-service reporting.

• Manage report execution and delivery.

• Create a multidimensional database with Analysis Services.


xx About This Course

• Implement dimensions in a cube.

• Implement measures and measure groups in a cube.

• Use MDX Syntax.

• Customize a cube.

• Implement a Tabular Data Model in PowerPivot.

• Use DAX to query a tabular model.

• Implement a Tabular Database.

• Use Power View to create interactive data visualizations.

• Use Data Mining for Predictive Analysis.

Course Outline
This section provides an outline of the course:
Module 1, “Introduction to Business Intelligence and Data Modeling”

Module 2, “Implementing Reports with SQL Server Reporting Services”

Module 3, “Supporting Self Service Reporting”


Module 4, “Managing Report Execution and Delivery”

Module 5, “Creating Multidimensional Databases”

Module 6, “Working with Cubes and Dimensions”


Module 7, “Working with Measures and Measure Groups”
Module 8, “Introduction to MDX”

Module 9, “Customizing Cube Functionality”

Module 10, “Implementing a Tabular Data Model with Microsoft PowerPivot”


Module 11, “Introduction to DAX”

Module 12, “Implementing an Analysis Services Tabular Data Model”

Module 13, “Creating Data Visualizations with Power View”


Module 14, “Performing Predictive Analysis with Data Mining”
About This Course xxi

Course Materials
The following materials are included with your kit:

• Course Handbook A succinct classroom learning guide that provides all the critical technical
information in a crisp, tightly-focused format, which is just right for an effective in-class learning
experience.
• Lessons: Guide you through the learning objectives and provide the key points that are critical to
the success of the in-class learning experience.

• Labs: Provide a real-world, hands-on platform for you to apply the knowledge and skills learned
in the module.

• Module Reviews and Takeaways: Provide improved on-the-job reference material to boost
knowledge and skills retention.
• Lab Answer Keys: Provide step-by-step lab solution guidance at your finger tips when it’s
needed.

Course Companion Content on the http://www.microsoft.com/learning/companionmoc/ Site:


Searchable, easy-to-navigate digital content with integrated premium on-line resources designed to
supplement the Course Handbook.

• 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.

• Resources: Include well-categorized additional resources that give you immediate access to the most
up-to-date premium content on TechNet, MSDN®, Microsoft Press®.
Student Course files on the http://www.microsoft.com/learning/companionmoc/ Site: Includes the
Allfiles.exe, a self-extracting executable file that contains all the files required for the labs and
demonstrations.

• 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.

• To provide additional comments or feedback on the course, send email to


support@mscourseware.com. To inquire about the Microsoft Certification Program, send email to
mcphelp@microsoft.com.
xxii About This Course

Virtual Machine Environment


This section provides the information for setting up the classroom environment to support the business
scenario of the course.

Virtual Machine Configuration


In this course, you will use Microsoft Hyper-V to perform the labs.

The following table shows the role of each virtual machine used in this course:

Virtual Machine
Role
10777-8A-MIA-SQLBI Application Server

10777-8-MIA-DC1 Domain Controller

MT11-MSL-TMG1 Internet Gateway

Software Configuration
The following software is installed on each VM:

• Microsoft Windows Server 2008 R2 SP1

• Microsoft SQL Server 2012 (on 10777-8A-MIA-SQLBI only)


• Microsoft SharePoint Server 2010 (on 10777-8A-MIA-SQLBI only)
• Microsoft Office 2010 (on 10777-8A-MIA-SQLBI only)

Course Files
There are files associated with the labs in this course. The lab files are located in the folder
D:\10778A\Labfiles\LabXX on the 10777-8A-MIA-SQLBI VM.

Classroom Setup
Each classroom computer will have the same virtual machine configured in the same way.
Course Hardware Level 6+

To ensure a satisfactory student experience, Microsoft Learning requires a minimum equipment


configuration for trainer and student computers in all Microsoft Certified Partner for Learning Solutions
(CPLS) classrooms in which Official Microsoft Learning Product courseware are taught.
1-1

Module 1
Introduction to Business Intelligence and Data Modeling
Contents:
Lesson 1: Introduction to Business Intelligence 1-3

Lesson 2: The Microsoft Business Intelligence Platform 1-11


Lab 1: Reporting and Analyzing Data 1-23
1-2 Introduction to Business Intelligence and Data Modeling

Module Overview

Business intelligence (BI) is becoming increasingly important for companies of many different sizes and
types because of the competitive edge it can help to give them. The combined capabilities of Microsoft®
SQL Server® 2012 and Microsoft SharePoint® 2010 make it easier than ever for companies to develop a
BI solution that meets their specific needs, provides reduced total cost of ownership (TCO), and achieves a
faster time to solution.
This module provides an introduction to BI. It describes common BI scenarios, current trends in BI, and the
typical roles that are involved in creating a BI solution. It also introduces the Microsoft BI platform and
describes the roles that SQL Server 2012 and SharePoint 2010 play in Microsoft BI solutions.
After completing this module, you will be able to:
• Describe common BI scenarios and current BI trends.

• Describe the main technologies that make up the Microsoft BI platform.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-3

Lesson 1
Introduction to Business Intelligence

BI is no longer the preserve of just large organizations, with businesses of various sizes and types starting
to realize the benefits of a well-designed BI solution. This lesson provides an overview of BI scenarios and
trends and an introduction to BI projects and data modeling.
After completing this lesson, you will be able to:

• Describe how organizations use BI.

• Describe recent trends in BI.


• Explain the roles that are involved in a typical BI project.

• Explain the importance of data models.


1-4 Introduction to Business Intelligence and Data Modeling

Business Intelligence Scenarios

BI is the practice of using specialist technologies to analyze data in a variety of ways to support business
processes. BI solutions can range from large, enterprise-wide applications that support thousands of users
to relatively simple desktop applications that might be used by a single individual, or shared at an office
or departmental level. Whatever the size and scope of a BI system, however, its primary purpose is to
provide support for users when they make decisions. A typical BI solution uses some kind of data
warehouse or data mart as its primary data source, although this is not always the case. Using a data
warehouse as the data source for a BI solution is preferable for several reasons, including the following:

• Organizations usually store data in different locations and formats; a single, centralized data
warehouse provides much simpler data access for a BI application than multiple, disparate sources.

• Data stores often contain data that is incomplete, inaccurate, duplicated, or inconsistent; the process
of populating a data warehouse usually involves integrating, cleaning, and standardizing data to
improve data quality, making it a more reliable data source for BI applications.

• Users of BI applications often need to analyze data from many different perspectives, so fast query
response times are very important; data warehouses typically use specially designed and optimized
hardware and software that can meet the demanding performance requirements of BI applications.

For More Information For more information about building and populating data
warehouses, you should attend Course 10777A, Implementing a Data Warehouse with
Microsoft® SQL Server® 2012.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-5

BI solutions support business activities across a wide range of areas, enabling information workers to
better understand business trends and performance, accurately measure performance against defined
goals, make more effective decisions, and predict future trends. BI solutions deliver support for business
activities through technologies that enable key scenarios, including:

• Reporting. A report provides summary information that enables managers to make decisions about a
specific area of a business. Reports typically display information graphically, through charts and
tables, which makes it possible for users to interpret the information quickly and with minimal effort.
For example, managers who are responsible for a particular product range within an organization
might use a monthly report to evaluate the success of their products in terms of sales over the
previous month, comparing this with the figures for the previous month or with the equivalent month
for a previous year. The managers can use the report to support decisions about various things, such
as marketing strategies, product development strategies, or future budget requirements. Reporting
solutions need to provide the tools to create reports, a method of access to reports, and a
management environment that ensures the consistency, accuracy, and availability of reports.

• Data analysis. For information workers to use the data in a data warehouse effectively, you need to
make that data available to them in a format that is meaningful. Data analysis tools combine the data
and metadata from data warehouses or other data stores to create structures that make this data
available to users as useable information. For example, your data warehouse might include a table
that contains millions of rows of sales data, a second table that contains product information, and
others that contain information about dates and geographical location. You could create a data
analysis solution that loads this data into a special structure, such as an online analytical processing
(OLAP) cube, calculates and stores aggregations of key data to improve query response times, and
makes all of this available to a range of client tools. You can perform historical analysis of data to
identify past trends and assess past performance. You can also build data mining models that enable
you to perform predictive analyses. Data mining involves using sophisticated algorithms to process
historical data and predict the likelihood of particular predefined outcomes. For example, you might
build a data mining model that identifies which of your previous customers is most likely to make a
subsequent purchase based on factors such as income or occupation. You could then create a
marketing campaign that focuses on these individuals.

• Collaboration. Effective decision making relies on making accurate information available at the right
time to the right people. For example, if members of a committee need a particular report to help
them to decide on a marketing strategy for the following year that report must be available to all
committee members at a set time, regardless of their location, and crucially, each copy of the report
must contain the same information. Collaboration tools provide a platform for managing and
distributing reports, spreadsheets, and the other documents that information workers use.
Collaboration tools also ensure reporting consistency through version control.
1-6 Introduction to Business Intelligence and Data Modeling

Trends in Business Intelligence

Just a few years ago, only larger organizations had the expertise and the financial means to build and
maintain BI solutions. Access to data analysis tools was often limited to a few specialist workers. However,
more recently, BI technologies have become more cost-effective and are easier to implement and
maintain. This has enabled increasing numbers of organizations of all sizes and from all industries to move
into the BI arena. Recent key areas of change in BI include:

• Self-service reporting and analysis. Self-service BI technologies, such as the Microsoft PowerPivot for
Excel add-in and Report Builder, put the creation of reports and data analyses into the hands of the
individuals who use these documents, which increases efficiency and reduces the dependency on
professional developers.

• Increasing adoption of BI by a wider range of organizations. The increasing ease of use, lower TCO,
and faster time to solution have made BI more appealing to a wide range of organizations, leading to
a large rise in the number of companies that use BI technologies.

• Availability of out-of-the-box solutions. Vendors have begun to offer BI solutions as preconfigured


applications for specific purposes, eliminating the need for organizations to research, develop, and
deploy often complex software and hardware themselves.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-7

Business Intelligence Project Roles

A BI project shares similarities with any other IT implementation project, so it is possible to apply most
commonly used methodologies, such as Agile or Microsoft Solutions Framework (MSF), to BI projects.

A successful BI project will involve many roles, including some or all of the following:

• Business advisors. For a BI project to succeed there must be a clear understanding of the needs and
expectations of the business users and of the overall benefits to the business of implementing the
project. Business advisors work with the individuals who are involved in designing, developing, and
implementing the project to ensure that they are fully aware of the key business drivers and desired
goals.
• Project manager. The project manager coordinates project tasks and schedules and ensures that the
project is completed on time and within budget.

• BI architect. The BI architect designs the data model that end users will interact with. Data models
reduce the complexity of the underlying data sources and organize data into meaningful entities such
as facts and dimensions. The BI architect must have a thorough understanding of the business
requirements and how users need to interact with the data, and he or she will liaise frequently with
the business advisors to ensure that the project remains on the right track.

• BI developers. BI developers create the measures, key performance indicators (KPIs), and other entities
that report authors and information workers use in reports.

• Report authors. Report authors use a range of authoring tools to create reports and data analyses for
analysts and information workers to enable them to explore and analyze data.

• Information workers. Information workers consume the reports and data analyses that authors create.
Information workers include business analysts and managers, who use reports to support decision
making and other business processes, and data analysts, who explore data to identify trends.
1-8 Introduction to Business Intelligence and Data Modeling

• Testers. Testers test the models, measures, reports, and other components that the BI architect,
developers, and report authors produce.

• BI administrator. The BI administrator manages the BI applications to ensure high availability, security,
and performance.
In addition to ensuring the appropriate assignment of these roles, you should also consider the
importance of executive-level sponsorship of the BI project. The project is significantly more likely to
succeed if a high-profile executive sponsor actively supports the creation of the BI solution. You should
also consider the need for support from the organization’s IT department, on which you will rely to
manage the infrastructure for the BI solution.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-9

Data Models

To enable end users to interact with data without requiring an understanding of complex source data
storage systems, you can create a semantic data model. A semantic data model is a logical representation
of data that is designed to make that data easy to understand.

Semantic Models
The data that forms the basis of BI reports and data analysis spreadsheets is often stored in relational
databases. Transactional relational databases generally store data in a normalized format, in which
individual tables contain only a precisely limited set of data, such as product data or order data.
Furthermore, column names in a transactional database are often not easy to interpret outside the
context of the database. To enable the users of your BI system to interact with this data in reports,
spreadsheets, or other BI tools, you need to make it meaningful by creating a semantic data model.
Creating a semantic data model changes data into useful information by adding context to the data. For
example, data modelers can create relationships between data, arrange related data into hierarchies that
make the data easier to browse, and rename objects such as tables or columns, so that they are easy for
users to understand.

Data Modeling
The process of creating a semantic data model is called data modeling. Data modelers require an
understanding of both the technical aspects of creating a BI solution and the expectations and needs of
the business users. They also need to maintain an open and ongoing dialog with the business sponsors
and the information workers so that they can successfully translate the business requirements into a useful
model.
1-10 Introduction to Business Intelligence and Data Modeling

Developing a data model is an iterative process, in which users and testers try out initial designs and make
suggestions and requests for change. Based on this feedback, the data modeler produces a second
version of the model, and the process then repeats, often many times, until all parties agree on a final
design. An iterative approach to data modeling may initially seem time-consuming, but it can actually
reduce development time and TCO by helping to ensure that the BI solution delivers what is required the
first time around.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-11

Lesson 2
The Microsoft Business Intelligence Platform

The Microsoft BI platform is a suite of products that together enable you to get the most out of existing
investments to create complete and powerful BI solutions. This lesson describes the technologies that
make up the Microsoft BI platform, the semantic models that you can create by using SQL Server 2012,
and some common installation scenarios for Microsoft BI technologies.
After completing this lesson, you will be able to:

• Describe the Microsoft BI product suite.


• Describe the BI semantic models that you can create by using SQL Server 2012.
• Describe the requirements and benefits of common installation scenarios.

• Describe some considerations for SharePoint integration.


1-12 Introduction to Business Intelligence and Data Modeling

Microsoft Business Intelligence Technologies

The Microsoft BI platform consists of multiple products that together enable companies of all sizes to
create a huge variety of BI solutions. Key Microsoft products for BI solutions include:

• SQL Server 2012

• SharePoint 2010

• Microsoft Office 2010

SQL Server 2012


SQL Server 2012 is at the heart of the Microsoft BI platform, delivering BI functionality through three key
services:
• SQL Server Analysis Services. You use Analysis Services to create the data models for your BI solution.
Analysis Services in SQL Server 2012 enables you to create multidimensional OLAP data models and
tabular data models, providing the flexibility to meet the exact requirements of your organization.
You can install SQL Server 2012 Analysis Services in one of three modes:

• Multidimensional. Multidimensional mode supports databases that are built on multidimensional


data models.

• Tabular. Tabular mode supports databases that are built on tabular data models.

• PowerPivot for SharePoint. PowerPivot for SharePoint integrates Analysis Services with SharePoint
to enable access to PowerPivot workbooks through a browser.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-13

For More Information For more information about multidimensional databases in SQL
Server 2012 Analysis Services, see Module 5 of this course, Creating Multidimensional
Databases. For more information about tabular databases in SQL Server 2012 Analysis
Services, see Module 12 of this course, Implementing an Analysis Services Tabular Data
Model. For more information about PowerPivot technologies, see Module 10 of this course,
Implementing a Tabular Data Model with Microsoft PowerPivot.

• SQL Server Reporting Services. Reporting Services provides a complete environment for creating,
distributing, and managing reports. Information workers can create reports by using Report Builder
3.0, and they can use Power View, a feature of SQL Server 2012 Reporting Services Add-in for
Microsoft SharePoint Server 2010 Enterprise Edition, to create interactive data visualizations.
Professional developers can use SQL Server Data Tools to create and deploy reports, and BI
administrators can use Report Manager to manage the report server, including security, subscriptions,
and data sources. You can install Reporting Services in native mode, which configures a stand-alone
Reporting Services server, or in SharePoint Integrated mode, which places Reporting Services in a
SharePoint farm, enabling users to access reports across the enterprise through a browser. Reporting
Services in SharePoint Integrated mode also enables users to use the new Power View component to
create interactive data visualizations.

For More Information For more information about Reporting Services in SQL Server
2012, see Module 2 of this course, Implementing Reports with SQL Server Reporting
Services. For more information about Power View, see Module 13 of this course, Creating
Data Visualizations with Power View.

• SQL Server Integration Services. Integration Services is an extract, transform, and load (ETL) tool that
enables you to populate the data warehouse or other database that you will use as the data source
for your BI solution.

In addition to Analysis Services, Reporting Services, and Integration Services, SQL Server 2012 also includes
the relational database engine that can host your data warehouse, and SQL Server Data Quality Services
and SQL Server Master Data Services, which enable you to ensure data standardization and data quality.

For More Information For more information about SQL Server Integration Services, Data
Quality Services, and Master Data Services, you should attend Course 10777A,
Implementing a Data Warehouse with Microsoft® SQL Server® 2012.

SharePoint 2010
SharePoint 2010 promotes collaboration through a secure portal. Analysts and information workers can
share and access Reporting Services reports, PowerPivot workbooks, and Power View reports that are
hosted on SharePoint sites by using only a browser. SharePoint 2010 integrates with SQL Server 2012
Reporting Services to provide an enterprise reporting solution, and it integrates with SQL Server 2012
Analysis Services to provide server-based access to centralized PowerPivot workbooks. PerformancePoint
Services in SharePoint 2010 enables you to keep track of key metrics by creating scorecards, KPIs, and
dashboards.
1-14 Introduction to Business Intelligence and Data Modeling

Office 2010
Office 2010 includes Microsoft Excel® 2010, the most widely used BI tool in the world. The PowerPivot for
Excel add-in enables users to perform complex data analysis in an Excel worksheet, and it delivers
excellent performance even with very large data sets. You can also save PowerPivot for Excel workbooks
to the SharePoint gallery to share them with colleagues.

For More Information For more information about PowerPivot for Excel and PowerPivot
for SharePoint, see Module 10 of this course, Implementing a Tabular Data Model with
Microsoft PowerPivot.

The Data Mining Add-ins for Excel extend Excel functionality, enabling analysts to create and validate data
mining models, and to use these models to analyze data. The Data Mining Add-ins for Excel include a
range of analysis tools that you can use to perform different types of analyses. For example, you can
perform shopping basket analysis, which enables you to generate recommendations to online customers
based on the contents of their shopping cart, or you can perform key influencers analysis, which identifies
the factors that most strongly influence a particular outcome, such as which customers in your database
are most likely to respond to a marketing campaign by making further purchases.

For More Information For more information about data mining and the Data Mining
Add-ins for Excel and Data Mining in SQL Server 2012 Analysis Services, see Module 14 of
this course, Performing Predictive Analysis with Data Mining.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-15

BI Semantic Models in SQL Server 2012 Analysis Services

SQL Server 2012 Analysis Services introduces the concept of BI semantic models. A BI semantic model is a
conceptual model that provides a choice of data models within a single framework. BI semantic models
provide the flexibility to create solutions for any business analysis requirement, from small-scale desktop
BI to enterprise-scale applications. Within the BI semantic model framework, you can create two types of
data model:

• Multidimensional data models. Multidimensional data models have been supported in all versions of
SQL Server Analysis Services, up to and including SQL Server 2012 Analysis Services. Multidimensional
data models expose data through dimensions and cubes. They use the powerful Multidimensional
Expressions (MDX) language to implement business logic, and they can provide access to data
through relational online analytical processing (ROLAP) storage or multidimensional online analytical
processing (MOLAP) storage.

• Tabular data models. Tabular data models are new in SQL Server 2012 Analysis Services. Tabular data
models expose data in a relational format. They use the Data Analysis Expressions (DAX) language to
implement business logic, and they can provide access to data by using the xVelocity in-memory
engine or, subject to limitations in the design of the model, the DirectQuery mode, which provides
access to data in the underlying data source.
The BI semantic model provides a single logical model for all end-user experiences by exposing the same
set of application programming interfaces (APIs) to client tools, regardless of the underlying data model
(tabular or multidimensional) that the BI semantic model uses. Individuals can use Excel to connect to
tabular or multidimensional models, and they can use Power View to connect to tabular models. This
single-model approach provides flexibility, enabling businesses to choose from a range of client tools and
data models, and it reduces the risk that organizations will become locked to a single client tool or data
model.
1-16 Introduction to Business Intelligence and Data Modeling

Selecting a Data Model


Tabular models are not intended to replace multidimensional models but rather to complement them.
When you decide which data model to use for a project, you should consider many factors, including:

• The complexity and required scalability of the proposed application.


• How quickly the solution must be available.

• The cost of developing the solution.

• The availability of developer expertise.


• The amount of memory that is available on the server that will host the model.

For More Information For more information about tabular data models in SQL Server
2012 Analysis Services, see Module 12 of this course, Implementing an Analysis Services
Tabular Data Model. For more information about multidimensional data models in SQL
Server 2012 Analysis Services, see Module 5 of this course, Creating Multidimensional
Databases.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-17

Installation Requirements for Common Scenarios

The Microsoft BI platform provides the flexibility to create BI solutions for organizations of any size. The
following table shows the capabilities and requirements of BI solutions in three example scenarios.

Desktop BI Departmental BI Enterprise BI


Capabilities • Create, save, and • Create, save, and manage • Share and view
manage PowerPivot for Excel PowerPivot for Excel
PowerPivot for workbooks locally. workbooks by using the
Excel workbooks • Create and view Reporting SharePoint gallery.
locally. Services reports on a • Share and view Reporting
stand-alone server. Services reports by using
• Connect to stand-alone the SharePoint gallery.
Analysis Services database • Create Power View
by using Excel. reports.
• Connect to Analysis
Services databases by
using BI semantic model
connections.
1-18 Introduction to Business Intelligence and Data Modeling

(continued)

Desktop BI Departmental BI Enterprise BI

Required Excel 2010 Reporting Services installed in SharePoint 2010 with Service Pack 1
software and PowerPivot for native mode. (SP1).
services Excel add-in Instance of Analysis Services Reporting Services installed in
installed in tabular mode or SharePoint Integrated mode.
multidimensional mode. Instance of Analysis Services installed
in SharePoint Integrated mode.
(Requires SharePoint 2010
Enterprise.)
Instance of Analysis Services installed
in tabular mode or multidimensional
mode.

Integrating Reporting Services and Analysis Services with SharePoint 2010 enables you to build a true
enterprise-scale BI application that provides many advantages, such as:
• Collaboration. The SharePoint gallery provides a single point of access to BI resources, enabling users
to upload, browse, and open Reporting Services reports, Power View reports, Analysis Services
database connections, and PowerPivot for Excel workbooks. Integrated source control and versioning
ensure integrity and accuracy.

• Centralized management. Integrated Windows security ensures that you can precisely define
permissions, even down to the level of the data row. Centralization also simplifies the management of
high availability, resource provision, backups, and other administrative tasks.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-19

Considerations for SharePoint Configuration

You can integrate SQL Server 2012 Reporting Services and SQL Server 2012 Analysis Services with a
SharePoint 2010 farm to build BI solutions that offer greater scalability and increased functionality.

Reporting Services in SharePoint Integrated Mode


Installing Reporting Services in SharePoint Integrated mode adds the Reporting Services add-in for
SharePoint 2010 Products to the SharePoint web front-end servers in a SharePoint farm. When you install
Reporting Services in SharePoint Integrated mode, you should keep the following considerations in mind:

• You should install SharePoint 2010 and Reporting Services on the same computer; you can do this in
any order, but typically you install SharePoint 2010 first.

• You must install the SQL Server database engine to host the report server database. You can use an
existing instance of the database engine to store the report server database, or you can add a
database engine instance during the installation of Reporting Services.

• In SQL Server Setup, you should select the Reporting Services – SharePoint and Reporting Services
Add-in for SharePoint installation features. The installation only adds the Reporting Services files; it
does not configure the report server—you must do this later.

• After you install Reporting Services, you must install the Reporting Services SharePoint service. You
can do this by using the SharePoint Central Administration website.

• You must create a Reporting Services service application. You can do this by using the SharePoint
Central Administration website.
1-20 Introduction to Business Intelligence and Data Modeling

Note You can integrate SQL Server 2012 Reporting Services with SharePoint Foundation
2010 or SharePoint 2010 Standard, but to run Reporting Services as a shared service in a
SharePoint farm, you must integrate it with SharePoint 2010 Enterprise with SP1.

For More Information For more information about Deployment Checklist: Install
Reporting Services into an Existing SharePoint Farm, see
http://go.microsoft.com/fwlink/?LinkID=246775.

Analysis Services in SharePoint Integrated Mode


When you install Analysis Services in SharePoint Integrated mode, you should keep the following
considerations in mind:

• Analysis Services integration requires SharePoint 2010 Enterprise with SP1.


• In SQL Server Setup, you should select the SQL Server PowerPivot for SharePoint setup role.

• The installation creates an Analysis Services instance called PowerPivot. You cannot choose a different
name for this instance.
• After installation, you must configure the server by using the PowerPivot Configuration Tool. This tool
performs a number of post-installation tasks that leave the server in a useable state. You can also use
the PowerPivot Configuration Tool to repair the installation if required.

For More Information For more information about Install PowerPivot for SharePoint, see
http://go.microsoft.com/fwlink/?LinkID=246776.

Example SharePoint Configuration


The high-level steps in the following list explain how to install Reporting Services and Analysis Services in
SharePoint Integrated mode for a stand-alone server:
1. Install SharePoint 2010 Enterprise.

2. Install SharePoint 2010 SP1.


3. Install Analysis Services in SharePoint Integrated mode and the SQL Server 2012 database engine.
4. Use the PowerPivot Configuration Tool to configure the server.

5. Install Reporting Services and the Reporting Services add-in.

6. Create a Reporting Services application.


For More Information For more information about Deployment Checklist: Reporting Services,
Power View, and PowerPivot for SharePoint, see http://go.microsoft.com/fwlink/?LinkID=246777.

Note Configuring a SharePoint farm that has more than two tiers is more complex than
the process that is outlined in the preceding list. Multi-tier SharePoint farms require you to
configure Kerberos, the Active Directory® directory service, and network load balancing in
addition to SQL Server 2012 and SharePoint 2010. For information about Microsoft SQL
Server PowerPivot Planning and Deployment, see
http://go.microsoft.com/fwlink/?LinkID=246778.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-21

Lab Scenario

This lab provides an overview of the BI technologies you will explore throughout the rest of this course.
The lab is designed to provide you with an introduction to reporting and data analysis.

During the rest of the course, you will examine SQL Server 2012 BI capabilities in greater depth. In later
labs, you will perform the following BI tasks:

Lab Tasks

1 Explore SQL Server 2012 reporting, analysis, and data visualization technologies.

2A Create a report with Report Designer.

2B Enhance a report with graphical features and parameters, and publish it to a report server.

3 Use Report Builder to perform self-service reporting.

4 Configure report execution and delivery through subscriptions.

5 Create a multidimensional database that contains a simple OLAP cube.

6 Configure the dimensions in the cube.


1-22 Introduction to Business Intelligence and Data Modeling

(continued)

Lab Tasks

7 Configure the measures and measure groups in the cube.

8 Use MDX to query the cube.

9 Customize the cube’s behavior with actions, perspectives, and translations.

10 Create a tabular data model with PowerPivot for Microsoft Excel.

10 Extend the tabular model with custom DAX calculated columns and measures.

11 Create a tabular database in Analysis Services.

12 Use a tabular data model as a source for interactive data visualizations with Power View.

13 Use data mining technologies to perform predictive data analysis.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-23

Lab 1: Reporting and Analyzing Data

Exercise 1: Exploring a Reporting Services Report


Scenario
You want to explore the options for viewing reports in SQL Server 2012. To achieve this, you have installed
SQL Server Reporting Services and Analysis Services in SharePoint Integrated mode, and a developer has
created a Reporting Services report for you to explore.

The main tasks for this exercise are as follows:

1. Prepare the lab environment.


2. Publish and view a Reporting Services report.

 Task 1: Prepare the lab environment


• Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows® Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab01\Starter
folder as Administrator.

 Task 2: Publish and view a Reporting Services report


• Start Internet Explorer and browse to the http://mia-sqlbi SharePoint site.
• In the Libraries section of the Quick Launch pane, click Reports.

• On the Documents tab of the ribbon, click New Document and then click Report Builder Report. If
prompted to install Report Builder, click Run and wait for the application to be downloaded and
installed.
1-24 Introduction to Business Intelligence and Data Modeling

• In the Getting Started window, click Open. Then browse to the


D:\10778A\Labfiles\Lab01\Starter\AWReports folder and open the Sales_Report.rdl report.

• Click the round button at the top left of the Report Builder window, and click Save As. Then click the
Recent Sites and Servers shortcut, double-click http://mia-sqlbi/, double-click Reports, and click
Save.

• Close Report Builder, and in Internet Explorer, in the Libraries section of the Quick Launch area, click
Reports to refresh the view.

• Click the Sales_Report report, and note that it shows a chart of sales for 2004, as shown here.

• At the top of the report page, click the Next Page button and note that this page shows sales details
for January. Each subsequent page shows sales for the remaining months of the year.
• In the Year parameter list, check 2001, uncheck 2004, and then click Apply. Note that the report
now shows sales for 2001.

• On the Actions menu bar, click Export, and then click Excel. Then, when prompted, click Open to
open the report in Excel.

• View the report in Excel, and then close Excel and Internet Explorer.

Results: After this exercise, you should have published and viewed a Reporting Services report.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-25

Exercise 2: Exploring a PowerPivot Workbook


Scenario
To help you to continue your exploration of reporting and data analysis options, a BI developer has
created a PowerPivot workbook for you to review. You also intend to test PowerPivot Gallery by
uploading the workbook.

The main tasks for this exercise are as follows:


1. Open and review a PowerPivot for Excel workbook.

2. Upload a PowerPivot for Excel workbook to PowerPivot Gallery.

3. Open a PowerPivot for Excel workbook from PowerPivot Gallery.

 Task 1: Open and review a PowerPivot for Excel workbook


• In the D:\10778A\Labfiles\Lab01\Starter folder, double-click AW Sales.xlsx.

• Click the Reseller Sales tab. This worksheet contains a PivotTable table on the left that displays the
Sales Amount, Product Cost, and Total Profit measures, a PivotChart chart on the right entitled
Sales Amount by Category by Year, and two slicers named Country and Calendar Year at the top
of the worksheet. The worksheet should resemble the following image.
1-26 Introduction to Business Intelligence and Data Modeling

• In the PivotTable table, expand Bikes. Note that the values in the Sales Amount, Product Cost, and
Total Profit columns update automatically to show the data for the Bikes category. Note that the
color-coded conditional formatting in the Total Profit column displays a different color for each of
the bike categories. The color that is displayed for a given category depends on the value in the Total
Profit column for that category.

• Expand Mountain Bikes and review the data for the different products in the Mountain Bikes
subcategory.
• Review the data in the Sales Amount by Category by Year PivotChart chart.

• In the Country slicer, click United Kingdom. Note that the data in the PivotTable table and the
PivotChart chart updates to show only the sales figures for the United Kingdom.

• In the Calendar Year slicer, click 2004. Note that the data in the PivotTable table and the PivotChart
chart updates to show only the sales figures for 2004.
• In the Calendar Year slicer and the Country slicer, click the Clear Filter button.

• Close the PowerPivot window, and then close Excel without saving any changes.

 Task 2: Upload a PowerPivot for Excel workbook to PowerPivot Gallery


• Start Internet Explorer and browse to the http://mia-sqlbi SharePoint site.
• In the Libraries list, click PowerPivot Gallery.

• Click the Documents tab, click the Upload Document drop-down menu, and then click Upload
Document.
• In the PowerPivot Gallery – Upload Document dialog box, click Browse.
• In the File name box, navigate to the D:\10778A\Labfiles\Lab01\Starter\ folder, click AW Sales.xlsx,
and then click Open.
• In the PowerPivot Gallery – Upload Document dialog box, click OK. If the PowerPivot Gallery –
AW Sales.xlsx dialog box appears, click Save.

 Task 3: Open a PowerPivot for Excel workbook from PowerPivot Gallery


• In the PowerPivot Gallery, click the large AW Sales icon.

• Click the Reseller Sales tab, and then use the Calendar Year and Country slicers to modify the data
that is displayed in the PivotTable table and PivotChart charts.

• Clear the Calendar Year and Country slicer filters.

• In the breadcrumb trail at the top of the page, click PowerPivot Gallery to close the workbook.
• Keep Internet Explorer open for the next exercise.

Results: After this exercise, you should have reviewed and uploaded a PowerPivot for Excel workbook.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 1-27

Exercise 3: Exploring a Power View Report


Scenario
Business users can find it useful to visualize data interactively. To explore this technique, you will use the
tabular data model in the uploaded PowerPivot workbook to create a Power View report.

The main task for this exercise is as follows:


• Open a Power View report and create a column chart.

 Task 1: Open a Power View report and create a column chart


• In the PowerPivot Gallery, to the right of AW Sales, click the Create Power View Report button (use
the tooltips for the buttons to find this).

• In the fields pane, expand Reseller Sales, and then select Sales Amount.
• On the Design tab, in the Visualizations gallery, click Column. Then, drag the lower-right corner of
the chart to enlarge it.

• In the fields pane, expand Date, and then select Calendar Year.
• In the fields pane, expand Product, and then select Category. Then, in the chart, in the Category
series, click Clothing. The chart highlights the figures for the Clothing category. Click Clothing again
to display the figures for every category.
• In the fields pane, in Date, select Month. This displays multiple charts, one for each month of the
year. The chart should now resemble the following image.

• Close Internet Explorer. In the Windows Internet Explorer dialog box, click Leave this page.

Results: After this exercise, you should have created a Power View report.
1-28 Introduction to Business Intelligence and Data Modeling

Module Review and Takeaways

Review Questions
1. How do the BI implementations in your place of work use Microsoft technologies?
2. Does your organization use SharePoint in a BI context?
2-1

Module 2
Implementing Reports with SQL Server Reporting Services
Contents:
Lesson 1: Introduction to Reporting Services 2-3

Lesson 2: Creating a Report with Report Designer 2-12


Lesson 3: Grouping and Aggregating Data in a Report 2-24

Lab 2A: Creating a Report with Report Designer 2-35


Lesson 4: Showing Data Graphically 2-42

Lesson 5: Filtering Reports By Using Parameters 2-56

Lesson 6: Publishing and Viewing a Report 2-64


Lab 2B: Enhancing and Publishing a Report 2-71
2-2 Implementing Reports with SQL Server Reporting Services

Module Overview

One of the most common applications of business intelligence is to provide information to business users
in the form of reports. Microsoft® SQL Server® 2012 includes SQL Server Reporting Services, a
comprehensive platform for creating, publishing, and managing reports. The ability to design, develop,
and deliver accurate and effective reports is a valuable skill for any business intelligence developer, and
familiarity with SQL Server Reporting Services will help you gain that skill.
This module discusses the tools and techniques that a professional business intelligence developer can use
to create and publish reports. After completing this module, you will be able to:

• Describe the key features of Reporting Services.

• Use Report Designer to create a report.

• Group and aggregate data in a report.

• Use charts and other visualizations to show data graphically in a report.

• Use parameters to filter data in a report.

• Publish and view a report.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-3

Lesson 1
Introduction to Reporting Services

SQL Server Reporting Services is a component of SQL Server that provides a platform for building and
managing a reporting solution. Reporting Services is available in most editions of SQL Server, including
SQL Server Express with Advanced Services; though not all features are supported in all editions.
Before you start building a reporting solution, it is important to be familiar with common reporting
scenarios and how Reporting Services can be used to support them. This lesson provides an overview of
the ways in which Reporting Services can be used to provide a reporting solution in a business
organization.

After completing this lesson, you will be able to:

• Describe common reporting scenarios.


• Describe the modes in which Reporting Services can be deployed.

• Identify appropriate reporting tools for roles in a reporting scenario.

• List the report rendering formats supported by Reporting Services.

• Describe how Microsoft SQL Azure™ Reporting Services can be used for cloud-based reporting
solutions.
2-4 Implementing Reports with SQL Server Reporting Services

Reporting Scenarios

Every organization is different, and each has its own specific requirements for business reporting.
However, there are some common reporting scenarios with which BI developers should be familiar in
order to design appropriate reporting solutions.

Common reporting scenarios that can be found in many organizations include:

• Scheduled delivery of standard reports. BI developers create a set of standard business reports that
business users receive by email or delivery to a file share on a regular basis.

• On-demand access to standard reports. Business users consume reports on-demand by browsing to an
online report repository.

• Embedded reports and dashboards. Reports are integrated into an application or portal to provide
contextualized business information at a glance.
• Request to IT for custom reports. Business users request specific reports from the IT department, and s
BI developer creates the reports to order.

• Self-service reporting. Business users can use report authoring tools to create their own reports, often
based on data sources and datasets that have been published by the IT department.
Most reporting solutions address one or more of these scenarios, and before starting development on a
reporting solution, it is important to understand the scenarios that your solution must support.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-5

Reporting Services Modes

When installing SQL Server Reporting Services, you must choose between two possible deployment
modes:

• SharePoint integrated mode. In Microsoft SharePoint® integrated mode, the report server is installed
as a SharePoint 2010 shared service in a SharePoint Server farm, and users manage and view reports
in a SharePoint site. You can integrate SQL Server Reporting Services with Microsoft SharePoint
Foundation 2010 or SharePoint Server 2010.

• Native mode. In native mode, Reporting Services provides a management and report viewing user
interface (UI) called Report Manager, which is implemented as a stand-alone web application.
In business environments where SharePoint technologies are used, SharePoint Integrated mode is the
preferred deployment mode for SQL Server Reporting Services. SharePoint integration has been
completely re-architected in this release of SQL Server, and provides the following benefits:

• Centralized configuration management in SharePoint Central Administration.

• Scale-out support for integrated Reporting Services applications.


• A common security identity for Reporting Services and other SharePoint shared services through the
SharePoint Shared Service application pool.

• Support for claims-based authentication.


• SharePoint cross-farm support for viewing reports.

• Integration with SharePoint backup and logging features.


2-6 Implementing Reports with SQL Server Reporting Services

Note You can configure Reporting Services integration with SharePoint in local mode or
connected mode. In local mode, reports can be rendered in a SharePoint document library
without any need for a report server. In connected mode, your reporting solution can
include the full capabilities of Reporting Services, including subscriptions, snapshots, and
server-based report processing. For more information, see Reporting Services Report
Server (SharePoint Mode) in SQL Server Books Online.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-7

Reporting Roles and Authoring Tools

SQL Server Reporting Services supports multiple types of report author by providing a range of authoring
tools and environments.

Reporting Roles
Formal names for roles in a reporting scenario can vary across organizations. However, the following roles
describe common categories of user involved in developing or consuming reports.
• BI Developer. A professional business intelligence developer who creates sophisticated reports for
business users, and who is familiar with the underlying data warehouse, data marts, and other data
sources used for reporting. Job roles that fall into this category include BI specialists such as report
developers and data warehouse developers.

• IT Professional. A technical employee that is usually responsible for managing IT infrastructure, but in
small organizations or departments often required to create reports for business users. Job roles that
fall into this category include technology-based employees, such as IT administrators, database
developers, and programmers.
• Power User. A business user that is not a technical professional but has a good knowledge of IT
systems and principles, and the ability to use advanced features of tools and programs. Job roles that
fall into this category include users who need to perform detailed analysis of data, such as business
analysts and financial accountants.

• Information Worker. A business user who relies on information generated from IT systems to perform
their job, but who has no particular skills with IT tools or systems. Job roles that fall into this category
include anyone who consumes data as an aid to decision making as part of their daily activity; such as
sales employees, customer support engineers, and business executives.
2-8 Implementing Reports with SQL Server Reporting Services

Authoring Tools
SQL Server provides the following report authoring tools and environments.

• Report Designer. A professional report development interface integrated into the Visual Studio
development environment and packaged with other BI development tools in SQL Server Data Tools.
Report Designer provides support for project-based development, enabling you to create multiple
data sources, datasets, and reports as part of a single project, and take advantage of source control
support in Visual Studio Team Foundation Server. Report designer is the preferred report
development tool for BI professionals who need to create and maintain business reports for an
organization.
• Report Builder. A ClickOnce application that users can install directly from the Report Manager or
SharePoint document library where they view reports. Report Builder provides an easy to use, feature-
rich report development environment that supports reusable report elements and flexible layout of
report contents. Report Builder provides enough sophistication for IT professionals and power users
to create detailed business reports, but does not require the user to install and use a fully-featured
development environment.

• Power View. An interactive data visualization environment in which users can drag and drop data
entities in a previously created data model to create graphical representations of business data. Power
View is designed to support reporting environments where the emphasis is on the visual exploration
of data rather than the creation of detailed, formal reports. Power View is an ideal tool for
information workers who want to explore data visually in an intuitive, easy to use environment.

Note The rest of this module focuses on professional report development with Report
Designer. Self-service reporting with Report Builder is discussed in Module 3: Supporting
Self-Service Reporting; and Power View is described in Module 13: Creating Data
Visualizations with Power View.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-9

Report Rendering Formats

When planning a reporting solution, you must consider the ways in which reports will be consumed.
Typically, reports are consumed in one of the following three ways.

• Online – users view the report in a web browser.

• As a document in an application – Users open the report in an application, such as Microsoft Excel®.

• Printed – Users print the report and view it in hard copy.


When you publish a report to a Reporting Services report server, it can be rendered in an interactive
HTML-based report viewer that enables users to consume the report online. However, users can also
export the report to a number of formats, and print the report for offline viewing. Additionally, you can
deliver reports in specific file formats through subscriptions; in which case users do not need to view the
report online but can open the report directly in an application for viewing or printing.
Reporting Services supports this range of options for viewing reports by using an extensible rendering
architecture, in which a report can be rendered into any format for which a renderer is available. Each
renderer has its own strengths, limitations, and features; so understanding which renderers must be
supported in your reporting scenario can help you optimize reports to suit the pagination, image support,
and interactivity available in your target formats. By default, Reporting Services includes renderers for the
following formats:

• Microsoft Excel (2003 or 2007-2010)


• Microsoft Word (2003 or 2007-2010)

• Comma-Separated Value (CSV)

• XML
• Web Archive
2-10 Implementing Reports with SQL Server Reporting Services

• Image

• Adobe Acrobat (PDF)

• Atom Feed

Note When developing reports that might be rendered in multiple formats, test each
render format to ensure that the pagination and formatting provides the desired output.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-11

SQL Azure Reporting Services

SQL Server Reporting Services provides an on-premise reporting platform that you can use to deliver an
enterprise reporting solution for your organization. However, with the growing number of organizations
moving some or all of their IT infrastructure to the cloud, you might want to consider a cloud-based
reporting solution.

SQL Azure Reporting Services is a cloud-based service that provides a similar report authoring and
delivery experience to SQL Server Reporting Services in a highly scalable, self-managing infrastructure.
SQL Azure Reporting Services is designed to support two core reporting scenarios:
• Business and operational reports for data stored in SQL Azure.
• Embedded reports in Windows and Azure applications.

For More Information For more information about Windows Azure Business Analytics,
see http://go.microsoft.com/fwlink/?LinkID=246779.
2-12 Implementing Reports with SQL Server Reporting Services

Lesson 2
Creating a Report with Report Designer

Report Designer is a professional report authoring interface for the Visual Studio development
environment. You can use Report Designer to build and publish a report by creating a Reporting Services
project with SQL Server Data Tools.
This lesson describes how to use Report Designer, and explains the key elements of a report that you need
to develop with it.

After completing this lesson, you will be able to:


• Describe the structure of a report.
• Use the Report Wizard to create a report.

• Identify key elements of the Report Designer interface.

• Work with data sources.


• Work with datasets.

• Describe the different kinds of tablix data regions that you can use in a report.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-13

What Is a Report?

A report is an XML document that complies with the report definition language (RDL) schema and
includes a description of how data should be presented by a report renderer. A report includes the
following elements:

• Body. A description of the items included in the report and how they should be formatted and
presented.
• Data Sources. Connection information to access the data sources where the data for the report is
stored. Data sources can be embedded in the report, or stored in a separate file and shared across
multiple reports.
• Datasets. Query definitions that determine the data fields presented in the report. Each dataset is
associated with a data source, and can be embedded in the report or stored in a separate file and
shared across multiple reports.

You can author reports in any text editor by typing the appropriate RDL elements and attributes.
However, in most cases you should use the Report Designer authoring environment to create reports.
2-14 Implementing Reports with SQL Server Reporting Services

Using the Report Wizard

The easiest way to create a report is to use the Report Wizard. You can use the Report Wizard to create a
complete report, or to quickly create a starting point from which you will develop a more complex report.

The Report Wizard is started when you perform one of the following actions:

• Create a new project in SQL Server Data Tools by using the Report Server Project Wizard template.

• Add a report to an existing Report Server project by selecting the Report Wizard template or right-
clicking the Reports folder in Solution Explorer and click Add New Report.

After clicking Next on the Welcome to the Report Wizard page of the Report Wizard, the following
pages are presented to gather the information needed to create your report.
1. Select the Data Source. On this page you can select an existing shared data source in the project or
create a new one. If you create a new one, you must specify the connection information and
credentials to use when accessing the data source.

2. Design the Query. On this page, you can enter a query to define a dataset for your report. The
specific query syntax depends on the type of data source selected in the previous step, and if the data
source supports it you can use the Query Builder graphical tool to create the query.
3. Select the Report Type. On this page, you can choose to create a tabular or matrix report. Tabular
reports display data in rows, while matrix reports show data fields grouped in rows and columns, with
aggregated values in the intersecting cells, similar to a PivotTable or crosstab..

4. Design the Table/Matrix. The specific page displayed at this point depends on your choice of report
type. In either case, this page enables you to specify the fields and groupings in your table or matrix.

5. Choose the Table Layout. If you chose to create a tabular report, you can use this page to control
how groupings are displayed, display subtotals for grouped numeric values, and enable interactive
drilldown functionality that report viewers can use to expand or collapse grouped rows within the
table.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-15

6. Choose the Table / Matrix Style. On this page you can choose from a number of predefined visual
formats for your report.

7. Choose the Deployment Location. On this page you must specify the URL of the report server
where the report will be published.
8. Complete the Report Wizard. On this final page, you must specify a name for the report. Then you
can view a summary of the options you have selected and elect to preview the report as soon as it is
created. Clicking Finish on this page generates the report.
2-16 Implementing Reports with SQL Server Reporting Services

The Report Designer Interface

After you have created a report with the Report Wizard or added a blank report to a Report Server
project, you can edit the report in the Report Designer interface. Key elements of the Report Designer
interface include:

• Solution Explorer. This pane shows the projects in the currently open SQL Server Data Tools solution,
and the items in each project. For a Report Server project, it shows the reports, shared data sources,
shared datasets, and other resources included in the project.

• The Report Design Surface. This is the graphical report development area on the Design pane of
the Report Designer. You use this part of the interface to design a report.
• The Report Body. This represents the body of your report, where you can drag and drop report
items to define the layout of your report.

• The Properties Pane. This pane shows the properties of the selected item.
• The Report Data Pane. This pane shows the data sources, datasets, parameters, and images you have
defined for your report as well as built-in fields that you can use in any report.

• The Toolbox. This pane shows the report items you can place in the report body.
• The Grouping Pane. This pane shows the data groupings defined in your report, and enables you to
define and manage groupings to aggregate report data.

• The Preview Tab. This tab provides a preview of the report, enabling you to verify how the report is
rendered before publishing it.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-17

Working with Data Sources

A report requires one or more data sources. A data source:

• Defines the connection string used to access the database where report data is stored.
• Specifies the credentials to use when connecting to the database.

• Can be shared across multiple reports or embedded in a single report.


You can create a data source in the following ways:

• Specify details for the data source in the Select the Data Source page of the Report Wizard.

• Add a data source to the report in the Report Data pane.

• Add a shared data source to the project in the Solution Explorer pane.
Additionally, you can convert an embedded data source in the Report Data pane into a shared data
source.
2-18 Implementing Reports with SQL Server Reporting Services

Working with Datasets

After you have defined one or more data sources for your report, you must define the datasets that
contain the fields your report will display. A dataset:

• Defines a query used to retrieve data from a data source.

• Determines the fields available for use in the report.

• Can be shared across multiple reports or embedded in a single report.


You can create one or more datasets for each data source in your report in the following ways:

• Specify details for the data source in the Design the Query page of the Report Wizard.

• Add a dataset to the report in the Report Data pane.

• Add a shared dataset to the project in the Solution Explorer pane.

Additionally, you can convert an embedded dataset in the Report Data pane into a shared dataset.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-19

Tablix Data Regions

After you have defined a data source and a dataset, you can use a tablix data region to display data field
values in a report. The term “tablix” is derived from the words “table” and “matrix” because a tablix data
region provides a common user interface element that supports both kinds of report layout.

You can use the following kinds of tablix data region in a report.

• Table. A table data region shows data as rows in a table with a column for each field. For example,
you could use a table to show sales results aggregated by country, with a row for each country.

• Matrix. A matrix data region shows data fields grouped in rows and columns, with aggregated values
in the intersecting cells, similar to a PivotTable or crosstab. For example, you could use a matrix to
show sales for each country for a range of years, with a row for each country and column for each
year.

• List. A list data region shows a repeated arrangement of data items in a free-form layout. For
example, you could use a list to show details for each store in the organization as a store name field
formatted as a heading with labels and field values for business type, city, and phone number.
When you create a report with the Report Wizard, a table or matrix data region is automatically generated
in the report depending on the type of report you selected in the wizard. To add a tablix data region to
an existing report, drag the appropriate data region item from the Toolbox and position it in the report
body.
2-20 Implementing Reports with SQL Server Reporting Services

After you have added a tablix data region to the report, you can specify the data it should display by
dragging fields from the Report Data pane and dropping them in the appropriate space in the data
region. A tablix data region can only be bound to a single dataset, and the first field you add to a data
region creates this binding. Attempting to drag fields from a second dataset into a data region results in
an error.

Note You can use lookup functions to include data from multiple related datasets in a
single data region.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-21

Demonstration: Creating a Report

 Task 1: Use the Report Wizard to create a report


1. Ensure that both MIA-DC1 and MIA-SQLBI virtual machines are running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then, in the
D:\10778A\Demofiles\Mod02 folder, run Setup.cmd as Administrator.

2. Start SQL Server Data Tools, and create a new project using the Report Server Project Wizard
template. Name the project ReportsDemo1 and save in the D:\107778A\Demofiles\Mod02 folder.

3. In the Welcome to the Report Wizard page, click Next.

4. In the Select the Data Source page, create a new data source named AdventureWorksDW that
uses Windows authentication to connect to the AdventureWorksDW database on the localhost
instance of SQL Server. Do not select the Make this a shared data source checkbox, and click Next.

5. On the Design the Query page, click Query Builder, and in the Query Designer window, perform
the following steps and click OK. Then click Next.
• Add the DimGeography, DimReseller, and FactResellerSales tables.

• Select the EnglishCountryRegionName, StateProvinceName, and City columns in the


DimGeography table.
• Select the ResellerName column in the DimReseller table.

• Select the SalesOrderNumber, OrderDate, and SalesAmount columns in the FactResellerSales


table.

• Add the following values to the Alias column:

EnglishCountryRegionName: Country
StateProvincename: State

ResellerName: Reseller
2-22 Implementing Reports with SQL Server Reporting Services

6. On the Select the Report Type page, ensure that Tabular is selected, and then click Next.

7. On the Design the Table page, add all fields to the Details section. Then click Next.

8. On the Choose the Table Style page, preview each of the built-in styles, and then select Generic and
click Next.

9. On the Choose the Deployment Location page, review the default selections and then click Next.

10. On the Completing the Wizard page, change the report name to Reseller Sales and click Finish.

 Task 2: Format and preview a report in Report Designer


1. When the report has been created, click the report design surface and in the View menu, click
Report Data.

2. In the Report Data pane, expand Data Sources and note that the AdventureWorksDW data source
you defined in the wizard has been created. Then expand Datasets and note that a dataset named
Dataset1 has been created from the query you defined in the wizard.

3. Right-click Dataset1 and click Dataset Properties. Then change the name to ResellerSales and click
OK.

4. Click the Preview tab and view the report with its default formatting. Then click the Design tab.

5. In the report body, click the text box at the top left containing the report title (Reseller Sales), and
then use the formatting buttons on the toolbar to make the title bold with a size of 14pt.
6. Click the tablix data region so that the gray row and column headers appear, and click the gray box
where the row and column headers intersect to select the data region. Then drag the multidirectional
arrow handle to move the data region down to make room for a larger title.

7. Click the title textbox and resize it so all of the text is visible.

8. In the tablix data region, click the top-left cell (which contains the Country column title) and drag to
the bottom-right cell (which contains the [SalesAmount] field) to select all cells in the data region.
Then click the Align Left button on the toolbar.

9. Click outside of the tablix data region to de-select it, and then select the first row of the tablix data
region (which contains the column titles) and on the toolbar, click the Bold button. Then click the
Background Color button and set the background to Light Gray.

10. Right-click the cell containing the [OrderDate] field and click Textbox Properties. Then in the Text
Box Properties dialog box, on the Number tab, select the Date category and the 31-Jan-00 type
and click OK.

11. Click the cell containing the [SalesAmount] field and press F4. Then in the Properties pane, set the
Format property to $###,##0.00.

12. Click the tablix region so that the gray row and column headers appear, and then click and drag the
border between the column headings to widen the columns so that the data they contain fits on a
single line. You may need to switch back and forth between Design and Preview tabs to determine
appropriate column widths.

13. Click the Preview tab to view the completed report.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-23

14. Click the Export button, and then click Excel. When prompted, save the report as Reseller Sales.xlsx in
the D:\107778A\Demofles\Mod02 folder.

15. Close SQL Server Data Tools, and then open the Reseller Sales.xlsx Excel workbook in the
D:\107778A\Demofles\Mod02 folder and view the exported report.
16. Close Excel.
2-24 Implementing Reports with SQL Server Reporting Services

Lesson 3
Grouping and Aggregating Data in a Report

While many reports show detailed business data, it is very common for reports to show aggregated data
that is grouped by time periods or business entities, For example, a sales manager might require a report
that shows total sales grouped by salesperson and month.
Reporting Services reports can include multiple data groupings and aggregated values, and even include
interactive drilldown functionality that enables report consumers to show or hide different levels of detail
in a grouped report.

This lesson describes how to implement grouping in a report and control how grouped data is rendered.
After completing this lesson, you will be able to:

• Add groups to a tablix data region.


• Display aggregated values based on groupings in a report.

• Enable interactive drilldown functionality for data groupings in a report.

• Configure page breaks for groups in a report.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-25

Adding Groups to a Tablix Data Region

You can group data in a tablix data region to make it easier for users to see a breakdown of business
information by time periods or business entities. A data region can contain multiple groups, and each
group can contain multiple levels. For example, a report that shows sales might group the sales by
product category, subcategory, and individual product.

The Groupings pane in Report Designer shows the groups defined in a data region. Table data regions can
have row groups, and matrix regions can have both row and column groups. All table and matrix data
regions include a detail-level group, which by default includes all data fields.
You can use the following techniques to create groups.
• Drag the field on which you want to group data from the Report Data pane to the Groupings pane
and drop it above an existing group to create a parent group, or below an existing group to create a
child group.
• Right-click an existing group in the Groupings pane, click an option on the Add Group context
menu, and specify the field in the bound dataset you want to group by. Using this technique enables
you to add a parent group, a child group, or an adjacent group before or after the existing group you
right-clicked.

• Right-click a cell in the table or matrix, click an option on the Add Group context menu, and specify
the field in the bound dataset you want to group by. Using this technique enables you to add a
parent group, a child group, or an adjacent group before or after the group that contains the cell you
right-clicked.

Note In most scenarios, report data is grouped by individual fields in the dataset.
However, you can also use expressions to define groupings that include multiple fields or
other criteria.
2-26 Implementing Reports with SQL Server Reporting Services

After defining a group, you can select the group in the Groupings pane and edit its properties. In
particular, you should specify an appropriate name for the group because group names can be used in
expressions to specify scope for aggregated values.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-27

Displaying Aggregated Values

One of the benefits of grouping data in a report is that you can use the groupings to show aggregated
values for the data. For example, a report that shows sales grouped by product category, subcategory,
and individual products can show sales totals for each category, subcategory, and product.

You can use the following techniques to add an aggregation to a report.

• Right-click a group in the Groupings pane, click Add Total, and click Before or After depending on
where you want to display the total. This technique adds a row (or column if you clicked a column
group for a matrix data region) containing a Sum function for each numeric field in the group.
• Add a row or column to the group and enter an expression that includes an aggregation function
such as Sum, Avg, Min, Max, or Count. By default, the function aggregates data at the same level as
the group within which it is used. For example, you could use the following expression in a Product
group to show the total sales for each product.

=Sum(Fields!SalesAmount.Value)

• In any group level, use an aggregation function with a named scope to aggregate a field value at
another group level. For example, you could use the following expression in a Subcategory group to
show the total sales for each subcategory and how that compares with the total sales for the
Product_Category parent group.

=Sum(Fields!SalesAmount.Value) & " of " & Sum(Fields!SalesAmount.Value,


"Product_Category")
2-28 Implementing Reports with SQL Server Reporting Services

Enabling Interactive Drilldown Functionality

Groups and aggregations enable you to create reports that include summary and detail levels of
information. In many business scenarios, report users initially want to view summary information, and only
explore details for specific groupings where a potential issue or anomaly merits further investigation.
Reporting Services supports this “drilldown” functionality by enabling you to hide or show groups in a
report by clicking a toggle button associated with a field in the parent group.

You can use the following techniques to enable drilldown functionality in a report.

• In the Report Wizard, select Enable Drilldown in the Choose the Table Layout page for a tabular
report that contains groups.
• In an existing report that contains groups, right-click a child group in the Groupings pane and click
Group Properties. Then, in the Group Properties dialog box, on the Visibility tab, select Hide,
select Display can be toggled by this report item, and select the field in the parent group that you
want report viewers to use to show or hide the group.

Note Drilldown functionality is only available when a published report is viewed in a


browser or exported to a format such as Microsoft Excel where the renderer supports this
kind of interactivity. When exported to a format that does not support interactivity, the data
is rendered statically in the state in which it is currently displayed in the browser.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-29

Configuring Page Breaks for Groups

You can view reports online in a browser, but in many cases, they are printed or exported to another
format for offline viewing and further analysis. Reporting Services provides a number of ways in which you
can control how reports are divided into pages when they are printed or rendered in a format that
supports pagination. Pagination is particularly important when working with groups, for example enabling
you to start a new page for each new instance of a group.

Key ways in which you can control pagination include:

• Defining page breaks in tablix data regions, groups, and rectangles. You can define explicit behaviors
for page breaks by setting the BreakLocation, ResetPageNumber, and PageName properties in the
PageBreak category.

• The BreakLocation property specifies where the page break should occur. For data regions and
rectangles, this can be before, after, or before and after the report element on which the page
break is defined. For groups, you can also specify that the page break should occur between
instances of the group; for example, you can force a new page for each employee in a report that
shows sales grouped by employee.

• The ResetPageNumber property causes page numbering to be restarted on the new page that
the page break causes.
• The PageName property specifies a name for the new page that the page break causes. Some
renderers, such as Microsoft Excel®, use page names to identify pages. You can set an explicit
value for this property, or you can use an expression to generate the value dynamically—for
example, to specify the name of the employee in the grouped sales report that the previous topic
described.

You can also set the Disabled property to disable a page break.

• Setting the InitialPageName property of the report. This property defines the page name for the first
page in the report (or for all pages if it contains no explicitly defined page breaks).
2-30 Implementing Reports with SQL Server Reporting Services

Pagination and Microsoft Excel


The ability to control pagination is particularly useful when you export reports to Microsoft Excel. By
default, the Excel rendering extension creates a workbook in Excel with a single worksheet that contains
the report data. The worksheet name (which is shown in the tabs at the bottom of the workbook) is based
on the name of the report by default. However, if you specify an InitialPageName property value, it is
used for the worksheet name.

In many cases, you may want to render the report data in Excel on multiple worksheets. One reason for
doing this is to make it easier for users to navigate the data in the report, for example, by creating a new
worksheet (and corresponding tab) for each employee grouping in the sales report that the previous topic
described. Another reason is that Excel enforces a maximum number of rows for each worksheet, and a
very large report may not render successfully if it contains more rows than are available in a worksheet.

Setting a page break in a report causes the Excel rendering extension to generate a new worksheet, and if
the page break includes a PageName property value, the worksheet is named accordingly. This makes it
possible to design easy-to-navigate, multiple-worksheet Excel-based reports.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-31

Demonstration: Grouping Data in a Report

 Task 1: Create groups in a Tablix data region


1. Ensure that both MIA-DC1 and MIA-SQLBI virtual machines are running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then, in the
D:\10778A\Demofiles\Mod02 folder, run Setup.cmd as Administrator.

2. Double-click ReportsDemo2.sln in the D:\107778A\Demofiles\Mod02 folder to open the solution in


SQL Server Data Tools. Then in Solution Explorer, double-click the Reseller Sales.rdl report.

3. In the Groupings pane, in the Row Groups section, in the table1_Details_Group drop-down list, point
to Add Group and click Parent Group. Then in the Tablix Group dialog box, in the Group By list
click [Country], select Add group header, and click OK.
4. Note that the report now contains two Country columns – one for the group you just created, and
one for the original Country field, which is no longer required. Right-click the gray column header for
the original Country field (the second column) and click Delete Columns to remove it.

5. In the Report Data pane, expand Datasets, and drag the State field from the ResellerSales dataset
and drop it between the Country and table1_Details_Group groups in the Grouping pane. Note that
this adds a group for the State field without a group header in addition to the original State field.
Then, right-click the gray column header for the original State field (the third column) and click
Delete Columns to remove it.
6. Right-click the [State] field in the second column, point to Insert Row, and click Inside Group –
Above. This creates a header row for the group.

7. Right-click the [City] field in the third column, point to Add Group, and under Row Group, click
Parent Group. Then in the Tablix Group dialog box, in the Group By list click [City], select Add
group header, and click OK. Then, right-click the gray column header for the original City field (now
the fourth column) and click Delete Columns to remove it.
2-32 Implementing Reports with SQL Server Reporting Services

8. Right-click the [City] field in the third column, point to Add Group, and click Child Group. Then in
the Tablix Group dialog box, in the Group By list click [Reseller], select Add group header, and
click OK. Then, right-click the gray column header for the original Reseller field (the fifth column)
and click Delete Columns to remove it.

9. In the Groupings pane, in the table1_Details_Group drop-down list, click Group Properties. Then
on the Sorting tab, click Add and in the Sort by column, click [OrderDate]. Then click OK.
10. Preview the report, and switch back to the Design tab to widen the new columns as required. When
you are satisfied with the column widths, preview the report and note that the data is now grouped
and sorted.

 Task 2: Display aggregate values for data groups


1. On the Design tab, in the Groupings pane, on the Country drop-down list, point to Add Total and
click After. Note that this adds a row at the bottom of the table with an expression to calculate the
sum of the [SalesAmount] field.
2. In the Groupings pane, on the State drop-down list, point to Add Total and click Before. Note that
this adds an expression to calculate the sum of the [SalesAmount] field to the first row in the table
(in which the [Country] field is displayed in the first column).
3. Repeat the previous step for the City, Reseller, and table1_Details_Group groups, and note that the
Sales Amount column now contains subtotals for each grouping with a grand total at the bottom.

4. When you added the totals, Report Designer automatically created a Total label for each row. Delete
all of these Total labels other than the one on the bottom row of the table.

5. Right-click the cell immediately above the [Sales Order Number] field in the Sales Order Number
column, and click Expression. Then in the Expression dialog box, enter the following expression and
click OK.

=CountDistinct(Fields!SalesOrderNumber.Value)

6. Right-click the cell containing the expression you just created and click Copy, and then paste the cell
into each of the empty cells above it.
7. Preview the report, and note that the number of orders and sales total for each group is displayed.

 Task 3: Enable drilldown interactivity


1. On the Design tab, in the Groupings pane, in the table1_Details_Group drop-down list, click Group
Properties.

2. In the Group Properties dialog box, on the Visibility tab, select the Hide option, select the Display
can be toggled by this report item checkbox, and in the drop-down list, select Reseller1. Then click
OK. Reseller1 is the textbox containing the name of the reseller for each Reseller group.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-33

3. Repeat the previous two steps to hide the following groups and enable them to be toggled by the
specified report items:

• Reseller (toggled by City1)


• City (toggled by State1)

• State (toggled by Country1)

4. Preview the report and note that you can expand and contract the groupings to display the level of
detail you require.

 Task 4: Configure report pagination based on data groups


1. On the Design tab, click the report design surface and press F4. Then in the Properties pane, set the
InitialPageName property for the Report item to Reseller Sales Report.

2. Click the tablix data region so that the gray row and column headers appear, and click the gray box
where the row and column headers intersect to select the data region. Then in the Properties pane,
expand the PageBreak property group for the table1 tablix and set the BreakLocation property to
Start. This creates a page break at the start of the tablix data region.
3. In the Groupings pane, click the Country group. Then in the Properties pane, expand the Group and
PageBreak property groups for the Country tablix member and set the BreakLocation property to
Between. This creates a page break between each instance of the Country group.

4. With the Country group still selected, in the Properties pane, set the PageName property to the
following expression:

=Fields!Country.Value

5. Preview the report and note that the first page contains only the report title.
6. Use the page navigation buttons to scroll through the report and verify that each country group
starts on a new page.

7. Click the Export button, and then click Excel. When prompted, save the report as Reseller Sales.xlsx in
the D:\107778A\Demofles\Mod02 folder – replacing the file if it already exists.

8. Close SQL Server Data Tools, and then open the Reseller Sales.xlsx Excel workbook in the
D:\107778A\Demofles\Mod02 folder and view the exported report, noting that it contains a title
worksheet and a worksheet for each country, in which users can expand or collapse the grouped data.
Then close Excel.
2-34 Implementing Reports with SQL Server Reporting Services

Lab Scenario

The sales manager at Adventure Works Cycles currently spends a large amount of time manually creating
sales reports in Excel. The report shows monthly sales broken down by product category, subcategory,
and individual product, but it takes too long to produce each month.

The sales manager has requested a reporting solution that generates the required report on-demand, and
exported in Excel format.
To accomplish this, you will create a report, and enhance it to group and aggregate data, support
interactive drilldown, and generate a separate worksheet per month when exported to Excel.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-35

Lab 2A: Creating a Report with Report Designer

Exercise 1: Creating a Report


Scenario
The sales manager at Adventure Works spends a large amount of time each month using Excel to query
the data warehouse in order to produce a sales report that shows monthly sales broken down by product
category, subcategory, and individual product. You have been asked to create a reporting solution that
provides the sales manager with an Excel workbook containing the information they need without the
need to manually query the data warehouse each month.

The main tasks for this exercise are as follows:

1. Prepare the lab environment.

2. Create a Report Server project.


3. Add a report to the project.

4. Explore and modify report properties.

5. Format the report.


6. Export the report to Microsoft Excel

 Task 1: Prepare the lab environment


• Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.
• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab02A\Starter
folder as Administrator.
2-36 Implementing Reports with SQL Server Reporting Services

 Task 2: Create a Report Server project


• Start SQL Server Data Tools and create a new Report Server project named AWReports in the
D:\10778A\Labfiles\Lab02A\Starter\Ex1 folder.

 Task 3: Add a report to the project


• Use the Report Wizard to add a report to the project. Specify the following settings in the wizard:

• Create a new embedded data source named AdventureWorksDW that connects to the
AdventureWorksDW database on the localhost instance of SQL Server by using Windows
authentication.
• Use the following query to retrieve the data for the report (You can import this query from the
D:\10778A\Labfiles\Lab02A\Starter\Ex1\SalesQuery.sql).

SELECT d.CalendarYear [Year],


d.MonthNumberOfYear [MonthNo],
d.EnglishMonthName [Month],
c.EnglishProductCategoryName [ProductCategory],
s.EnglishProductSubcategoryName [ProductSubcategory],
p.EnglishProductName [Product],
i.SalesOrderNumber,
i.OrderDate,
i.SalesAmount
FROM dbo.DimProductCategory c
INNER JOIN dbo.DimProductSubcategory s ON s.ProductCategoryKey = c.ProductCategoryKey
INNER JOIN dbo.DimProduct p ON p.ProductSubcategoryKey = s.ProductSubcategoryKey
INNER JOIN dbo.FactInternetSales i ON i.ProductKey = p.ProductKey
INNER JOIN dbo.DimDate d ON i.OrderDateKey = d.DateKey
ORDER BY d.CalendarYear, d.MonthNumberOfYear, c.EnglishProductCategoryName,
s.EnglishProductSubcategoryName, p.EnglishProductName, i.SalesOrderNumber

• Create a tabular report that includes the Year, Month, ProductCategory, ProductSubcategory,
Product, SalesOrderNumber, OrderDate, and SalesAmount fields in the details section with no
groupings.

• Apply the generic report style.

• Name the report Sales Report.

 Task 4: Explore and modify report properties


• In the Report Data pane, change the name of the Dataset1 dataset to Sales.

• In the Groupings pane, change the name of the table1_Details_Group to SalesDetails.

 Task 5: Format the report


• Preview the report to view the default formatting.
• On the Design tab, format the report so that when previewed it looks like the following image. Use
the following formatting techniques:

• To format text, select the text or textbox in which it is displayed and use the formatting buttons
on the toolbar.

• To change column widths, drag the edges of the column headers.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-37

• To apply a number or date format, right-click the textbox containing the data field and click
properties. Then on the Number tab, select an appropriate format.

 Task 6: Export the report to Microsoft Excel


• Preview the report and export it to a Microsoft Excel workbook named Sales Report.xlsx in the
D:\10778A\Labfiles\Lab02A\Starter\Ex1 folder.
• Open the exported report in Excel and view it.

• Close Excel and SQL Server Data Tools.

Results: After this exercise, you should have a report that shows sales data from the
AdventureWorksDW database.
2-38 Implementing Reports with SQL Server Reporting Services

Exercise 2: Grouping and Aggregating Data


Scenario
The sales manager has reviewed the report you have created and requested that you modify it so that the
Excel workbook generated from the report includes a blank title worksheet and a worksheet for each
month of the year. On each month’s worksheet, sales for that month should be grouped by product
category, product subcategory, and individual product.

The main tasks for this exercise are as follows:

1. Open the AWReports project.

2. Delete the Year column and Titles row.

3. Group the report by Month.

4. Add groups for Product Category, Product Subcategory, and Product.

5. Add aggregate summary values.

6. Enable drilldown interactions.

7. Add page breaks

 Task 1: Open the AWReports project


• Open the AWReports solution in the D:\10778A\Labfiles\Lab02A\Starter\Ex2 folder with SQL Server
Data Tools.

• View the Sales Report report.

 Task 2: Delete the Year column and titles row


• Delete the Year column.
• Delete the row containing the column titles.

 Task 3: Group the report by Month


• Add a parent group to the SalesDetails group. The new group should group the data on the Month
field and should include a group header.
• Preview the report and note that the month is now displayed at the group level and in the detail
level.

• Delete the column that displays the Month field in the details group. This column is no longer
required because the month is now displayed in the parent group header.

• Preview the report again and note that the months are displayed in alphabetical order.

• Edit the properties of the new parent group so that the group is sorted by the MonthNo field. This
ensures that the data is displayed in the correct month order (January, February, and so on.)

• Preview the report again to ensure it looks correct.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-39

 Task 4: Add groups for Product Category, Product Subcategory, and Product
• Add parent groups with group headers to the SalesDetails group for the ProductCategory,
ProductSubcategory, and Product fields.

• Delete the details columns for the fields in the report that now have their own groups.
• Ensure your report looks like the following image.

 Task 5: Add aggregate summary values


• Add totals rows before the SalesDetails, Product, ProductSubcategory, and ProductCategory
groups.
• Add the following expression in the Product group heading row immediately above the
SalesOrderNumber field:

=Count(Fields!SalesOrderNumber.Value)

• Copy the cell containing the expression to the ProductSubcategory, ProductCategory, and Month
rows.
2-40 Implementing Reports with SQL Server Reporting Services

• Verify that your report looks like the following image.

 Task 6: Enable drilldown interactions


• Edit the visibility properties of the SalesDetails group so that it is hidden by default and its visibility
can be toggled by the Product1 textbox (which is the textbox containing the Product value in the
Product group heading.
• Modify the Product group so that its visibility can be toggled by the ProductSubcategory1 textbox.

• Modify the ProductSubcategory group so that its visibility can be toggled by the
ProductCategory1 textbox
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-41

• Verify that when previewed, your report provides drilldown functionality as shown in the following
image.

 Task 7: Add page breaks


• Set the InitialPageName property of the report to Sales Summary.
• In the Groupings pane, select the Month group and then in the Properties pane, in the Group
section, create a page break between each instance of the group.

• Set the PageName property for the Month group to the following expression:

=Fields!Month.Value

• Add a page break at the start of the table1 Tablix object so that the table starts on a new page,
leaving a blank page with only the report title at the beginning of the report.

• Preview the report and export it to a Microsoft Excel workbook named Sales Report.xlsx in the
D:\10778A\Labfiles\Lab02A\Starter\Ex2 folder.

• Open the exported report in Excel and view it to verify that the first sheet in the workbook is named
Sales Summary, and that there is an additional sheet for each month’s sales. The worksheets for each
month’s sales should enable users to drilldown and view the data at the product category,
subcategory, and product levels.

• Close Excel and SQL Server Data Tools.

Results: After this exercise, you should have a report that includes sales data grouped by month, product
category, subcategory, and product.
2-42 Implementing Reports with SQL Server Reporting Services

Lesson 4
Showing Data Graphically

While many reports contain only text and figures, some users prefer to view graphical representations of
business data. Reporting Services supports a number of data visualizations that you can use to create
graphical reports that give users an intuitive understanding of key business metrics.
This lesson describes various ways to add graphical elements to a report. After completing this lesson, you
will be able to:

• Include images in a report.


• Include charts to visualize data values in a report.
• Use gauges to show key values in a report.

• Summarize data graphically with data bars and sparklines.

• Use indicators to show trends and key performance indicators (KPIs) in a report.
• Display geographical data in a report by using a map.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-43

Including Images in a Report

You can enhance the appearance of a report by including images. Common ways to use images in a
report include:

• Adding a logo to a report. For example, a company might include its logo in the header of all reports
to provide a consistent look and feel that reflects corporate branding.

• Binding an image to a data field. For example, a report showing a breakdown of sales by product
might include a photograph of each product.

• Including a background image in a report. For example, an annual report for shareholders in a bicycle
manufacturing company might include a subtle image of the corporate headquarters as a
background watermark for the report.

To add an image to a report, drag an Image item from the Toolbox and place it in the report body. Then
use the Image Properties dialog box to configure the image. The key property you must set is the image
source, which can be one of the following three kinds:

• External. An image published in an external location such as a website. If you select this option, you
must specify the location of the image as a URL in the Use this image listbox. Alternatively, if the
dataset used by the report includes a field that contains a URL, you can select this field.

• Embedded. An image that is embedded into the report. If you select this option, you can import an
image file to embed in the report.
• Database. An image field in the dataset. If you choose this option, you must specify the field you want
to bind to the Image control, and the MIME type you want to use when rendering the image.
2-44 Implementing Reports with SQL Server Reporting Services

To display a background image for a report body or data region, set the following properties in the
BackgroundImage category of the Properties pane.

• Source: Specify external, embedded, or database as described above.


• Value: Specify the source of the image as above.

• MIMEType: Specify the MIME type to be used for image data fields as described above.

• BackgroundRepeat: Specify whether the image should be repeated to fill the background.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-45

Working with Charts

Charts provide a common way to express data values visually. Many reports include a chart as a visual
summary of the detailed data in a table or matrix; and some reports consist solely of a chart.

Use the following procedure to add a chart to a report:

1. Drag a Chart item from the Toolbox and drop it on the body of the report.

2. In the Select Chart Type dialog box select an appropriate type of chart for your data. Available chart
types include:

• Column charts
• Line charts

• Shape charts (such a pie charts)

• Bar charts

• Area charts

• Range charts

• Scatter charts

• Polar charts

3. Select the chart to display the Chart Data pane, and then specify the fields that the chart will display:

• Add one or more data fields to the Values area to specify the fields to be plotted on the value
axis of the chart. For example, add a SalesAmount field from dataset showing customer sales
orders.
2-46 Implementing Reports with SQL Server Reporting Services

• Add fields to the Category Groups area to create the data points for the chart. For example, add
a Year field from the sales orders data set to show a summarized value for each year.

• Add fields to the Series Groups area to plot values for multiple series. For example, add a
Country field from the sales orders data set to show summarized sales values for each country.
4. You can edit the properties of the chart area and individual elements within it, such as axis titles, the
chart legend, and the chart title. This enables you to customize the appearance of the chart to suit
your requirements. You can also change the type of a chart if you later decide that the data would be
better represented using a different visualization. For example, you might change a column chart
showing sales grouped by year to a line chart to show a trend over time more clearly.

For More Information For more information about using charts in reports, see Charts
(Report Builder 3.0 and SSRS) in SQL Server Books Online.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-47

Demonstration: Creating a Chart

 Task 1: Add a chart to a report


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then, in the
D:\10778A\Demofiles\Mod02 folder, run Setup.cmd as Administrator.

2. Double-click ReportsDemo3.sln in the D:\107778A\Demofiles\Mod02 folder to open the solution in


SQL Server Data Tools. Then in Solution Explorer, double-click the Reseller Sales.rdl report.

3. Click the tablix data region so that the gray row and column headers appear, and click the gray box
where the row and column headers intersect to select the data region. Then drag the multidirectional
arrow handle to move the data region down about 10 centimeters.
4. In the Toolbox, drag a Chart to the blank area you just created above the tablix data region. Then in
the Select Chart Type dialog box, in the Shape section select the third chart style (3-D Pie) and click
OK.

5. Move and resize the chart to fit the available space above the tablix data region.

 Task 2: Specify chart data


1. Click the chart to display the Chart Data pane.

2. In the Chart Data pane, in the Values section, add the SalesAmount field.
3. In the Chart Data pane, in the Category Groups section, add the Country field.

4. Click the Preview tab and verify that the chart displays sales by country.
2-48 Implementing Reports with SQL Server Reporting Services

 Task 3: Format a chart


1. On the Design tab, click the Chart Title label, and then in the Properties pane change the Caption
property to Reseller Sales by Country.

2. Click a blank area on the report design surface, and then right-click the chart, point to Chart, and
click Chart Properties.
3. In the Chart Properties dialog box, in the Color palette drop-down list, select Bright pastel, and
click OK.

4. Preview the report and view the formatted chart.

5. Click the Export button, and then click Excel. When prompted, save the report as Reseller Sales.xlsx in
the D:\107778A\Demofles\Mod02 folder – replacing the file if it already exists.

6. Close SQL Server Data Tools, and then open the Reseller Sales.xlsx Excel workbook in the
D:\107778A\Demofles\Mod02 folder and view the exported report, noting that the first worksheet
contains the chart. Then close Excel.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-49

Showing Key Values with Gauges

Gauges provide an intuitive way to show key performance indicators (KPIs) in a report. For example, you
can use a gauge to show sales performance against a sales quota in the form of a dial or linear indicator.
Gauges can be radial or linear, and exist within a gauge panel. When you add a gauge to a report, a
gauge panel is automatically created, to which you can then add more gauges if required.

Use the following procedure to add a gauge to a report:


1. Drag a Gauge item from the Toolbox and place it on the report body.

2. In the Select Gauge Type dialog box, choose an appropriate gauge type for your data.

3. Select the gauge to display the Gauge Data pane, and add one or more fields to the Values section
to define the pointers that your gauge will display. For example, add the SalesAmount field from a
dataset showing sales figures for an organization.
4. Format the scale of the gauge and add one or more ranges so that the pointer value is shown relative
to a comparative business measure. For example, set the scale to use a SalesQuota value as a
maximum so that the needle shows current sales volume relative to the sales quota for the year; and
add a range to highlight important subsections of the scale, such as a red area for values less than the
sales volume that the company must achieve to break even.

For More Information For more information about using gauges in reports, see Gauges
(Report Builder 3.0 and SSRS) in SQL Server books Online.
2-50 Implementing Reports with SQL Server Reporting Services

Summarizing Data with Data Bars and Sparklines

Data bars and sparklines are compact charts that are usually displayed in-line with data in a table or
matrix. They provide the same type of visual representations of data as standard charts, but they are
designed to be small, so they do not support chart features such as legends, axes lines, labels, or tick
marks. Report authors can use data bars and sparklines to convey a lot of information visually in a small
amount of space. In particular, data bars and sparklines are useful for providing comparisons of key
metrics across a number of rows of data, enabling report consumers to see potential issues and identify
outliers at a glance.

Although data bars and sparklines are similar, the key differences between them are:
• You can use data bars to show multiple data points, but you typically use them to show a single
value—such as an annual sales total. You can include a data bar at any level of a table or matrix.
• You can use sparklines to display multiple data points that are grouped by categories, such as sales
totals for a range of months. They work with aggregated data, and you can only use them in a group
level of a table or matrix.

Use the following procedure to add a data bar or sparkline to a report:

1. Drag a Data Bar or Sparkline item from the Toolbox and place it in an appropriate cell in a table or
matrix.

2. Select the appropriate data bar or sparkline type.


• You can use sparklines to display most kinds of chart, including column, bar, line, area, pie, and
range charts. Only pie charts can be shown in three-dimensional (3-D) format.
• You can only use data bars to display column or bar charts. These can be basic (in which each bar
or column represents a single value), stacked (in which multiple values are shown as different
colored ranges in the same bar or column), or 100% stacked (in which the bar or column fills the
available space and multiple values are shown as proportionally sized color ranges).
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-51

3. Select the data bar or sparkline to display the Chart Data pane, and then specify the fields to display:

• Add one or more data fields to the Values area to specify the series and fields that you want to
show in the chart. You can add multiple series and multiple fields for each series; for example,
you can create a sparkline that shows an employee’s monthly sales totals together with his
monthly sales quota. However, you should bear in mind that the benefit of data bars and
sparklines is in their compactness; if you try to display too much data in such a small chart, you
may confuse rather than inform report users.
• Add fields to the Category Groups area to define the grouping that defines the categories for
the chart. For data bars that show only a single value, a category group is not required. For
sparklines where you want to show the value (for example, sales total) across a range of
categories (for example, months), you need to specify the field on which you want to aggregate
the data.

• Add fields to the Series Groups area to add a further grouping of the data. For example, for a
sparkline that shows sales grouped by month, you can add a series group to show monthly sales
grouped by product. Generally, series groups are more effective in full charts than they are in
data bars and sparklines.

In addition to the data settings, you can set a wide range of properties to format the colors and style of
the data bar or sparkline.

Data Bar and Sparkline Alignment


You generally use sparklines and data bars to compare key metrics across multiple rows; therefore, it is
important that the plotted data points and scales that you use in each instance of the sparkline or data
bar provide a like-with-like comparison.
By default, the plot points and scale that you use in an individual instance of a data bar or sparkline are
consistent only within the chart itself; for example, a sparkline might show that a salesperson named Amy
Alberts had sales in two month of the year and achieved substantially higher sales in one of those months
than she did in the other.

However, if you compare Amy Alberts with another salesperson named David Campbell in the same
report, the plot locations of the months in Amy’s sparkline may not align with the same months in David’s
sparkline, because Amy only started working two months ago, but David has been employed since the
beginning of the year. If the months in the sparkline are not aligned, report viewers cannot make a
month-by-month comparison between the two salespeople. Additionally, the scale that is used to show
the sales volume may vary between the sparklines, so a large value for one month in Amy’s sparkline
might not indicate the same volume of sales as a similarly sized value in David’s sparkline.

To resolve this issue, you can align the horizontal and vertical axes of the charts based on the data
grouping in which the charts are displayed. This ensures that the data is plotted on the same scale for all
instances of the sparkline or data bar in the grouping, which enables like-with-like comparisons.

For More Information For more information about using data bars and sparklines in
reports, see Sparklines and Data Bars (Report Builder 3.0 and SSRS) in SQL Server books
Online.
2-52 Implementing Reports with SQL Server Reporting Services

Using Indicators

Indicators are minimal gauges that you can use to show a particular icon in a report. Indicators are
commonly used to show:

• Trends. For example, you can display an upward-pointing arrow to show a month-on-month increase
in sales or a downward-pointing arrow to show a month-on-month reduction in sales.

• Status and conditions. For example, you can display a green traffic light to show that a salesperson is
on track to meet a sales quota or a red traffic light to show that a salesperson is behind on a quota.

• Ratings. For example, you can display a star that is proportionally filled to show customer satisfaction
levels.

Indicators are a useful way to show how various aspects of the business are performing against key goals
or metrics in a form that users can see quickly.
As a report author, you can use indicators in two ways by choosing the measurement unit on which you
want to base the indicator. The measurement units that you can choose from are:

• Numeric. The indicator icon is based on a numerical value. You must define the range of values to be
used to determine how the indicator will be displayed by specifying a start value and an end value for
each icon in the indicator set. These start and end values can be absolute numbers or they can be
derived at run time from an expression. Numeric indicators are useful when you want to show how a
particular data value compares to a target value—for example, to show how a salesperson’s sales total
compares to a quota.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-53

• Percentage. The indicator icon is based on a percentile across a specified data group. You must
specify the start and end values for each icon in the percentage range (usually 0 to 100), and the
indicator will show the appropriate icon based on where in that percentile range a particular instance
of a data value falls across the grouping. The percentage scale is determined by the minimum and
maximum values that are specified for the indicator. In most cases, this is determined automatically
by taking the lowest value for the specified data field in the grouping as the minimum and the
highest value as the maximum. You can override the minimum and maximum values, in which case
any rows with a value outside the range that you specify will not have an indicator icon displayed.
Percentage indicators are useful when you want to show how rows in a data grouping compare with
one another—for example, to grade salespeople by the volume of sales that they have achieved.

For More Information For more information about using indicators in reports, see
Indicators (Report Builder 3.0 and SSRS) in SQL Server books Online.
2-54 Implementing Reports with SQL Server Reporting Services

Displaying Geographical Data with Maps

You can display geographical data in a report by adding a map. A map consists of one or more map
layers, and each layer can define:

• Spatial data to define the geographical features to be displayed.

• Analytical data to show business values that are related to the spatial data.

• Legends and scales to help viewers interpret the map.


Use the following procedure to add a map to a report:

1. Drag a Map item from the Toolbox to the report body. This starts the New Map Layer wizard.

2. In the New Map Layer wizard, on the Choose a source of spatial data page, select a source for the
spatial data that will be used to define the map. The spatial data for a map layer defines points, lines,
or polygons that represent spatial locations and features. You can obtain the spatial data for a map
layer from:

• The map gallery that is provided with SQL Server Reporting Services. This contains a number of
maps of the United States.
• An Environmental Systems Research Institute (ESRI)-compatible shapefile.

• A query that returns spatial data from a SQL Server database.

3. In the New Map Layer wizard, on the Choose spatial data and map view options page, select an
appropriate map resolution and size, and optionally add a Bing Maps layer to overlay the map with
geographical imagery from Bing Maps.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-55

4. In the New Map Layer wizard, on the Choose map visualization page, select the type of map you
want to create. The options available are:

• Basic map. A basic map shows spatial elements with no analytical data. Typically, a basic map
shows polygons that represent geographical areas such as states or sales territories.
• Color analytical map. You can add analytical data to a basic map and use it to format areas in
different colors to represent the analytical values. For example, you can compare sales in multiple
sales territories by coloring or shading each territory based on the sales value.

• Bubble map. You can use different-sized bubbles to indicate analytical values for each area that
the map shows. For example, each sales territory that the map shows can have a bubble at its
center, with the size of the bubble indicating the relative sales volume for that territory.

5. If you choose a map visualization that requires analytical data, on the Choose the analytical dataset
page, select an existing data set or add a new dataset that includes the analytical data you want to
display on the map.

The analytical dataset must include a field in common with the spatial dataset, so that you can relate
each instance of the analytical values to a spatial feature or location. For example, you might define a
map layer that contains spatial data from a Transact-SQL query that returns the ID and geographical
location of each store and analytical data from a query that returns the store ID and total sales. You
can then use the common field (the store ID) to match the analytical data (the total sales) to the
spatial data (the geographical location).
Alternatively, you might create a map layer using a US state map from the map gallery and add an
analytical dataset that includes sales volumes grouped by state code. You can then match the
StateCode field in the analytical dataset to the USPS state code attribute in the US state map dataset.

6. In the New Map Layer wizard, on the Choose color theme and data visualization page, select a
visual theme and specify which field to visualize on the map. For example, you could visualize the
Sales field from an analytical dataset using a color rule that colors states on the map as a shade of
green, yellow, or red depending on the sales volume for each state.

After you have added a map, you can add additional map layers, including Bing Maps imagery, by using
the Map Layer Wizard.

Note Bing Maps layers can only be used when Internet access is available.

For More Information For more information about using maps in reports, see Maps
(Report Builder 3.0 and SSRS) in SQL Server books Online.
2-56 Implementing Reports with SQL Server Reporting Services

Lesson 5
Filtering Reports By Using Parameters

Reports can contain a great deal of data, and often users need to view only a subset of that data. For
example, a sales manager might want to view a report that shows sales results for a specific month or
quarter. You can use parameters to enable users to filter reports by specifying values or ranges for data
values they want to include in the report.
This lesson describes how to use parameters to filter reports and provide a dynamic reporting solution
that empowers business users to focus on the data they need..

After completing this lesson, you will be able to:

• Describe key features of parameters.

• Add parameters to a report.

• Configure report parameters.

• Define available and default values for parameters.

• Use parameters to filter data and in expressions in a report.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-57

Overview of Parameters

Parameters provide a way to make the contents of a report dynamic depending on the parameter values
specified by the user or process requesting the report. Reporting Services supports two kinds of
parameter:

• Report parameters. Parameters that are passed to a report when it is rendered. Report parameters can
be specified by:
• A user viewing the report interactively.

• A setting in a report subscription that delivers reports automatically at a scheduled time.

• A report that contains a parameterized subreport.


• Dataset parameters. Parameters that are passed to a dataset when retrieving data. Dataset
parameters are specified in a query, and are usually used to filter the query results. For example, the
following Transact-SQL query uses a parameter named @Year in the WHERE clause to filter the
results to include only sales that occurred in a specific year.

SELECT SalesOrderNumber, SalesAmount


FROM FactInternetSales
WHERE YEAR(OrderDate) = @Year

Dataset parameters are typically mapped to report parameters, enabling report users to specify the
values that are used to filter the query.
2-58 Implementing Reports with SQL Server Reporting Services

Adding Parameters to a Report

You can add parameters to a report implicitly by creating parameterized dataset queries, or explicitly by
creating a new parameter in the Report Data pane.

Adding a Parameter to a Dataset Query


The easiest way to add a parameter to a report is to specify a parameter in a dataset query. When you do
this, Report Designer automatically defines a dataset parameter for each parameter in the query and a
report parameter mapped to each dataset parameter. The name used for the parameter is derived from
the parameter named specified in the query.
For example, a dataset based on the following query would result in a dataset parameter named Year and
a matching report parameter, also named Year.

SELECT SalesOrderNumber, SalesAmount


FROM FactInternetSales
WHERE YEAR(OrderDate) = @Year

Adding a Report Parameter


You can add a report parameter explicitly in the Report Data pane by clicking New and then clicking
Parameter. This enables you to add a report parameter that is not mapped to a dataset parameter. You
can then use this parameter to filter data in a tablix data region or chart by setting the Filter property to
an expression that compares a dataset field value to the parameter value.

Note Using an unmapped report parameter and a Filter expression appears to produce
the same results as using a dataset parameter to filter the query results. However, you
should be aware that a dataset containing a parameterized query retrieves only data that
matches the parameterized condition in the WHERE clause, but an un-parameterized
dataset retrieves all of the data requested by the query, even if that data is then excluded
from the report by a Filter expression. This can affect the performance of the report.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-59

Configuring Parameters

After you have added a report parameter, you must configure the following properties.

• Name – The name of the parameter.


• Prompt – The label displayed in the report rendering user interface.

• Data type – The data type of the parameter. This can be Text, Boolean, Date/Time, Integer, or
Float.
• Allowable values – You can choose to allow a parameter value to be null or blank. You can also
configure a parameter to support multiple values, in which case any expressions referencing the
parameter must treat it as an array and any queries used to filter results based on the parameter must
use the IN operator, as shown in the following example.

SELECT SalesOrderNumber, SalesAmount


FROM FactInternetSales
WHERE YEAR(OrderDate) IN (@Year)

• Visibility – You can choose to hide a parameter or configure it as an internal parameter. Hidden and
internal parameters are useful when the parameter value will be set programmatically by a client
application or when the report will always be used as a subreport and the parameter value will be
specified in the parent report.
2-60 Implementing Reports with SQL Server Reporting Services

Available and Default Parameter Values

You can specify a range of available values for a report parameter and pre-assign a default value so that
the report will render without requiring that the user enter a parameter value first.

For example, a report that shows sales by month might use an Integer parameter named Month to filter
the data to include only sales in the specified months. You could configure the Month parameter so that
the available values are restricted to the numbers 1 to 12, and set a default value that sets the parameter
to the appropriate value for the current month.

You can use the following options to specify available and default values for a report parameter.
• None – The user must explicitly enter a parameter value before the report can be rendered.

• Specify values – The report developer can enter a list of available values and a single default value in
the Report Designer user interface. When the report is rendered, the default value specified by the
developer is used, and users can select from a list of the available values the developer specified.
• Get values from a query – The default or available values are retrieved by a dataset when the report is
requested. The report developer must specify the field in the dataset to use for the default and
available values. A different field can be chosen for the label that users select when choosing from
available values.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-61

Working with Parameters

When you have added parameters to a report, you can map them to dataset parameters to filter the
report data. You can also use them in the following ways:

• Filter a data region or group by setting the Filter property to an expression that compares field
values to parameter values. For example, you could create a report that retrieves the data for all sales,
but filters a table to show only sales for specific products.
• Display a subreport by passing a parameter to show a parent-child hierarchy. For example, you could
create a report that shows the details for a specific sales order based on an OrderID parameter, and
embed it as a subreport in a report that shows all sales.
• Reference parameters in an expression. For example, you could use the following expression to
display a dynamic report title that includes the specified Year parameter value.

="Sales for " & Parameters!Year.Value

Note The Parameters collection referenced in the previous expression is just one of many
property collections that you can use in a report. For example, the Globals collection
contains member properties such as ExecutionTime and PageNumber that you can use to
display contextual information about the report being rendered. For more information, see
Built-in Collections in Expressions (Report Builder and SSRS) in SQL Server Books Online,
2-62 Implementing Reports with SQL Server Reporting Services

Demonstration: Using a Parameter

 Task 1: Add a parameter to a report


1. Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then, in the
D:\10778A\Demofiles\Mod02 folder, run Setup.cmd as Administrator.

2. Double-click ReportsDemo4.sln in the D:\107778A\Demofiles\Mod02 folder to open the solution in


SQL Server Data Tools. Then in Solution Explorer, double-click the Reseller Sales.rdl report.

3. In the Report Data pane, expand Datasets and then right-click the ResellerSales dataset and click
Query.
4. In the Query Designer dialog box, add the following WHERE clause to the existing Transact-SQL
query, and then click OK.

WHERE YEAR(FactResellerSales.OrderDate) = @Year

5. Right-click the ResellerSales dataset and click Dataset Properties. Then in the Dataset Properties
dialog box, on the Parameters tab, note that a dataset property named @Year has been created,
and click OK.

6. In the Report Data pane, expand Parameters and note that a report parameter named Year has been
created.

 Task 2: Configure a parameter


1. In the Report Data pane, right-click the Year report parameter and click Parameter Properties.

2. In the Report Parameter Properties dialog box, on the General tab, in the data type drop-down list,
select Integer. Then click OK.
3. Click the Preview tab and note that the report is not rendered. Then, in the Year text box, type 2004
and click View Report. The report is then rendered with data for sales in 2004.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-63

 Task 3: Set available and default values for a parameter


1. On the Design tab, in the Report Data pane, right-click Datasets and click Add Dataset.

2. In the Dataset Properties dialog box, perform the following steps and then click OK.

• In the Name box type SalesYears.

• Select Use a dataset embedded in my report.

• In the Data Source drop-down list, select AdventureWorksDW.

• Ensure that the Text query type option is selected.

• Enter the following Transact-SQL query.

SELECT DISTINCT YEAR(OrderDate) Year


FROM FactResellerSales
ORDER BY YEAR(OrderDate)

3. Repeat the previous two steps to create a dataset named MostRecentSalesYear that uses the
following Transact-SQL query.

SELECT MAX(YEAR(OrderDate)) MaxYear


FROM FactResellerSales

4. In the Report Data pane, right-click the Year report parameter and click Parameter Properties.
5. In the Report Parameter Properties dialog box, on the Available Values tab, perform the following
steps:

• Select Get values from a query.


• In the Dataset drop-down list, select SalesYears.

• In the Value field drop-down list, select Year.

• In the Label field drop-down list, select Year.


6. On the Default Values tab, perform the following steps. Then click OK.

• Select Get values from a query.

• In the Dataset drop-down list, select MostRecentSalesYear.


• In the Value field drop-down list, select MaxYear.

7. Click the Preview tab and note that the report is rendered using the most recent year (2004). Then, in
the Year drop-down list, select 2003 and click View Report. The report is then rendered with data
for sales in 2003.

8. Close SQL Server Data Tools.


2-64 Implementing Reports with SQL Server Reporting Services

Lesson 6
Publishing and Viewing a Report

When you have finished creating your reports, you must typically publish them to a report server so that
users can view them. Professional report developers using Report Designer in SQL Server Data Tools can
publish reports at the project level or publish individual reports as required. Before publishing your
reports, you must be aware of the effect of project properties on how reports are published.
After completing this lesson, you will be able to:

• Set Report Server project properties and publish reports.


• View a published report.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-65

Reporting Services Project Properties

Before you publish reports you have created in SQL Server Data Tools, you must ensure that the following
properties are set appropriately for the report server where you intend to publish them.

Property Description

OverwriteDataSources Specifies whether to replace existing data sources when publishing shared
data sources. If this property is set to False, an attempt to publish a data
source with the same name as an existing data source will fail.

TargetDataSetFolder Folder where shared datasets are published. When publishing to a report
server in native mode, this property should be set to the name of the
folder. When publishing to a report server in SharePoint integrated mode,
this property should be set to the full URL for the document library in the
SharePoint site.

TargetDataSourceFolder Folder where shared data sources are published. When publishing to a
report server in native mode, this property should be set to the name of
the folder. When publishing to a report server in SharePoint integrated
mode, this property should be set to the full URL for the document library
in the SharePoint site.

TargetReportFolder Folder where reports are published. When publishing to a report server in
native mode, this property should be set to the name of the folder. When
publishing to a report server in SharePoint integrated mode, this property
should be set to the full URL for the document library in the SharePoint
site.

TargetReportPartFolder Folder where report parts are published. When publishing to a report
server in native mode, this property should be set to the name of the
folder. When publishing to a report server in SharePoint integrated mode,
this property should be set to the full URL for the document library in the
SharePoint site.
2-66 Implementing Reports with SQL Server Reporting Services

(continued)

Property Description

TargetServerURL Service endpoint for the report server. When publishing to a report server
in native mode, this property should be set to URL for the report server
web service. When publishing to a report server in SharePoint integrated
mode, this property should be set to the URL for the SharePoint site where
you want to publish the reports.

TargetServerVersion Compatibility version for reports. The RDL format used by Reporting
Services in SQL Server 2008 R2 and later is different from the RDL format
used in earlier versions. If you are publishing to an older report server, you
must set the TargetServerVersion appropriately. You can publish reports
in either version to report servers running SQL Server 2008 R2 or later, but
some report features are not supported in the older RDL format.

After you have set the project properties, you can publish the reports, shared data sources, and shared
datasets in the project. To publish all items in the project, right-click the project in Solution Explorer and
click Deploy, or on the Build menu, click Deploy Project_name. To publish an individual item in the
project, right-click the item in Solution Explorer and click Deploy.

When you deploy a project or an individual item, the deployment status is shown in the Output pane.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-67

Viewing a Report

After a report has been deployed, users can view the report by performing the following steps.

1. Open a web browser and navigate to the report location.


If the report has been published to a report server running in native mode, the user must navigate to
the Report Manager site, and if necessary enter appropriate authentication credentials. If the report
has been published to a report server in SharePoint integrated mode, the user must navigate to the
document library in the SharePoint site where the reports have been published.

2. Click the report. If the report has no parameters, or all parameters have default values, the report will
be rendered in the browser.

3. Enter parameter values to filter the report as required, and click View Report to render the report
with the specified parameters.
4. Use the Report Viewer toolbar to navigate the report by scrolling through report pages or searching
the report for a specified text value.

5. Export the report to a file or click the feed icon to download the report as an atom feed.
2-68 Implementing Reports with SQL Server Reporting Services

Demonstration: Publishing a Report

 Task 1: Configure a report project


1. Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then, in the
D:\10778A\Demofiles\Mod02 folder, run Setup.cmd as Administrator.

2. Double-click ReportsDemo5.sln in the D:\107778A\Demofiles\Mod02 folder to open the solution in


SQL Server Data Tools.

3. In Solution Explorer, right-click the ReportDemo5 project and click Properties. Then set the
following properties and click OK:
• TargetDatasetFolder: http://mia-sqlbi/reports/demo/datasets

• TargetdataSourceFolder: http://mia-sqlbi/reports/demo/datasources

• TargetReportFolder: http://mia-sqlbi/reports/demo
• TargetReportPartFolder: http://mia-sqlbi/reports/demo/reportparts

• TargetServerURL: http://mia-sqlbi

 Task 2: Deploy a report project


1. On the Build menu, click Deploy ReportsDemo5.

2. Observe the deployment progress in the status bar and the Output pane.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-69

 Task 3: View a published report


1. When deployment has succeeded, close SQL Server Data Tools, start Internet Explorer, and browse to
the SharePoint site at http://mia-sqlbi.

2. Under Libraries, click Reports. Then in the Reports document library, click the demo folder.
3. Click the Reseller Sales report and note that it is rendered in the SharePoint interface.

4. In the Parameters pane, in the Year drop-down list, select 2003, and click Apply. The report is
rendered again with the data for sales in 2003.

5. In the Actions menu, point to Export, and click Excel. When prompted, save the report as Reseller
Sales.xlsx in the D:\107778A\Demofles\Mod02 folder—replacing the file if it already exists.

6. When the file has downloaded, click Open to view it in Excel.

7. Close Excel and Internet Explorer.


2-70 Implementing Reports with SQL Server Reporting Services

Lab Scenario

The sales manager at Adventure Works Cycles has reviewed the sales report you have created, and
requested the following enhancements:

• The report should include a chart on the first page to summarize sales by month for each product
category - providing a visual “executive summary”. To accomplish this, you will add a chart to the
report in the space above the tablix data region.
• Users should be able to filter the report by year, and see sales figures only for the specified year. To
accomplish this you will modify the query in the dataset used to retrieve the data to include a where
clause that filters based on a year. You will then add a parameter to the report with an appropriate
default value and list of available values.

• Users should be able to view the report on-demand in the company’s SharePoint site. To accomplish
this, you will publish the report to a document library in a SharePoint site where Reporting Services is
installed in SharePoint integrated mode.

• If time permits, the sales manager would like a report that shows a visual comparison of total sales
and monthly sales trend for product categories.

• If time permits, the sales manager would also like a report that shows sales by US state as a map.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-71

Lab 2B: Enhancing and Publishing a Report

Exercise 1: Adding a Chart to a Report


Scenario
The sales manager at Adventure Works has requested that you add a chart to first page of the sales
report. The chart should show sales volumes for each product category across months of the year.
The main tasks for this exercise are as follows:

1. Prepare the lab environment.


2. Open the AWReports project.
3. Add a Chart report item.

4. Specify the data for the chart.

5. Format the chart.

 Task 1: Prepare the lab environment


• Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab02B\Starter
folder as Administrator.

 Task 2: Open the AWReports project


• Open the AWReports solution in the D:\10778A\Labfiles\Lab02B\Starter\Ex1 folder with SQL Server
Data Tools.
• View the Sales Report report.
2-72 Implementing Reports with SQL Server Reporting Services

 Task 3: Add a Chart report item


• Move the existing tablix data region down to make room for the chart.

• Add a chart to the report above the tablix data region. The chart should be a 3D clustered column
chart, and you should resize it to fit the space above the tablix data region.

 Task 4: Specify the data for the chart


• Configure the chart with the following data fields:

• Values: SalesAmount

• Category Groups: Month

• Series: ProductCategory

• Edit the properties of the Month field in the Category Groups section so that the group is sorted by
the MonthNo field.

 Task 5: Format the chart


• Edit the chart properties and change the Color palette property to Semi transparent.
• Delete the chart title

• Format the vertical axis so that the numbers are formatted as currency with a separator for thousands.
• Preview the report and verify that the chart looks like this.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-73

• Export the report to a Microsoft Excel workbook named Sales Report.xlsx in the
D:\10778A\Labfiles\Lab02A\Starter\Ex2 folder.

• Open the chart in Excel and verify that the first worksheet includes the chart you created. Then close
SQL Server Data Tools and Excel.

Results: After this exercise, you should have a report that includes a chart.
2-74 Implementing Reports with SQL Server Reporting Services

Exercise 2: Adding Parameters to a Report


Scenario
The report you have created for the sales manager currently shows sales grouped by month, but the data
is not filtered to any particular year. This means that the chart shows the total sales for each month
regardless of what year the sale occurred in. You must add a parameter to the report so that the sales
manager can filter the report to include the years they want to view, with a default value that ensures the
report only shows sales for the most recent sales year.

The main tasks for this exercise are as follows:


1. Open the AWReports project.

2. Add a parameter.

3. Configure available and default values for a parameter.

 Task 1: Open the AWReports project


• Open the AWReports solution in the D:\10778A\Labfiles\Lab02B\Starter\Ex2 folder with SQL Server
Data Tools.

• View the Sales Report report.

 Task 2: Add a parameter


• In the Report Data pane, edit the query for the Sales dataset so that it matches the following
Transact-SQL query. You can import this query from D:\10778A\Labfiles\Lab02B\Starter\Ex2\
Parameterized Sales Query.sql:

SELECT d.CalendarYear [Year],


d.MonthNumberOfYear [MonthNo],
d.EnglishMonthName [Month],
c.EnglishProductCategoryName [ProductCategory],
s.EnglishProductSubcategoryName [ProductSubcategory],
p.EnglishProductName [Product],
i.SalesOrderNumber,
i.OrderDate,
i.SalesAmount
FROM dbo.DimProductCategory c
INNER JOIN dbo.DimProductSubcategory s ON s.ProductCategoryKey = c.ProductCategoryKey
INNER JOIN dbo.DimProduct p ON p.ProductSubcategoryKey = s.ProductSubcategoryKey
INNER JOIN dbo.FactInternetSales i ON i.ProductKey = p.ProductKey
INNER JOIN dbo.DimDate d ON i.OrderDateKey = d.DateKey
WHERE d.CalendarYear IN (@Year)
ORDER BY d.CalendarYear, d.MonthNumberOfYear, c.EnglishProductCategoryName,
s.EnglishProductSubcategoryName, p.EnglishProductName, i.SalesOrderNumber

• Edit the Year report parameter created when the dataset query was updated so that is has a data
type of Integer allows multiple values.

• Edit the textbox containing the report title so that is contains the following expression:

="Sales Report for " & Join(Parameters!Year.Value, ", ")

• Preview the report and verify that you can specify multiple year values in the parameter box by typing
2003, inserting a new line, and typing 2004. Click View Report to render the report with the
parameter values.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-75

 Task 3: Configure available and default values for a parameter


• In the Report Data pane, add a dataset named SalesYears. The data set should be embedded in the
report and use the following query (which you can import from
D:\10778A\Labfiles\Lab02B\Starter\Ex2\Sales Years.sql):

SELECT DISTINCT YEAR(OrderDate) [Year]


FROM FactInternetSales
ORDER BY YEAR(OrderDate) DESC

• Add another embedded dataset named MaxYear that uses the following query (which you can
import from D:\10778A\Labfiles\Lab02B\Starter\Ex2\Max Years.sql):

SELECT YEAR(MAX(OrderDate)) [MaxYear]


FROM FactInternetSales

• Edit the properties of the Year report parameter to get the available values from the SalesYears
dataset and the default value from the MaxYear dataset.
• Preview the report and verify that the default parameter is used to render the report for the current
year, and that you can select one or more years from the available values in the Year parameter
drop-down list.

• Close SQL Server Data Tools.

Results: After this exercise, you should have a report that includes a parameter with default and available
values based on datasets that retrieve data from a database.
2-76 Implementing Reports with SQL Server Reporting Services

Exercise 3: Publishing a Report


Scenario
You have created a report for the sales manager, and must now deploy it to the report server, which is
installed in SharePoint Integrated mode.

The main tasks for this exercise are as follows:


1. Open the AWReports project.

2. Configure deployment properties.

3. Deploy the AWReports project.

 Task 1: Open the AWReports project


• Open the AWReports solution in the D:\10778A\Labfiles\Lab02B\Starter\Ex3 folder with SQL Server
Data Tools.

• View the Sales Report report.

 Task 2: Configure deployment properties


• Set the following properties for the AWReports project:
• OverwriteDatasets: True

• OverwriteDataSources: True
• TargetDatasetFolder: http://mia-sqlbi/Reports/Datasets
• TargetDataSourceFolder: http://mia-sqlbi/Reports/Data Sources

• TargetReportFolder: http://mia-sqlbi/Reports
• TargetReportPartFolder: http://mia-sqlbi/Reports/Report Parts
• TargetServerURL: http://mia-sqlbi

• TargetServerVersion: SQL Server 2008 R2 or later

 Task 3: Deploy the AWReports project


• Deploy the project, and monitor the deployment status in the Output window.
• When the project has been successfully deployed, close SQL Server Data Tools and use Internet
Explorer to browse to the SharePoint site at http://mia-sqlbi.

• In the Quick Launch area, under Libraries, click Reports.


• In the Reports library, click Sales Report and note that the report is displayed with the default
parameter value.

• Export the report to a Microsoft Excel workbook named Sales Report.xlsx in the
D:\10778A\Labfiles\Lab02A\Starter\Ex2 folder.

• Open the chart in Excel and verify that the first worksheet includes the chart you created. Then close
Internet Explorer and Excel.

Results: After this exercise, you should have configured and deployed a Report Server project.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-77

Optional Exercise: Using Data Bars and Sparklines


Scenario
The sales manager wants to be able to easily compare sales by product category. You must create a report
that shows a visual comparison of total sales for the year and a comparison that shows the trend for sales
of each category across the year.

The main tasks for this exercise are as follows:


1. Open the AWReports project.

2. Add a data bar.

3. Add a spark line.

 Task 1: Open the AWReports project


• Open the AWReports solution in the D:\10778A\Labfiles\Lab02B\Starter\Opt1 folder with SQL Server
Data Tools.
• View the Sales Trends report.

 Task 2: Add a data bar


• Modify the report to include a Sales Volume: label and a data bar as shown here,

• You will need to add the SalesAmount field to the Values section in the Chart Data pane.

• Configure the series properties of the SalesAmount field to use the following fill options.
• Fill style: Gradient

• Color: Light Steel Blue


• Secondary color: Cornflower Blue

• Gradient Style: Left right


2-78 Implementing Reports with SQL Server Reporting Services

• Configure the horizontal axis properties of the SalesAmount field so that the axes are aligned at the
table1 scope.

• Ensure that the data bar does not have a border.


• When you preview the report, it should show a data bar that indicates the relative sales volume for
each product category, as shown here.

 Task 3: Add a sparkline


• Modify the report to include a Monthly Trend: label and a sparkline as shown here.

• Add the SalesAmount field to the Values area of the Chart Data window for the sparkline, and
select the MonthNumberOfYear field in the Category Groups section.

• Configure the series properties of the SalesAmount field to use the following fill options.

• Fill style: Gradient


• Color: Light Steel Blue

• Secondary color: Cornflower Blue


• Gradient Style: Top bottom

• Configure both the horizontal axis and the vertical axis so that they are aligned at the table1 scope.

• Ensure that the data bar does not have a border.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-79

• When you preview the report, it should show a sparkline that shows the sales trend for each category
across the year, as shown here.

Results: After this exercise, you should have created a report that uses a data bar and a sparkline to show
a visual comparison of sales by product category.
2-80 Implementing Reports with SQL Server Reporting Services

Optional Exercise: Using a Map


Scenario
You have created a report that lists sales totals for each US state. The sales manager has requested that
the report show these sales values visually on a map.

The main tasks for this exercise are as follows:


1. Open the AWReports project.

2. Add a map.

3. Format the map.

 Task 1: Open the AWReports project


• Open the AWReports solution in the D:\10778A\Labfiles\Lab02B\Starter\Opt2 folder with SQL Server
Data Tools.

• View the US Sales By State report.

 Task 2: Add a map


• Drag a Map item from the toolbox to the report body and complete the New Map Layer wizard
using the following settings:

• On the Choose a source of spatial data, ensure Map gallery is selected and in the Map Gallery
pane, select USA by State Insert. Then click Next.

• On the Choose spatial data and map view options page, review the default settings and click
Next.
• On the Choose map visualization page, select Color Analytical Map and click Next.
• On the Choose the analytical dataset page, select Sales and click Next.

• On the Specify the match fields for spatial and analytical data page, select the checkbox for
the STATENAME field, and in the Analytical Data Fields column, select StateProvinceName.
Then click Next.

• On the Choose color theme and data visualization page, in the Theme drop-down list, select
Ocean; in the Field to visualize drop-down list, select [Sum(SalesTotal)]; and in the Color rule
drop-down list, select White-Blue. Then click Finish.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-81

 Task 3: Format the map


• Click the map to display the Map Layers pane (you might need to scroll to the right to see the Map
Layers pane as shown here), and modify the properties of the map as described below.

• Set the polygon properties of the PolygonLayer1 layer so that [Sum(SalesTotal)] is displayed as a
tooltip.

• Set the polygon color rule of the PolygonLayer1 layer so that the color of each state is displayed
with the following distribution.

• Number of subranges: 10

• Range start: 0
• Modify the properties of the legend above the color distribution legend at the top right to change
the title text to Sales ($).

• Change the map title to Sales by State.

• Remove the color scale at the bottom left.


2-82 Implementing Reports with SQL Server Reporting Services

• When you preview the report, the map should indicates sales volume in each state by the shade of
the color used to fill the state and display tooltips for each state that show the actual sales amount as
shown in the following image.

Results: After this exercise, you should have created a report that shows sales by US state on a map.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 2-83

Module Review and Takeaways

Review Questions
1. As a professional BI developer, what tool should you generally use to create and maintain reports?
2. You need to create a report in which users can view a summary of sales totals for each month of the
year and drilldown into the individual sales for each month. How can you achieve this?

3. You want to show a graphical representation of a company’s profit for the year to-date compared to
the target that was set at the beginning of the year. How can you achieve this?
3-1

Module 3
Supporting Self Service Reporting
Contents:
Lesson 1: Introduction to Self Service Reporting 3-3

Lesson 2: Shared Data Sources and Datasets 3-11


Lesson 3: Report Parts 3-22

Lab 3: Implementing Self Service Reporting 3-32


3-2 Supporting Self Service Reporting

Module Overview

Business users depend on information to make business decisions in a timely manner. However, as the
volume and variety of business data used to make those decisions grows, relying on the IT department or
BI specialists to create reports introduces a bottleneck into ongoing business processes that can frustrate
business users and prevent business agility. As a result, many organizations seek to empower their
business users to create the reports they need for themselves in a self-service fashion.
This module describes Microsoft® SQL Server® Reporting Services features that you can use to enable
self-service reporting. After completing this module, you will be able to:

• Support self-service reporting with Report Builder.

• Create shared data sources and datasets for self-service reporting scenarios.

• Use report parts as reusable report elements.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-3

Lesson 1
Introduction to Self Service Reporting

As a BI professional, you will often be required to create reports for business users. Increasingly however,
organizations are empowering users to create their own reports, and you must be able to support these
self-service reporting scenarios by ensuring that users can access appropriate report authoring tools.
This lesson discusses self-service reporting scenarios and introduces Report Builder, a report authoring
tool that is specifically designed for business users. After completing this lesson, you will be able to:

• Describe the features and benefits of self-service reporting scenarios.


• Use report builder to create a report.
• Plan the deployment of Report Builder to business users.
3-4 Supporting Self Service Reporting

Self Service Reporting Scenarios

Businesses today have access to increasing volumes of data, which business users must use to make ever
faster decisions in day-to-day business operations. Additionally, business users are increasingly familiar
with technology and adept at using it to perform their jobs. While complex report authoring and delivery
is a task that is best suited to IT and BI professionals, many organizations are adopting self-service
reporting solutions that take advantage of the available business data and IT 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 they need to make informed decisions without
waiting for an IT professional to create a report.
• Supplement standard reports created by the IT department 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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-5

Report Builder

While Report Designer in SQL Server Data Tools provides a comprehensive report authoring environment
for BI specialists, it includes many features that are relevant only to professional developers. Business users
who are more familiar with productivity software packages, such as Microsoft Office applications, can find
the Microsoft Visual Studio® interface of SQL Server Data Tools distracting or even intimidating.

Report Builder is a report authoring tool that combines many of the features of Report Designer with the
familiar ribbon-based interface of Microsoft Office. It is designed specifically for business users, and is the
primary report authoring tool for self-service reporting scenarios. With Report Builder, business users can
create and edit reports as easily as they can work with other kinds of business document, and publish their
reports to Report Manager or Microsoft SharePoint® document libraries.

Report Builder supports the same report features as Report Designer, including:

• Rich formatting.
• Tablix data regions for table, matrix, and list reports.

• Groups, aggregations, and drill-down interactions.


• Charts and images.

• Parameters.
3-6 Supporting Self Service Reporting

Deploying Report Builder

There are two versions of Report Builder that you can provide to business users. The two versions are
functionally identical – the only difference between them is the way in which they can be deployed.

The ClickOnce Version of Report Builder


Users can install the ClickOnce version of Report Builder from Report Manager or a document library in a
SharePoint site where Reporting Services is installed in SharePoint integrated mode. The application uses
Microsoft .NET ClickOnce technology to install Report Builder on-demand when a user creates or edits a
report.
To enable users to install the ClickOnce version of Report Builder, the .NET Framework 2.0 or greater must
be installed on the user’s computer. Additionally, the report server must be configured to enable
ClickOnce installation of Report Builder. By default, ClickOnce installation of Report Builder is enabled,
and you can modify this setting by:

• Setting the EnableReportDesignClientDownload property on the Advanced tab of the report


server properties dialog box in SQL Server Management Studio.
• Modifying the Enable Report Builder download setting in the System Settings page for the
Reporting Services service application in SharePoint Central Configuration when Reporting Services is
installed in SharePoint Integrated mode.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-7

By default, Reporting Services enables users to download Report Builder 3.0, which is the version of Report
Builder that ships with SQL Server 2012 Reporting Services, from the report server instance they are
currently connected to. However, you can specify an alternative URL for Report Builder to provide a
centralized download location or to support a later release of Report Builder. To set a custom URL for
Report Builder installation:

• Set the ReportBuilderLaunchURL property on the Advanced tab of the report server properties
dialog box in SQL Server Management Studio.
• Enter the URL in the Report Builder Launch URL textbox in the System Settings page for the
Reporting Services service application in SharePoint Central Configuration.

Note To install Report Builder from Report Manager or a SharePoint document library,
users must have sufficient permissions. In Native mode, you can add users to the Content
Manager or Report Builder role to grant them permission to install Report Builder. In
SharePoint Integrated mode, you must grant users Contribute or Full Control permission
on a document library that supports the Report Builder Report content type.

The Standalone Version of Report Builder


Report Builder is available in a standalone version that is installed from a Microsoft Installer (.msi) package
file. You can use the following techniques to deploy the standalone version of Report Builder to business
users who need to create reports:
• Have each user download the installer package for Report Builder from the Microsoft Download
Center, and install it.
• Download the installer package for Report Builder and place it on an internal network share from
which business users can install it.

• Use an enterprise software management solution, such as Microsoft System Center Essentials 2010 to
push Report Builder to business user workstations.
3-8 Supporting Self Service Reporting

Demonstration: Using Report Builder

 Task 1: Use Report Builder to create a report


1. Ensure MIA-DC1 and MIA-SQLBI are started, and log onto MIA-SQLBI as ADVENTUREWORKS
\Student with the password Pa$$w0rd. Then in the D:\10778A\Demofiles\Mod03 folder, run
Setup.cmd as Administrator.

2. Start Internet Explorer and browse to the Reports document library in the SharePoint site at
http://mia-sqlbi.

3. In the ribbon, on the Documents tab, in the New Document drop-down list, click Report Builder
Report. If you are prompted to install Report Builder, click Run, and wait for Report Builder to be
downloaded. The application starts automatically after it has been downloaded.
4. In the Getting Started dialog box, ensure that New Report is selected and click Table or Matrix
Wizard.

5. On the Choose a dataset page, ensure Create a dataset is selected, and click Next.
6. On the Choose a connection to a data source page, click New, and in the Data Source Properties
dialog box, create a data source with the following settings and click OK. Then click Next.

• On the General tab, change the Name property to AdventureWorksDW, ensure that the
Microsoft SQL Server connection type is selected, and enter the following connection string.

Data source=localhost;Initial Catalog=AdventureWorksDW

• On the Credentials tab, ensure that the Use current Windows user. Kerberos delegation
might be required option is selected.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-9

7. On the Design a query page, in the Database view pane, expand Tables, expand the
DimGeography, DimDate, DimCustomer, and FactInternetSales tables, and select the following
fields:

• DimDate.CalendarYear
• DimDate.MonthNumberOfYear

• DimDate.EnglishMonthName

• DimGeography.EnglishCountryRegionName
• DimCustomer.GeographyKey

• FactInternetSales.CustomerKey
• FactInternetSales.OrderDateKey

• FactInternetSales.SalesAmount

8. After you have selected the fields, click Run Query and note that no rows are returned. Then expand
the Relationships pane, review the relationships that have been automatically detected, and note that
the FactInternetSales table is joined to the DimDate table on three fields (OrderDateKey,
DueDateKey, and ShipDateKey).

9. Click Edit as Text and modify the query to remove the AND clauses that join the FactInternetSales
table to the DimDate table on the DueDateKey and ShipDateKey columns and click the Run button
to verify that the query now returns data. Then click Next.

Note This step highlights the fact that some knowledge of query syntax may be required
to define a dataset for a report. In a self-service reporting scenario, some users may not
have this knowledge. Later in this module, the use of shared data sources and datasets to
overcome this problem is discussed.

10. On the Arrange fields page, drag and drop the fields to the following groups and then click Next.

• Row groups

EnglishCountryRegionName

• Column groups
CalendarYear

EnglishMonthName
• Values

SalesAmount

11. On the Choose the layout page, ensure that Show subtotals and grand totals and
Expand/collapse groups are all selected, and then click Next.

12. On the Choose a style page, in the Styles list, select Generic. Then click Finish.

13. In the Click to add title text box, type Sales Report. Then click Run to preview the report, and then
click Design and widen columns as necessary.
3-10 Supporting Self Service Reporting

 Task 2: Publish a report from Report Builder


1. In the quick access toolbar, click Save. Then in the Save As Report dialog box, browse to the
http://mia-sqlbi/Reports folder, in the Name box type Demo Sales Report.rdl, and click Save.

2. Close Report Builder.


3. In Internet Explorer, in the Quick Launch area of the http://mia-sqlbi SharePoint site, under Libraries,
click Reports to refresh the view and note that Demo Sales Report has been published in the
Reports document library. Then click Demo Sales Report and view the report.

 Task 3: Use Report Builder to edit an existing report


1. When viewing the report, at the top of the page click the Reports link to return to the Reports
document library. Then, on the drop-down menu for Demo Sales Report, click Edit in Report
Builder.

2. Click the cell containing the expression [Sum(SalesAmount)] directly beneath the
[EnglishMonthName] cell, and then hold the Shift key and click the [Sum(SalesAmount)] field at
the bottom right of the tablix data region to select all of the [Sum(SalesAmount)] cells. Then on the
toolbar, click the currency ($) format button.
3. In the Groupings pane, in the EnglishMonthName group drop-down list, click Group Properties.
Then on the Sorting tab, change the Sort by field to MonthNumberOfYear so that the months are
sorted in calendar order, and click OK. Then, in the quick access toolbar, click Save. Then close Report
Builder.

4. In Internet Explorer, in the Reports document library, click Demo Sales Report to view the report
and note that your changes have been published to the report server. Then close Internet Explorer.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-11

Lesson 2
Shared Data Sources and Datasets

Report Builder provides a report authoring environment that makes it easy for business users to create
their own reports. However, many business users are unfamiliar with the details of accessing data in
database servers and using query syntax to retrieve the data they need. In a self-service reporting solution,
you may want to provide a layer of abstraction that eliminates the need for users to define connection
strings or Transact-SQL queries and enable them to focus on creating reports that are based on data items
that you provide.
This lesson describes how you can use shared data sources and shared datasets to provide reusable data
items on which business users can base their reports. After completing this lesson, you will be able to:

• Describe how shared data items can support a self-service reporting solution.

• Create shared data sources and use them in reports.


• Create shared datasets and use them in reports.
3-12 Supporting Self Service Reporting

Using Shared Data Items for Self Service Reporting

Reporting Services provides two data items that you can reuse across multiple reports and authors. By
creating shared data sources and datasets, BI developers can create a layer of abstraction between report
authors and the databases or other sources where data for reports is stored. This layer of abstraction
eliminates the need for business users to learn connection string or query syntax and makes it easier to
support a self-service reporting solution.

Shared Data Sources


Shared data sources provide a way to define the connection details for a source of data such as a
database once, and reuse them across multiple reports. Shared data sources are published as individual
items in a report server and can then be used by multiple authors when creating reports.

In a self-service reporting scenario, an IT or BI specialists can create a shared data source and publish it to
a report server. Business user can then specify that the shared data source should be used when creating
reports with Report Builder. Depending on the security requirements of the organization, you can include
specific authentication credentials in the data source, or you can configure the data source to use
integrated authentication based on the identity of the user creating or viewing reports that are based on
it.

Note Shared data sources are not exclusively designed for self-service reporting solutions.
They can be useful in any scenario where multiple reports must access the same data
source.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-13

Shared Datasets
Shared datasets provide a way to define reusable queries for data to be displayed in reports or used as
parameter values. A BI specialist can create shared datasets for commonly used reporting data, and
business users can then use these datasets when creating reports with Report Builder. Shared datasets can
include parameters so that business users can filter the data to suit the requirements of a particular report
or create parameterized reports.
3-14 Supporting Self Service Reporting

Creating Shared Data Sources

You can create a shared data source in a report server project in SQL Server Data Tools, or in a report
manager folder or SharePoint document library.

Creating a Shared Data Source in SQL Server Data Tools


To create a shared data source in a report server project in SQL Server Data Tools, you can use one of the
following techniques:
• In Solution Explorer, right-click the Shared Data Sources folder and click Add New Data Source.

• Right click any folder in Solution Explorer or the Project menu, and click Add New Item. Then add a
new item based on the Data Source template.
• When using the Report Wizard to creating a report, on the Select the Data Source page, create a
new data source and select the Make this a shared data source checkbox.

• In the Report Data pane, right-click an existing data source that is embedded in a report and click
Convert to Shared Data Source.

After you have added a shared data source to a project, you can publish it to a report server. The specific
folder or document library that the data source is published to depends on the settings you have
configured in the project properties, where you can also control whether or not to overwrite the data
source if it already exists on the server.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-15

Creating a Shared Data Source in Report Manager or a SharePoint Site


You can create and manage shared data sources in Report Manager or a SharePoint document library. To
create a shared data source:

• In Report Manager, click New Data Source in any folder in which you have Manage data sources
permission.

• In a SharePoint document library that supports the Report Data Source content type, on the
Documents tab of the ribbon, in the New Document drop-down list click Report Data Source.

You can view and modify the settings for any shared data source in Report Manager or SharePoint Server,
and you can view its dependent items to identify datasets and reports that use it.
3-16 Supporting Self Service Reporting

Demonstration: Using a Shared Data Source

 Task 1: Create a shared data source


1. Ensure MIA-DC1 and MIA-SQLBI are started, and log onto MIA-SQLBI as ADVENTUREWORKS
\Student with the password Pa$$w0rd. Then in the D:\10778A\Demofiles\Mod03 folder, run
Setup.cmd as Administrator.

2. Start Internet Explorer and browse to the Reports document library in the SharePoint site at
http://mia-sqlbi.

3. In the ribbon, on the Documents tab, in the New Document drop-down list, click Report Data
Source.
4. In the Data Source Properties page, configure a data source with the following settings and click
OK.

• Name: Demo Adventure Works DW


• Data Source Type: Microsoft SQL Server

• Connection string: Data source=localhost;Initial Catalog=AdventureWorksDW

• Credentials: Windows authentication (integrated) or SharePoint user


• Availability: Enable this data source selected

 Task 2: Use a shared data source in a report


1. In the ribbon, on the Documents tab, in the New Document drop-down list, click Report Builder
Report.

2. When Report Builder starts, in the Getting Started dialog box, select New Report and click Table or
Matrix Wizard.

3. On the Choose a dataset page, ensure Create a dataset is selected, and click Next.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-17

4. On the Choose a connection to a data source page, click Browse and browse to the http://mia-
sqlbi/Reports folder. Then select the Demo Adventure Works DW.rsds shared data source you
created in the previous task and click Open. Then ensure that the Demo Adventure Works
DW.rsds data source is selected, and click Next.

5. On the Design a query page, in the Database view pane, expand Tables, expand the
DimCustomer, DimGeography, and FactInternetSales tables, and select the following fields:
• DimGeography.EnglishCountryRegionName

• DimCustomer.GeographyKey

• FactInternetSales.CustomerKey
• FactInternetSales.SalesAmount

6. Expand the Relationships pane, review the relationships that have been automatically detected. Then
click Next.
7. On the Arrange fields page, drag and drop the fields to the following groups and then click Next.

• Row groups

EnglishCountryRegionName
• Values
SalesAmount

8. On the Choose the layout page, ensure that Show subtotals and grand totals is selected, and then
click Next.
9. On the Choose a style page, in the Styles list, select any style. Then click Finish.

10. In the Report data pane, expand Data Sources and then right-click the data source used by the
report and click Data Source Properties. Note that the data source is a reference to the Demo
Adventure Works DW.rsds shared data source you created earlier, and then click OK.

11. Format the report as necessary—for example, format the [Sum(SalesAmount)] fields as currency and
widen the columns.
12. Click Run to preview the report, and then close Report Builder without saving the report. Then close
Internet Explorer.
3-18 Supporting Self Service Reporting

Creating Shared Datasets

You can create a shared dataset with SQL Server Data Tools or Report Builder, and then publish it to a
report server. You can then manage the shared datasets that you have published in Report Manager or
SharePoint Server.

Creating a Shared Dataset in SQL Server Data Tools


To create a shared dataset in a report server project in SQL Server Data Tools, you can use one of the
following techniques:

• In Solution Explorer, right-click the Shared Datasets folder and click Add New Dataset.

• Right click any folder in Solution Explorer or the Project menu, and click Add New Item. Then add a
new item based on the Dataset template.

• In the Report Data pane, right-click an existing dataset that is embedded in a report and click
Convert to Shared Dataset.
After you have added a shared dataset to a project, you can publish it to a report server. The specific
folder or document library that the dataset is published to depends on the settings you have configured
in the project properties, where you can also control whether or not to overwrite the dataset if it already
exists on the server.

Creating a Shared Dataset in Report Builder


To create a shared dataset with Report Builder, you can use one of the following techniques.
• On the Getting Started dialog box, click New Dataset and select a shared data source on which to
base the shared dataset.

• On the Report Builder menu, click New. Then in the New Report or Dataset dialog box, click New
Dataset and select a shared data source on which to base the shared dataset.

After you have created the shared dataset, you can save it to a folder in a report server.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-19

Managing a Shared Dataset


You can view and modify the settings for any shared dataset in Report Manager or SharePoint Server, and
you can view its dependent items to identify reports that use it.
3-20 Supporting Self Service Reporting

Demonstration: Using a Shared Dataset

Note This demonstration requires that you have completed the previous demonstration in
this module. If you have not done so, you must create a shared data source named Demo
Adventure Works DW.rsds that connects to the AdventureWorksDW database in the
localhost instance of SQL Server.

 Task 1: Create a shared dataset


1. Ensure MIA-DC1 and MIA-SQLBI are started, and log onto MIA-SQLBI as ADVENTUREWORKS
\Student with the password Pa$$w0rd. Then in the D:\10778A\Demofiles\Mod03 folder, run
Setup.cmd as Administrator.

2. Start Internet Explorer and browse to the Reports document library in the SharePoint site at
http://mia-sqlbi.

3. In the ribbon, on the Documents tab, in the New Document drop-down list, click Report Builder
Report.
4. When Report Builder starts, in the Getting Started dialog box, select New Dataset and select the
Demo Adventure Works DW.rsds data source you created in the previous demo. If Demo
Adventure Works DW.rsds is not listed, click Browse other data sources and browse to the
http://mia-sqlbi/Reports folder. Then select the Demo Adventure Works DW.rsds shared data
source and click Open. When you have selected the Demo Adventure Works DW.rsds data source,
click Create.

5. On the ribbon, in the Query Designer section, click Import. Then browse to the
D:\10778A\Demofiles\Mod03 folder, select Internet Sales.sql, and click Open.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-21

6. On the ribbon, click the Run button. When the query has completed, review the results, which show
Internet sales data.

7. In the quick access toolbar, click Save. Then in the Save As Dataset dialog box, browse to the
http://mia-sqlbi/Reports folder, in the Name box type Demo Internet Sales.rsd, and save the
dataset.

 Task 2: Use a shared dataset in a report


1. Click the round button at the top left of the ribbon, and on the Report Builder menu, click New.
Then in the New Report or Dataset dialog box, select New Report and click Table or Matrix
Wizard.

2. On the Choose a dataset page, select Choose an existing dataset in this report or a shared
dataset, click Browse and in the http://mia-sqlbi/Reports folder, click Demo Internet Sales.rsd and
click Open. Then click Next.

3. On the Arrange fields page, drag and drop the fields to the following groups and then click Next.

• Row groups
CalendarYear

Month

• Column groups
ProductCategory

• Values

SalesAmount
4. On the Choose the layout page, ensure that Show subtotals and grand totals, Blocked, subtotal
below, and Expand/collapse groups are all selected, and then click Next.

5. On the Choose a style page, in the Styles list, select any style. Then click Finish.
6. Format the report as necessary - for example, format the [Sum(SalesAmount)] fields as currency and
widen the columns.
7. In the Groupings pane, in the Month group drop-down list, click Group Properties. Then on the
Sorting tab, change the Sort by field to MonthNo so that the months are sorted in calendar order,
and click OK.

8. Click Run to preview the report, and then close Report Builder without saving the report. Then close
Internet Explorer.
3-22 Supporting Self Service Reporting

Lesson 3
Report Parts

It is not unusual for multiple reports to contain common elements. For example, an organization might
create multiple reports that show sales data aggregated in different ways, but include a common gauge in
all of them that shows how total sales compare to the sales target for the year. This lesson describes how
Reporting Services supports reusable report parts that business users can incorporate in their reports.
After completing this lesson, you will be able to:

• Describe the key features and functionality of reports parts.


• Publish report parts from a report.
• Use report parts in a report.

• Update report parts in a report.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-23

What Are Report Parts?

Report parts are reusable report items that are stored on a report server and can be included in multiple
reports. You can publish any of the following report item types as a report part:

• Charts

• Gauges

• Images
• Maps

• Parameters

• Rectangles

• Tables

• Matrices

• Lists
A unique ID is used to maintain the relationship between published report parts on a report server and
instances of the report part used in reports. This enables report authors to report reports if any report
parts they use have been updated.
In a self-service reporting scenario, report parts enable organizations to use the individual strengths of
team members by dividing report design tasks. For example, suppose that Jeff and Nicole both work in
the sales department at Adventure Works. Jeff is familiar with the expression syntax that you use to create
custom calculations in reports but has a poor eye for designing visually interesting charts. Nicole has
greater experience of designing charts but has never used custom expressions.

Jeff and Nicole use the same shared dataset to create reports. Jeff’s report includes a table of data that
includes custom calculated fields. Nicole’s report includes a chart that shows the data graphically.
3-24 Supporting Self Service Reporting

Jeff publishes his table as a Report Part, and Nicole does the same with her chart. Now Jeff can add
Nicole’s chart to his report, and Nicole can add Jeff’s table to her report. Additionally, other authors can
use Jeff’s table, Nicole’s chart, or both in their own reports. By combining the abilities of multiple authors,
Adventure Works benefits from richer reports and reusable Report Parts that can easily be added to future
reports.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-25

Publishing Report Parts

You can publish items from a report as report parts from Report Designer in SQL Server Data Tools or
Report Builder. The procedure for publishing report parts is similar in both tools.

1. Create a report that includes the items you want to publish as report parts.

2. When using Report Designer, on the Report menu, click Publish Report Parts. The report parts will
be published to the location specified in the project properties.
When using Report Builder, on the Report Builder menu, click Publish Report Parts. You must
specify the folder or document library where you want to publish the report parts.

3. Optionally, you can select individual report items to publish, add descriptions, and set custom
publishing locations before publishing.
3-26 Supporting Self Service Reporting

Using Report Parts

You can only add report parts to a report in Report Builder. Use the following procedure to add a
published report part to a report:

1. Search the report part gallery for the report part you want to add. The report part gallery is a pane in
Report Builder that you can display by clicking Report Parts on the Insert tab of the ribbon.

2. Drag the report part into the body of the report.


3. Reformat the report part as appropriate.

Any formatting changes you make will apply only to the instance of the report part in the current report.
The published report part will retain its existing formatting unless you republish the report part from the
current report.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-27

Updating Report Parts

You can update a published report part by adding it to a report in report builder, making the required
changes, and republishing the report part. Any existing reports that use the report part will continue to
display the original version unless they are updated to use the new version.

When you open a report for editing in Report Builder, a notification is displayed if the report contains any
report parts that have been updated on the server. You can then view the updates and if desired, refresh
the report to use the new version of the report parts.

You can also explicitly check for updates at any time by clicking Check For Updates on the Report
Builder menu.
3-28 Supporting Self Service Reporting

Demonstration: Using Report Parts

 Task 1: Create and publish a report part


1. Ensure MIA-DC1 and MIA-SQLBI are started, and log onto MIA-SQLBI as ADVENTUREWORKS
\Student with the password Pa$$w0rd. Then in the D:\10778A\Demofiles\Mod03 folder, run
Setup.cmd as Administrator.

2. Start Internet Explorer and browse to the Reports document library in the SharePoint site at
http://mia-sqlbi.

3. In the ribbon, on the Documents tab, in the New Document drop-down list, click Report Builder
Report. If you are prompted, click Run, and wait for Report Builder to be downloaded. The
application starts automatically after it has been downloaded.
4. In the Getting Started dialog box, ensure that New Report is selected and click Chart Wizard.

5. On the Choose a dataset page, ensure Create a dataset is selected, and click Next.
6. On the Choose a connection to a data source page, click New, and in the Data Source Properties
dialog box, create a data source with the following settings and click OK. Then click Next.

• On the General tab, change the Name property to AdventureWorksDW, ensure that the
Microsoft SQL Server connection type is selected, and enter the following connection string.

Data source=localhost;Initial Catalog=AdventureWorksDW

• On the Credentials tab, ensure that the Use current Windows user. Kerberos delegation
might be required option is selected.

7. On the Design a query page, click Import and browse to the D:\10778A\Demofiles\Mod03 folder,
select SalesByYear.sql, and click Open. Then on the toolbar, click the Run button to verify that the
query returns sales volumes for years and product categories, and click Next.

8. On the Choose a chart type page, select Line, and click Next.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-29

9. On the Arrange chart fields page, drag CalendarYear to the Categories list, drag ProductCategory
to the Series list, and drag SalesAmount to the Values list. Then click Next.

10. On the Choose a style page, select Generic, and then click Finish.
11. When the report has been created, click the Chart Title text box and then select the text and change
it to Sales Trend. Then resize the chart to make it bigger.

12. Click Run to preview the chart and then click Design to return to design view.

13. With the chart selected, on the View tab of the ribbon, select Properties. Then in the Properties
pane, change the Name property of the chart to DemoSalesTrendChart.

14. In the Report Data pane, expand Datasets, right-click DataSet1 and click Dataset Properties. Then
in the Dataset Properties dialog box, change the Name property to DemoSalesByYear and click
OK.

15. Click the round button at the top left of the ribbon, and on the Report Builder menu, click Publish
Report Parts, and in the Choose Sharepoint Document Library dialog box, select the Reports
document library and click OK. Then in the Publish Report Parts dialog box, click Review and
modify report parts before publishing.

16. In the Publish Report Parts dialog box, expand DemoSalesTrendChart and in the description box,
type Chart showing sales by category over time. Then click Publish, and when the Result message
shows that a report part was published successfully, click Close.

 Task 2: Use a report part in a report


1. Click the round button at the top left of the ribbon, and on the Report Builder menu, click New.
When prompted to save the current report, click No. Then in the New Report or Dataset dialog box,
select New Report and click Blank Report.
2. In the ribbon, on the Insert tab, click Report Parts.

3. In the Report Part Gallery pane, in the search box type Sales and click the search button. Note that
the DemoSalesTrendChart report part you published in the previous task is listed in the results.
4. Drag the DemoSalesTrendChart report part to the body of the report.
5. Right-click the chart title, point to Chart, and click Chart Properties. Then in the Chart properties
dialog box, in the Color palette drop-down list, select Chocolate and click OK.

6. Click the Click to add title textbox and type Sales Report.
7. On the Home tab, click Run to preview the report and note that the report part is shown with the
chocolate color palette in this report.

8. In the quick access toolbar, click Save. Then in the Save As Report dialog box, browse to the
http://mia-sqlbi/Reports folder, in the Name box type Demo Sales Report – Line Chart.rdl, and click
Save.
3-30 Supporting Self Service Reporting

 Task 3: Update a report part


1. Click the round button at the top left of the ribbon, and on the Report Builder menu, click New.
Then in the New Report or Dataset dialog box, select New Report and click Blank Report.

2. Drag the DemoSalesTrendChart report part from the Report Parts Gallery pane to the body of the
report.
3. Right-click the chart title, point to Chart, and click Chart Properties. Then in the Chart properties
dialog box, in the Color palette drop-down list, select Sea green and click OK.

4. Click the round button at the top left of the ribbon, and on the Report Builder menu, click Publish
Report Parts, and in the Choose Sharepoint Document Library dialog box, select the Reports
document library and click OK. Then on the Publish Report Parts dialog box, click Review and
modify report parts before publishing.

5. In the Publish Report Parts dialog box, expand DemoSalesTrendChart and ensure that the Publish
as a new copy of the report part checkbox is not selected. Then click Publish, and when the Result
message shows that a report part was published successfully, click Close.
6. Click the round button at the top left of the ribbon, and on the Report Builder menu, in the Recent
Documents list, click Demo Sales Report – Line Chart.rdl. Do not save the current report from
which you republished the report part.

7. Wait for a few moments until the Updated Report Parts message appears under the ribbon. Then
click View Updates.
8. In the Update Report Parts dialog box, select the DemoSalesTrendChart report part and click
Update. Then click Close and note that the report has been updated with the new version of the
report part.
9. Save the report and close Report Builder and Internet Explorer.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-31

Lab Scenario

As a BI professional at Adventure Works Cycles, you want to empower business users to create their own
reports using Report Builder.

You need to experiment with Report Builder to create a report, and find out how much database
technology knowledge users will need to perform self-service reporting. You will do this by creating a
report that shows reseller sales by product category.
You must then explore ways in which you can create reusable reporting components that will simplify the
report creation process for business users who have limited database technology expertise. You will do
this by creating a shared data source and shared datasets, and by publishing a chart as a report part.
3-32 Supporting Self Service Reporting

Lab 3: Implementing Self Service Reporting

Exercise 1: Using Report Builder


Scenario
You intend to provide a self-service reporting solution at Adventure Works Cycles so that business users
can create their own reports. Report Builder will be the primary authoring tool for business users, so you
want to use it to create a report in order to understand the authoring experience it will provide to your
business users.
The main tasks for this exercise are as follows:

1. Prepare the lab environment.

2. Install Report Builder.

3. Create a report.

4. Format the report.

5. Publish the report.

 Task 1: Prepare the lab environment


• Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab03\Starter
folder as Administrator.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-33

 Task 2: Install Report Builder


• Start Internet Explorer and browse to the SharePoint site at http://mia-sqlbi.

• In the Reports document library, on the Documents tab of the ribbon, in the New Document drop-
down list, click Report Builder Report. Then install Report Builder and wait for it to start.

 Task 3: Create a report


• Use Report Builder to create a new report with the Table or Matrix Wizard. Use the following settings
when creating your report:

• Create a dataset for the report and add a new SQL Server data source named
AdventureWorksDW that uses the following connection string:

Data source=localhost;Initial Catalog=AdventureWorksDW

• Use the query designer to create a query that retrieves the following fields, verifying the
relationships that are detected by the query designer.
DimProductCategory.EnglishProductCategoryName

DimProductSubcategory.ProductCategoryKey

DimProduct.ProductSubcategoryKey
DimGeography.EnglishCountryRegionName

DimGeography.StateProvinceName

DimGeography.City

DimReseller.GeographyKey
FactResellerSales.ResellerKey

FactResellerSales.SalesAmount
• Arrange the fields in the report as follows:

Row groups

EnglishCountryRegionName
StateProvinceName

City

Column groups

EnglishProductCategoryName

Values

SalesAmount

• Show subtotals and grand totals, lay out the report as blocked with subtotals below details rows,
and enable expand and collapse interactions with groups.

• Format the report using the Generic style.


3-34 Supporting Self Service Reporting

 Task 4: Format the report


• Change the report title to Reseller Sales by Product Category.

• Apply formatting to the report to align data in columns, make titles bold, format currency values
appropriately, and generally improve the visual design of the report.
• Click Run to preview the report, and continue formatting the report until you are satisfied with it.

 Task 5: Publish the report


• Save the report as Reseller Sales by Product Category.rdl in the http://mia-sqlbi/Reports folder.
Then close Report Builder.

• In Internet Explorer, refresh the view of the Reports document library and view the report in the
browser.

Results: After this exercise, you should have used Report Builder to create and publish a report.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-35

Exercise 2: Simplifying Data Access for Business Users


Scenario
You have used Report Builder to create a report, and you are concerned that some business users will find
it difficult to create data sources and datasets when authoring their own reports. To help these users, you
want to create a shared data source for the data warehouse and shared datasets for commonly requested
reporting data so that business users do not need to learn how to define connection strings or Transact-
SQL queries when creating reports.

The main tasks for this exercise are as follows:


1. Create a shared data source.

2. Create shared datasets.

3. Create a report from shared data items.

 Task 1: Create a shared data source


• In Internet Explorer, in the Reports document library, on the Documents tab of the ribbon, in the
New Document drop-down list, click Report Data Source. Then add a new data source with the
following settings:
• Name: Adventure Works Data Warehouse

• Data Source Type: Microsoft SQL Server

• Connection string: Data source=localhost;Initial Catalog=AdventureWorksDW


• Credentials: Windows authentication (integrated) or SharePoint user

• Availability: Enable this data source selected

 Task 2: Create shared datasets


• In the Reports document library, on the Documents tab of the ribbon, in the New Document drop-
down list, click Report Builder Report to start Report Builder.
• Use Report Builder to create a new dataset based on the shared data source you created in the
previous task. Use the following settings when creating the dataset:
• Import the Reseller Sales By Year.sql query file from the D:\10778A\Labfiles\Lab03\Starter
folder.

• Set the parameter options for the dataset so that the @CalendarYear parameter is an integer
data type and allows multiple values.
• Save the dataset as Reseller Sales by Year.rsd in the http://mia-sqlbi/Reports folder.

• Create a second shared dataset that uses the Reseller Years.sql query file in the
D:\10778A\Labfiles\Lab03\Starter folder, and save it as Reseller Years.rsd in the
http://mia-sqlbi/Reports folder.

• Create a third shared dataset that uses the Most Recent Reseller Year.sql query file in the
D:\10778A\Labfiles\Lab03\Starter folder, and save it as Most Recent Reseller Year.rsd in the
http://mia-sqlbi/Reports folder.
3-36 Supporting Self Service Reporting

 Task 3: Create a report from shared data items


• Use Report Builder to create a new report with the Table or Matrix Wizard. Use the following settings
when creating your report:

• Use the Reseller Sales by Year.rsd dataset.


• Arrange the fields in the report as follows:

Row groups

CalendarYear
Month

Column groups

ProductCategory
Values

SalesAmount

• Show subtotals and grand totals, lay out the report as blocked with subtotals below details rows,
and enable expand and collapse interactions with groups.
• Format the report using the Generic style.

• Add a dataset named Years based on the Reseller Years.rsd shared dataset to the report.
• Add a dataset named MostRecentYear based on the Most Recent Reseller Year.rsd shared dataset
to the report.

• Configure the CalendarYear report parameter to get its available values from the CalendarYear field
in the Years dataset, and its default value from the CalendarYear field in the MostRecentYear
dataset.

• Change the report title to Reseller Sales by Year and format the report as you think appropriate.
• Modify the Month group properties so that the data in the group is sorted by the MonthNo column.

• Preview the report and verify that the default and available parameter values can be used to filter the
report.

• Save the report as Reseller Sales by Year.rdl in the http://mia-sqlbi/Reports folder.

Results: After this exercise, you should have a shared data source, three shared datasets, and a report that
is based on the shared data items.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 3-37

Exercise 3: Using Report Parts


Scenario
You have identified a chart that business users frequently request in reports. You want to publish the chart
as a report part to enable users to include it in their own reports.

The main tasks for this exercise are as follows:


1. Create a report part.

2. Use a report part.

 Task 1: Create a report part


• In Report Builder, create a new report by using the Chart Wizard. Use the following settings when
creating the report:

• Create a new dataset based on the Adventure Works Data Warehouse.rsds shared data source.
The data source should use the query defined in the Count Resellers by Country.sql query file,
which is in the D:\10778A\Labfiles\Lab03\Starter folder.

• Create a pie chart that shows resellers as values and the countries as categories.

• Format the chart using the Generic style.

• When the report is created, change the chart title to Resellers by Country and resize the chart to
make it bigger.

• Change the Name property of the chart to ResellersChart and change the Name property of the
dataset that was created by the wizard to ResellersByCountry.

• On the Report Builder menu (which is opened by clicking the round button at the top left of the
ribbon), click Publish Report Parts. Then select the Reports document library and select the option
to review and modify the report parts before publishing.
• Add the description Chart showing the number of resellers in each country to the ResellersChart
report part and then publish the report part.

 Task 2: Use a report part


• In Report Builder, create a new blank report. Do not save the current report (from which you
published the ResellerChart report part)

• With the new blank report open in Report Builder, view the Report Part Gallery pane and search for
Resellers. This should find the ResellerChart report part.

• Add the ResellerChart report part to the report, and then modify the properties of the chart to use
the Semi transparent color palette.

• Change the report title to Resellers By Country - Pie Chart and save it as Resellers By Country -
Pie Chart.rdl in the http://mia-sqlbi/Reports folder.

• Create another blank report and add the ResellerChart report part to it. Then change the chart type
to a column chart, change the report title to Resellers By Country - Column Chart and save it as
Resellers By Country - Column Chart.rdl in the http://mia-sqlbi/Reports folder.

Results: After this exercise, you should have a report part that is used in two reports.
3-38 Supporting Self Service Reporting

Module Review and Takeaways

Review Questions
1. How can you enable business users to create reports without them needing to define connection
strings for databases?

2. How can you simplify self-service reporting for business users who aren’t familiar with query syntax?

3. How can you create a standard gauge that multiple business users can include in their reports?
4-1

Module 4
Managing Report Execution and Delivery
Contents:
Lesson 1: Managing Report Security 4-3

Lesson 2: Managing Report Execution 4-10


Lesson 3: Subscriptions and Data Alerts 4-17

Lesson 4: Troubleshooting Reporting Services 4-31


Lab 4: Configuring Report Execution and Delivery 4-37
4-2 Managing Report Execution and Delivery

Module Overview

When you provide a reporting solution in an organization, you must manage the execution and delivery
of reports in order to ensure the security of business data and provide a high-performance report viewing
and delivery experience for your users.
This module describes how to apply security settings and configure reports for delivery. After completing
this module, you will be able to:
• Configure security settings for a report server.
• Configure report execution settings to optimize performance.

• Use subscriptions and alerts to automate report and data delivery.


• Troubleshoot reporting issues.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-3

Lesson 1
Managing Report Security

Reports contain business data, so it is important to ensure that your reporting solution applies appropriate
security restrictions to protect sensitive information. This lesson discusses security configuration for
Microsoft® SQL Server® Reporting Services.
After completing this lesson, you will be able to:

• Describe the considerations for securing a reporting solution.

• Configure authentication for a report server.


• Apply permissions to implement authorization in a report server.

• Configure secure network communication for a report server.


4-4 Managing Report Execution and Delivery

Introduction to Report Server Security

SQL Server Reporting Services provides a flexible security model that enables you to apply security
settings to protect your business data. While the specific details of security models can vary between
organizations, every reporting solution must address the following fundamental security considerations.

Authentication
Your reporting solution should authenticate users to verify their identity. Authentication usually involves
validating user credentials, such as a user name and password, before allowing the user to access the
reporting solution. SQL Server Reporting Services supports a number of authentication mechanisms, which
you can configure to match the requirements of your organization’s application infrastructure.

Authorization
After verifying the identity of each user, your reporting solution must authorize access to specific reports,
data sources, or other objects based on permissions that you have assigned. SQL Server Reporting Services
supports a role-based authorization model in which you can apply permissions to a specific set of roles,
and assign users to those roles in order to authorize access to report items.

Secure Communication
When users access a report server, data is transmitted across network connections. In some cases, you
should consider using encrypted connections to ensure that data cannot be intercepted and read by a
third party.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-5

Managing Authentication

SQL Server Reporting Services supports a number of authentication models.

By default, users connecting to a report server are authenticated based on their Windows® credentials,
but you can edit the RSReportServer.config file to enable any of the following authentication models.

• RSWindowsNegotiate This is the default authentication model for report servers in native mode
and authenticates users based on their Windows credentials using Kerberos where supported. In
environments where Kerberos is not supported, this authentication model falls back to Windows NT
LAN Manager (NTLM) authentication.
• RSWindowsNTLM This authentication model uses NTLM access tokens to authenticate users, and
does not support delegation of credentials (in which the report server can impersonate the user to
access resources on another server.)

• RSWindowsKerberos This authentication model uses a Kerberos ticket to identify a user. The user’s
credentials can be delegated across multiple servers in the same domain. Kerberos authentication
requires specific infrastructure configuration, including registering service principle names (SPNs) for
service accounts.

• RSWindowsBasic This authentication model uses HTTP basic authentication to authenticate user
access to the report server. Credentials are passed in base 64 clear text, so you should ensure that
your report server is configured to use an encrypted channel when using this model.

• Custom You can use a custom model that uses ASP.NET Forms authentication to validate users. At
the HTTP layer, requests are treated as anonymous and redirected to your custom module.

For More Information For more information about Kerberos Documentation for
Windows, see http://go.microsoft.com/fwlink/?LinkID=246780.
4-6 Managing Report Execution and Delivery

Managing Authorization

Access to reporting items such as reports, data sources, data sets, and report parts is based on permissions
assigned to roles. The specific roles and permissions you can use to secure a report server depend on the
mode in which the report server is installed.

Using Roles in Native Mode


When a report server is installed in native mode, you use system-level roles to control access to the report
server and server-level functionality, such as shared schedules; and item-level roles to control access to
individual report items. Reporting Services includes the following predefined roles:
• System-level roles

• System User Members of this role can access the report server.

• System Administrator Members of this role can administer the report server.

• Item-level roles

• Content Manager Members of this role have full control of items, including the ability to
manage permissions.

• Publisher Members of this role can add, update, view, and delete items
• Report Builder Members of this role can use Report Builder to create and edit items.

• Browser Members of this role can view items and create subscriptions.
• My Reports Members of this role can manage reports in a personal folder named My Reports.

If necessary, you can customize the individual permissions assigned to the predefined roles. Additionally,
you can define your own custom roles and assign specific permissions to them.
Item-level role membership is assigned for individual folders and items. By default, role membership
assignments are inherited by subfolders, but you can override inherited role memberships by creating
custom role assignments at any level in a folder hierarchy.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-7

Using Groups in SharePoint Integrated Mode


When a report server is installed in Microsoft SharePoint® Integrated mode, access to report items is
controlled through permissions granted to SharePoint groups in document libraries where report items
are supported. The following table shows how SharePoint groups relate to native mode Reporting
Services roles.

Permission Reporting Services Role SharePoint Group

Access the report System User There is no equivalent SharePoint group for this
server permission. Access to reporting items is based on
permissions to access the SharePoint farm.

Manage the report System Administrator There is no equivalent SharePoint group for this
server permission. The report server can be managed by
any user with administrative access to the
SharePoint farm.

Full control of items Content Manager Use the Owners group to enable a user to
manage reporting items in a SharePoint
document library.

Add, update, view, and Publisher Use the Members group to enable a user to
delete items publish, update, view, and delete reporting items
in a SharePoint document library.

Use Report Builder Report Builder There is no equivalent SharePoint group for this
permission. Users assigned to the Owners and
Members groups can use Report Builder to
create and edit items.

View Reports Browser Use the Visitors group to enable a user to view
reporting items in a SharePoint document library.

Use the My Reports My Reports There is no equivalent SharePoint group for this
folder permission because the My Reports folder is not
supported in SharePoint integrated mode. You
can use the My Site feature of SharePoint Server
to provide similar functionality.
4-8 Managing Report Execution and Delivery

Managing Secure Communication

Users generally use a web browser such as Windows Internet Explorer® to access a report server. When
this access will be performed across the Internet or any network where data must be secure while in
transit, you can configure the report server to use secure sockets layer (SSL) security to encrypt network
communication between the user and the report server.

Configuring SSL Security in Native Mode


When a report server is installed in native mode, you can use the following procedure to enable SSL for
secure network communication.
1. Install a server certificate for SSL communication.

You can obtain a certificate from a trusted certificate-issuing authority, or you can issue your own
certificates and configure clients to trust them.

2. Bind the certificate to each Reporting Services endpoint for which you want to enable secure
communication.

Use Reporting Services Configuration Manager to bind the certificate and specify the port to be used
for secure communication. You must bind the Reporting Services Web Service and Report Manager
URLs individually.

Reporting Services does not use Internet Information Services (IIS) to handle HTTP requests, but if IIS is
installed on a server where Reporting Services is configured to use SSL, then the W3SVC service must be
running.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-9

Configuring SSL Security in SharePoint Integrated Mode


When a report server is running in SharePoint Integrated mode, there is no specific procedure for
enabling SSL communication for Reporting Services. You can use the following procedure to enable SSL
communication for the entire SharePoint site:

1. Install a server certificate for SSL communication.

2. Bind the certificate to the SharePoint website in IIS.


4-10 Managing Report Execution and Delivery

Lesson 2
Managing Report Execution

After you have published report server items, you can configure them to optimize report execution. The
specific optimization techniques you can use depend on a number of factors, including the authentication
credentials used to access report data sources and the acceptable latency of the data in the reports.
This lesson describes common ways to manage report execution. After completing this lesson, you will be
able to:

• Configure credentials for a shared data source.


• Cache reports and data sets to optimize performance.
• Use snapshots to create a report history.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-11

Configuring Data Source Credentials

You can manage a shared data source in Report Manager or a SharePoint document library, and
configure it to use any of the following credential settings when accessing data.

• Windows integrated security Use this setting when you want the data source to impersonate the
Windows identity of the current user when connecting to the database server. You can use this
setting for database servers that are installed on the report server or on another server. If the
credentials must be impersonated across more than one other server, then Kerberos authentication is
required.
• Credentials supplied by the user running the report Use this setting when you want to prompt
the user to enter credentials when they view the report. The data source will then pass these
credentials to the database in order to gain access to the data for the report. You can specify that the
credentials entered by the user should be treated as Windows credentials or as a user name and
password for a non-integrated authentication model, such as a SQL Server login.

• Credentials stored securely on the report server Use this setting when you always want to access
the database using the same credentials, regardless of the user requesting the report. The credentials
are stored in an encrypted format on the report server, and users do not need to know the user name
and password used to access the database. This configuration is required when you want to cache
reports or datasets that use the data source, or create data-driven subscriptions for reports that use it.
• Credentials are not required Use this setting for databases or other sources of data that do not
require any authentication.
4-12 Managing Report Execution and Delivery

Optimizing Performance with Caching

Reports that contain a large amount of data or complex functions can be slow to render. To improve the
performance of these reports, you can use caching functionality in Reporting Services to cache datasets
and reports when they are first accessed, so that they can be rendered more quickly for subsequent
requests. You can also use a cache refresh plan to re-cache reports so that they are already in cache the
first time they are requested.

Cached reports and datasets are stored in memory, so data is not retrieved from the data source when the
report is rendered. Additionally, if a report or dataset includes parameters, a cached instance is created for
each distinct parameter combination that is requested. Caching is not suitable in the following scenarios:
• Real-time reporting is required every time the report is viewed.

• A report has a large number of parameters or a wide range of commonly requested parameter value
combinations.

• The data source for a report or dataset must use Windows Integrated authentication or credentials
provided by the user making the request.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-13

You can enable caching for a report or dataset in Report Manager of a SharePoint document library.
When you configure caching for a report or dataset, you can use the following options to specify when
the cached instance should expire:

• After a specified period of time For example, you could cache a report for one hour after it is
rendered. After an hour, the cached instance is expired and a subsequent request will result in a fresh
cached instance.
• On a report or dataset-specific schedule For example, you could configure a report to be cached
until midnight each day. A request after midnight will render a fresh copy of the report.

• On a shared schedule For example, if you need to cache multiple reports and datasets, you can use
a shared schedule to ensure they all expire at the same time.

Additionally, a report or dataset may be removed from the cache at any time if it is replaced with a new
version.
4-14 Managing Report Execution and Delivery

Using Report Snapshots

Caching is a technique that you can use to optimize report performance. However, there may be cases
where you need greater predictability about the specific point in time that data in a report represents. In
such scenarios, you can use snapshots to create a report history and enable user to view specific versions
of a report that relate to the time the snapshot was created.

Similarly to caching, snapshots are created for specific combinations of parameters and require that the
credentials used by the report data sources are stored securely on the server. Additionally, when using
snapshots, you should not map report parameters to data set parameters. Instead, use a data set query
that returns all of the data, and apply filters in the report based on report parameters.
You can configure snapshots for a report in Report Manager or a SharePoint document library, and have
them be generated on a scheduled basis. You can also create a snapshot on demand when viewing the
history of a report in Report Manager or SharePoint server.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-15

Demonstration: Configuring Report Execution

 Task 1: Configure credentials for a data source


1. Ensure MIA-DC1 and MIA-SQLBI are started, and log onto MIA-SQLBI as ADVENTUREWORKS
\Student with the password Pa$$w0rd. Then in the D:\10778A\Demofiles\Mod04 folder, run
Setup.cmd as Administrator.

2. In the D:\10778A\Demofiles\Mod04 folder, double-click AWReports.sln to open the solution in SQL


Server Data Tools. Then in Solution Explorer, right-click AWReports and click Deploy. When
deployment is complete, close SQL Server Data Tools.

3. Start Internet Explorer and browse to SharePoint site at http://mia-sqlbi, and in the Reports
document library, click Demo to view the contents of the Demo folder.
4. On the drop-down list for the AdventureWorksDW data source, click View Dependent Items and
note that the Monthly Sales Report report has a dependency on this data source. Then click Close.

5. On the drop-down list for the AdventureWorksDW data source, click Edit Data Source Definition,
and in the Credentials section of the configuration page, note that the data source is currently
configured to use the Windows authentication (Integrated) or SharePoint user option.

6. In the Credentials section, select the Stored credentials option and enter the following credentials:

• User Name: ADVENTUREWORKS\ServiceAcct

• Password: Pa$$w0rd

7. Select Use as Windows credentials and click Test Connection. Then when the connection has been
tested successfully, click OK.
4-16 Managing Report Execution and Delivery

 Task 2: Configure caching for a report


1. In the Demo folder, on the drop-down menu for the Monthly Sales Report report, click Manage
Processing Options.

2. In the Data Refresh Options section, select the Use cached data option, and then in the Cache
Options section, select On a custom schedule and click Configure.
3. In the Frequency section, select Day, in the Schedule section select all of the days and set the Start
time to 12:00 am, and click OK. Then click OK again to set the processing options and return to the
Reports document library.

4. Click Monthly Sales Report and note the execution date and time under the report heading.

5. At the top of the report page, click the demo link to return to return to the Demo folder, and then
click Monthly Sales Report again. Note that the execution date and time have not changed because
the report has been cached.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-17

Lesson 3
Subscriptions and Data Alerts

In addition to optimizing report execution for interactive viewing, you can configure reports for automatic
delivery through subscriptions. Users can receive reports automatically by email or in a shared folder or
SharePoint document library, and can be sent email notifications of specific report data conditions
through data alerts.
After completing this lesson, you will be able to:

• Describe how subscriptions and data alerts can be used to push report data to users.
• Subscribe to a report.
• Create a data-driven subscription for a report.

• Create a data alert.

• Manage data alerts.


4-18 Managing Report Execution and Delivery

Introduction to Subscriptions and Data Alerts

Business users can view reports on-demand, but often they require a push-oriented reporting solution in
which reports are delivered to them automatically on a regularly scheduled basis. Additionally, users
might only be interested in viewing reports under specific data conditions; and need to be alerted to
those conditions before browsing to the report.

SQL Server Reporting Services meets these needs through two features – subscriptions and data alerts.

Using Subscriptions to Deliver Reports


You can use subscriptions to deliver reports automatically on a scheduled basis. By creating subscriptions,
you can deliver reports in any supported rendering format to the following locations:
• An email message.

• A file share.
• A SharePoint document library.
For example, you could use a subscription to send a weekly sales report to the sales manager as a
Microsoft Excel® attachment in an email message, or you could save a product catalog report as a Word
document in a SharePoint document library every month.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-19

Using Data Alerts to Notify Users of Report Data Conditions


You can use data alerts to notify users on specific report data conditions by sending an email message.
For example, each regional sales manager could request a data alert every month if the monthly sales
report contains a regional sales total that is less than a specified amount.

Note Data alerts are only available in SharePoint Integrated mode.

To send subscriptions and data alerts by email, the report server must be configured with the address of
an SMTP server. For report servers in native mode, you can configure this setting in Reporting Services
Configuration Manager. When using SharePoint Integrated mode, you can configure email settings for
the report server service application in SharePoint Central Administration.
4-20 Managing Report Execution and Delivery

Subscribing to a Report

You subscribe to a report by creating a standard subscription. In most cases, business users create their
own standard subscriptions; though administrators can also use standard subscriptions to deliver reports
to email distribution lists, shared folders, or document libraries.

Use the following procedure to create a standard subscription:

1. View the report in Report Manager or in SharePoint Server.


2. In Report Manager, click the Subscriptions tab and then click Subscribe. In SharePoint Server, on the
Actions menu, click Subscribe.

3. Specify the appropriate options for your subscription.


Options for a subscription include:

• The delivery extension This specifies how the subscription will be delivered, and can be one of the
following:

• Email

• Windows file share


• SharePoint library (only available in SharePoint integrated mode)

• Extension-specific options The options available depend on the delivery extension selected. For
example, if you select the email extension, then you must specify an email address to which the report
must be sent, a subject for the email message, and other email related options.

• The report format This option determines the rendering format of the report. For example, you
could send the report as a Microsoft Excel workbook or a Microsoft Word document.

• The delivery schedule You can schedule a subscription to deliver the report when a snapshot is
refreshed, on a subscription-specific schedule, or on a shared schedule.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-21

• Parameter values If the report includes parameters, you must specify the values to be used for
them when delivering the subscription.

After you have created a standard subscription, you can view and manage your subscriptions in Report
Manager or SharePoint Server. Use one of the following techniques to view the Manage Subscriptions
page for a report.

• In Report Manager, on the drop-down menu for the report, click Manage. Then click the
Subscriptions tab.

• In SharePoint Server, on the drop-down menu for the report, click Manage Subscriptions.

Note Standard subscriptions are available in SQL Server Standard Edition or higher.
4-22 Managing Report Execution and Delivery

Creating a Data-Driven Subscription

In some scenarios, you might want to create a subscription that delivers the same report to multiple
recipients, each with their own preferred options. Additionally, you might want to configure those options
dynamically when the subscription is processed. To accomplish this, you can create a data-driven
subscription that determines delivery options based on values in a database.

For example, you might need to deliver a sales report to each regional sales manager, with the data
filtered using a parameter for the region. Additionally, each salesperson might want to receive the report
in a different format. Instead of creating multiple standard subscriptions to meet this requirement, you
could create a single data-driven subscription that gets the email address, region parameter value, and
preferred report format for each sales manager from a table of subscription data.

Data-driven subscriptions are generally created by administrators, and require a query to retrieve delivery
options from a database. Use the following procedure to create a data-driven subscription.
1. View the Manage Subscriptions page for the report.

2. In Report Manager, click New Data-Driven Subscription. In SharePoint Server, click Add Data-
Driven Subscription.

3. Specify a name for the subscription, and a data source and query for the subscription data.

4. Specify the delivery extension for the subscription. You can choose any of the delivery extensions
available for standard subscriptions. Additionally, a null delivery extension is available, which enables
you to use a subscription to pre-cache the report.

5. Specify subscription options as static values or fields from the subscription data.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-23

6. Specify values for any report parameters. You can use default values, specify static values, or specify
values fields from the subscription data.

7. Specify a schedule for the subscription.

Note Data-driven subscriptions are supported in SQL Server Enterprise Edition or higher.
4-24 Managing Report Execution and Delivery

Demonstration: Using Subscriptions

Note This demonstration requires that you have completed the previous demonstration
in this module.

 Task 1: Subscribe to a report


1. In the SharePoint site at http://mia-sqlbi, in the Reports document library, in the demo folder, view
the Monthly Sales Report report.
2. On the Actions menu, click Subscribe.

3. In the Delivery Extension drop-down list, select Windows File Share, and then enter the following
settings, and then click OK:
• File name: MonthlySalesReport

• Path: \\MIA-SQLBI\SharedReports

• Render Format: Excel

• Write mode: Overwrite

• File Extension: True

• Delivery Event: On a custom schedule. Click Configure and define a custom schedule that will
send the report daily, two minutes from the current time; and click OK. You can determine the
current system time by starting a command prompt window and entering the command time /T.

• User name: ADVENTUREWORKS\ServiceAcct


• Password: Pa$$w0rd

• Parameters: Use Report Default Value


4. At the top of the report page, click the demo link to return to return to the Demo folder.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-25

5. In the drop-down list for the Monthly Sales Report report, click Manage Subscriptions. Then view
the information about the Windows File Share subscription you created in the previous task.

6. Wait two minutes and then refresh the page. The Last Results column should indicate that
subscription has run. Then minimize Internet Explorer with the Manage Subscriptions page still open
7. View the contents of the D:\10778A\Demofiles\Mod04\SharedReports folder and verify that the
report has been created.

 Task 2: Create a data-driven subscription


1. In the D:\10778A\Demofiles\Mod04 folder, double-click Subscription Table.sql to open it in SQL
Server Management Studio. Each time you are prompted, use Windows authentication to connect to
the database engine on the localhost server.

2. View the Transact-SQL code and note that it creates and populates a table named
ReportSubscriptionsDemo, which contains the following columns:

• SubscriptionID – a unique primary key

• RecipientEmail – the email address of a subscription recipient


• ReportFormat – the format in which the report should be rendered.

• Linked – a Boolean value that indicates whether the subscription email should include a link to
the report on the report server.

3. Click Execute to run the query. Then when it has completed, close SQL Server Management Studio.

4. Maximize Internet Explorer, and in the Manage Subscriptions page for the Monthly Sales Report
report, click Add data-Driven Subscription.

5. In the Description text box, type Weekly Sales Report. Then, in the Connection Type section, select
Shared data source, in the Data Source Link section, click the ellipsis (…) button, and in the Select
an Item dialog box, select the AdventureWorksDW data source and click OK.
6. In the Query section, type SELECT * FROM ReportSubscriptionsDemo and click Validate. When the
query is validated successfully, click Next.

7. In the Calendar Year section, ensure that Use report default value is selected, and click Next.
8. In the Delivery Type section, ensure that E-Mail is selected. Then set the following configuration
values and click Next.

• To: Select a value from the database (select RecipientEmail)

• Include Report: True

• Render Format: Select a value from the database (select ReportFormat)

• Subject: Specify a static value (enter Weekly sales report)

• Comment: Specify a static value (enter The weekly sales report is attached)

• Include Link: Select a value from the database (select Linked)

9. In the Delivery Event section, ensure that On a custom schedule is selected.


4-26 Managing Report Execution and Delivery

10. In the Frequency section, select Day.

11. In the Schedule section, select the current day and enter a time that is two minutes later than the
current time. You can determine the current system time by starting a command prompt window and
entering the commands and time /T. You can also use the command echo %date% to determine the
current day and date.

12. Click Finish and view the subscription details.

13. Wait for two minutes and then refresh the page. When the subscription has been processed, the Last
Results column should contain the message Done: 3 processed of 3 total; 0 errors.

14. View the contents of the C:\inetpub\mailroot\Drop folder and note the email messages that have
been received by the local SMTP server.

15. Open the three most recent messages, and verify that the report has been sent in Excel, Word, and
embedded HTML formats.

16. Close all attachments, email messages, and folder windows.

.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-27

Creating a Data Alert

Business users can use the following procedure to create a data alert for a report, and be notified by email
if the data in the report meets specified conditions.

1. View the report in SharePoint server, and on the Actions menu, click New Data Alert.

2. In the New Data Alert dialog box, select the data feed in the report that contains the data you want
to be notified about. Typically, the data feed is a data region such as a tablix or a chart.
3. Specify whether you want to be notified when the report includes data that meets the conditions
defined in the alert, or when it does not contain data that meets the conditions in the report.

4. Add one or more rules to determine the conditions for the alert. Rules are defined by selecting a field
in the data feed, a comparison operator (such as is or is greater than), and a value to compare the
field to. You can combine multiple comparisons to create complex rules.
5. Specify a schedule for the alert. Typically, you should discourage users from creating alerts that run
more frequently than daily, as this can have a negative effect on report server performance.

6. Specify the email settings for the alert, including the recipient address, subject, and description.

After you have saved the data alert, it will be processed at the specified interval. If the report includes data
that meets the conditions you specified in the alert, an email message will be sent to the specified email
address.
4-28 Managing Report Execution and Delivery

Managing Data Alerts

Users can use the following procedure to view and manage their data alerts.

1. In SharePoint server, on the drop-down menu for a report, click Manage Data Alerts. This displays
the Data Alert Manager page and shows any alerts that the current user has defined on the report.

2. If you want to review alerts for reports other than the one you clicked, select the appropriate option
in the View alerts for report drop-down list.
3. View the data alerts to see the number of notifications that have been sent for each alert, the date
and time each alert was last run, and the status of each alert.

4. Right-click any alert to edit it, delete it, or run it.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-29

Demonstration: Creating a Data Alert

Note This demonstration requires that you have completed the first demonstration in this
module.

 Task 1: Create a data alert


1. In the SharePoint site at http://mia-sqlbi, in the Reports document library, in the Demo folder, view
the Monthly Sales Report report.
2. On the Actions menu, click New Data Alert.

3. In the New Data Alert – Monthly Sales Report dialog box, in the Report data name drop-down
list, select Tablix1.
4. Click Add rule and click Product Category, then in the drop-down list for the rule value, click Bikes.
This creates a rule that sends an alert of the report data includes any sales for the Bikes product
category.
5. Under Schedule settings, change Daily to Minute, and ensure that the alert is scheduled for every 1
minute(s).
6. In the Email settings section, change the Recipient(s) value to student@adventureworks.msft,
and then click Save.

7. Minimize Internet Explorer and view the contents of the C:\inetpub\mailroot\Drop folder. Then wait
for a minute and refresh the folder until a new email message appears.
8. Double-click the new email message to view the alert. Then close the email message and the folder
window.
4-30 Managing Report Execution and Delivery

 Task 2: Manage data alerts


1. Maximize Internet Explorer, and above the report, click the demo link to view the demo folder.

2. In the drop-down list for the Monthly Sales Report report, click Manage Data Alerts.

3. Note that the alert you created previously is listed and that the Last Run and Status columns provide
information about when the alert was last sent.

4. Right-click the alert, and on the shortcut menu that appears, click Delete.

5. Close Internet Explorer.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-31

Lesson 4
Troubleshooting Reporting Services

A reporting solution can quickly become an indispensable part of an organization’s infrastructure. It is


therefore extremely important that BI professionals are able to troubleshoot problems and monitor
performance for Reporting Services.
This lesson describes the primary locations of troubleshooting and performance information that you can
use to manage the health of a Reporting Services solution. After completing this lesson, you will be able
to:

• Describe the log files that you can use to troubleshoot Reporting Services issues.

• Describe the performance counters that you can use to monitor Reporting Services performance.
4-32 Managing Report Execution and Delivery

Reporting Services Logs

If you need to troubleshoot an issue with a report server, you can find information to help you diagnose
the problem by enabling logging and viewing data in the logs. There are three general categories of
logging that you can use to troubleshoot Reporting Services.

Execution Logging
Execution logging records statistics about report execution. Before you can use execution logging to
troubleshoot an issue with Reporting Services, you must enable it.

• For report servers in native mode, you can enable execution logging on the Logging page of the
properties of the report server in SQL Server Management Studio.

• For report servers in SharePoint Integrated mode, you can enable execution logging in the System
Settings page for the reporting services application in SharePoint Central Administration.

You can enable execution logging in normal or verbose mode.


To view execution logging information, query the ExecutionLog, ExecutionLog2, and ExecutionLog3
views in the report server database.

For More Information For more information about execution logging, see Report Server
Execution Log and the ExecutionLog3 View in SQL Server Books Online.

Trace Logging
Trace logging records information about errors and warnings as well as general diagnostic data. By
default, Reporting Services logs trace data to a file named ReportServerService_<timestamp>.log in the
\Microsoft SQL Server\<SQL Server Instance>\Reporting Services\LogFiles folder. Additionally, for report
servers in SharePoint Integrated mode, you can specify reporting services events to be logged to the
SharePoint unified logging service (ULS) trace log.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-33

To configure logging in the Reporting Services trace log file, edit the DefaultTraceSwitch and RSTrace
settings in ReportingServicesService.exe.config, which is in the \Program Files\Microsoft SQL Server
\MSRS11.<instance name>\Reporting Services\ReportServer\bin folder.

To configure SharePoint ULS logging for Reporting Services, edit the SQL Server Reporting Services
events to be logged in the Configure Diagnostic Logging page in the Monitoring section of SharePoint
Central Administration.

HTTP Logging
HTTP logging records details of HTTP requests and responses made to the report server. This information
can be useful when diagnosing problems associated with user requests.

For report servers in native mode, you can log HTTP data in a file named
ReportServerService_HTTP_<timestamp>.log in the \Microsoft SQL Server\<SQL Server Instance>
\Reporting Services\LogFiles folder. To enable HTTP logging, you must add http:4 to the RSTrace section
of the ReportingServicesService.exe.config file, where you can also modify the HttpTraceFileName
attribute to customize the name of the log file.

For report servers in SharePoint Integrated mode, you can use the Internet Information Services log files
to view information about HTTP requests and responses.

.
4-34 Managing Report Execution and Delivery

Monitoring Reporting Services Performance

If you need to troubleshoot performance issues with a report server, you can use the Windows
Performance console to monitor performance counters. Reporting Service provides the following
performance objects, each of which includes counters that you can monitor.

MSRS 2011 Web Service


This object includes counters that you can use to monitor report server performance that is typically
initiated by a user viewing a report. For servers in SharePoint Integrated mode, the MSRS 2011
SharePoint Mode Web Service object provides equivalent counters.

For More Information For a full list of counters provided by the MSRS 2011 Web
Service and MSRS 2011 SharePoint Mode Web Service performance objects, see
Performance Counters for the MSRS 2011 Web Service Performance Object in SQL Server
Books Online.

MSRS 2011 Windows Service


The MSRS 2011 Windows Service object includes counters that you can use to monitor scheduled
operations and subscription deliveries. For servers in SharePoint Integrated mode, the MSRS 2011
Windows Service SharePoint Mode object provides equivalent counters.

For More Information For a full list of counters provided by the MSRS 2011 Windows
Service and MSRS 2011 Windows Service SharePoint Mode performance objects, see
Performance Counters for the MSRS 2011 Windows Service Performance Object in SQL Server
Books Online.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-35

ReportServer:Service
The ReportServer:Service object includes counters that you can use to monitor HTTP events and
memory management. For servers in SharePoint Integrated mode, the ReportServerSharePoint:Service
object provides equivalent counters.

For More Information For a full list of counters provided by the ReportServer:Service
and ReportServerSharePoint:Service performance objects, see Performance Counters for
the ReportServer:Service Performance Object in SQL Server Books Online.
4-36 Managing Report Execution and Delivery

Lab Scenario

Some business users at Adventure Works Cycles have reported that the sales report takes a long time to
render, and have asked you to improve its performance.

Users also want to be able to subscribe to the report and have it delivered by email.

Additionally, some executives have requested that the report should be sent to them by email; but each
executive wants the report in a different format.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-37

Lab 4: Configuring Report Execution and Delivery

Exercise 1: Configuring Report Execution


Scenario
You have developed a reporting solution for Adventure Works Cycles. The solution includes a report that
is used to view sales for each product category by month. As the year progresses, the sales report can
include a large volume of data and be unacceptably slow to render. Business users can accept a latency of
one day when viewing report, and so you have decided to improve rendering performance by caching the
report and refreshing the cached instance at midnight each day.

The main tasks for this exercise are as follows:

1. Prepare the lab environment.

2. Deploy reports.
3. Configure a shared data source.

4. Configure a report.

 Task 1: Prepare the lab environment


• Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab04\Starter
folder as Administrator.

 Task 2: Deploy reports


• Open the AWReports.sln solution in the D:\10778A\Labfiles\Lab04\Starter folder with SQL Server Data
Tools.

• Review the contents and deployment properties of the project, and then deploy it.
4-38 Managing Report Execution and Delivery

 Task 3: Configure a shared data source


• In the Reports document library in the http://mia-sqlbi SharePoint site, view the dependent items of
the AdventureWorksDW data source and confirm that this data source is used by the Monthly
Sales Report report.

• Edit the data source definition for the AdventureWorksDW data source and configure it to use the
following stored Windows credentials:

• User Name: ADVENTUREWORKS\ServiceAcct

• Password: Pa$$w0rd

 Task 4: Configure a report


• In the Reports document library in the http://mia-sqlbi SharePoint site, manage the processing
options for the Monthly Sales Report report, and configure it to use cached data. The cached report
should expire on a custom schedule at midnight every day.
• View the report and note the execution time. Then wait a few minutes and view the report again,
verifying that the execution time has not changed since the previous view because a cached instance
is rendered.

Results: After this exercise, you should have configured a shared data source to use stored credentials,
and configured a report to display a cached instance.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-39

Exercise 2: Implementing a Standard Subscription


Scenario
The senior sales executive at Adventure Works wants to receive the sales report in Microsoft Excel format
by email. To accomplish this, you intend to have the executive create a subscription, and you want to test
the functionality before providing instructions to the executive.

The main tasks for this exercise are as follows:


1. Subscribe to a report.

2. Verify the subscription.

 Task 1: Subscribe to a report


• In the Reports document library in the http://mia-sqlbi SharePoint site, view the Monthly Sales
Report report.

• On the Actions menu, click Subscribe and create a subscription with the following settings:
• Delivery Extension: E-Mail
• To: student@adventureworks.msft

• Comment: The sales report is attached

• Show report inside message: Selected


• Format: Excel

• Delivery Event: On a custom schedule in two minutes from the current time (You can determine
the current system time by starting a command prompt window and entering the command
time /T)

• Parameters: Use report default value

 Task 2: Verify the subscription


• In the Reports document library in the http://mia-sqlbi SharePoint site, in the drop-down list for the
Monthly Sales Report report, click Manage Subscriptions.

• View the information about the subscription you created in the previous task. Then wait for two
minutes and refresh the page until the Last Results column indicates that mail was sent to
student@adventureworks.msft.

• View the contents of the C:\inetpub\mailroot\Drop folder and verify that an email message was sent.

• Open the email message and verify that it contains the report in Microsoft Excel format.

Results: After this exercise, you should have created a standard subscription that delivers a report by
email.
4-40 Managing Report Execution and Delivery

Exercise 3: Implementing a Data-Driven Subscription


Scenario
A number of business users want to receive the sales report by email. However, the users have expressed a
preference for a variety of formats and subscription options. You have decided to use a data-driven
subscription to deliver the report to these users.

The main tasks for this exercise are as follows:


1. Create a table of subscription data.

2. Create a data-driven subscription.

3. Verify the subscription.

 Task 1: Create a table of subscription data


• Use SQL Server Management Studio to open the Subscription Table.sql script file in the
D:\10778A\Labfiles\Lab04\Starter folder. When prompted, use Windows authentication to connect to
the database engine on the localhost server.
• Review the script, and note that it creates a table named ReportSubscriptions, which contains the
following columns:
• SubscriptionID – a unique primary key

• RecipientEmail – the email address of a subscription recipient

• ReportFormat – the format in which the report should be rendered.


• Linked – a Boolean value that indicates whether the subscription email should include a link to
the report on the report server.

• Execute the script and close SQL Server Management Studio.

 Task 2: Create a data-driven subscription


• In the Reports document library in the http://mia-sqlbi SharePoint site, in the drop-down list for the
Monthly Sales Report report, click Manage Subscriptions.

• Click Add Data-Driven Subscription and add a subscription with the following settings:

• Give the report the description Weekly Sales Report, and configure it to use the
AdventureWorksDW shared data source to retrieve subscription data with the following query.

SELECT * FROM ReportSubscriptions

• Use the report default value for the CalendarYear parameter.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 4-41

• Use the E-Mail delivery type with the following settings:

To: Select a value from the database (select RecipientEmail)

Include Report: True

Render Format: Select a value from the database (select ReportFormat)

Subject: Specify a static value (enter Weekly sales report)

Comment: Specify a static value (enter The weekly sales report is attached)

Include Link: Select a value from the database (select Linked)

• Schedule delivery on a custom schedule on the current day, two minutes from the current time
(You can determine the current system time by starting a command prompt window and
entering the commands and time /T. You can also use the command echo %date% to
determine the current day and date)

 Task 3: Verify the subscription


• In the Reports document library in the http://mia-sqlbi SharePoint site, in the drop-down list for the
Monthly Sales Report report, click Manage Subscriptions.
• View the information about the subscription you created in the previous task. Then wait for two
minutes and refresh the page until the Last Results column indicates that the subscription has been
processed for 3 deliveries.

• View the contents of the C:\inetpub\mailroot\Drop folder and verify that three email messages were
sent.
• Open the email messages and verify that they contain the report in Excel, Word, and embedded
HTML formats.

Results: After this exercise, you should have created a data-driven subscription that delivers a report to
multiple recipients and in multiple formats by email.
4-42 Managing Report Execution and Delivery

Module Review and Takeaways

Review Questions
1. How can you ensure that the sales manager can view reports that are published in a SharePoint
library?

2. You want to reduce the time it takes to render a report that contains a lot of data. How can you
achieve this?

3. You want to publish a report as an Excel document in a SharePoint document library on a weekly
basis. How can you accomplish this?
5-1

Module 5
Creating Multidimensional Databases
Contents:
Lesson 1: Introduction to Multidimensional Analysis 5-4

Lesson 2: Creating Data Sources and Data Source Views 5-15


Lesson 3: Creating a Cube 5-21

Lesson 4: Overview of Cube Security 5-28


Lab 5: Creating a Multidimensional Database 5-39
5-2 Creating Multidimensional Databases

Module Overview

The fundamental purpose of using Microsoft® SQL Server® Analysis Services (SSAS) online analytical
processing (OLAP) solutions is to build cubes that you can use to perform complex queries and return the
results in a reasonable time. Typically, you use SQL Server Data Tools to develop cubes.
Multidimensional databases, which are also known as OLAP cubes, connect to relational databases by
using connection information in data sources and data source views. With the addition of dimensions and
measures, they make it possible to navigate aggregated data by using these dimensions.

A simple example could have a Sales Value measure and Time, Product, and Customer dimensions. You
can navigate the dimensions to find the total sales value for the previous month, a specific customer, and
a particular product.

Organization of data in this way has many benefits including:

• Measures are preaggregated, enabling extremely fast queries when compared to relational databases.
• Multidimensional structures are logical and straightforward to navigate for information workers who
use tools such as Microsoft Excel®.

• It is possible to create perspectives of the cube to focus on key areas of data and make the pertinent
facts even more accessible.

This module provides an introduction to multidimensional databases and introduces the core components
of an OLAP cube.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-3

After completing this module, you will be able to:

• Describe the considerations for a multidimensional database.

• Create data sources and data source views.

• Create a cube.

• Implement security in a multidimensional database.


5-4 Creating Multidimensional Databases

Lesson 1
Introduction to Multidimensional Analysis

Multidimensional analysis that uses OLAP requires the creation of OLAP cubes alongside data sources and
data source views. This lesson describes data sources, data source views, and the core components of a
cube: dimensions, measures, and measure groups.
After completing this lesson, you will be able to:

• Identify the business problems that multidimensional analysis addresses.

• Describe the core concepts of multidimensional analysis.


• Define a data source.

• Define a data source view.

• Describe a dimension.

• Define measures and measure groups.

• Create an OLAP cube.

• Describe the advantages of using SSAS as an OLAP platform.

• Identify the software requirements for multidimensional analysis.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-5

The Business Problem

Most database systems are designed for online transaction processing (OLTP). Many small updates and
inserts are happening in real time and data is stored at the most granular level possible. This level of detail
is required and is useful for many operations, but there are also many instances when these systems are
not optimal.

For example, Adventure Works sells bicycles and associated accessories. It is vital that every item from
every sale is recorded and these updates to the database must happen nearly instantaneously. The
problem occurs when the trading manager requires a broad overview of sales for the past month by
product category. The query to generate this data involves filtering all sales to find only those that occur
in the past month and then grouping them by product category before calculating the total sales by
product group. Not only is this query very slow in itself, but it causes locking and contention on the
database, which slows down its primary role as a transactional system.

OLTP systems have several limitations for use as a source of data for reporting and analysis:

• Aggregated spanning queries are slow to generate.

• Large queries can cause performance issues for transactional workloads.

• Normalized relational data models are not intuitive for business users.
5-6 Creating Multidimensional Databases

The Concepts of Multidimensional Analysis

Multidimensional analysis takes a data warehouse and stores the data in a multidimensional cube. The
cube consists of measures, which are the values that are aggregated, and dimensions, which are the axes
of the cube and give the measures their context.

For example, a sales cube might have Sales Value and Units Sold measures and Time, Product, and
Customer dimensions.
The dimensions enable you to drill down through different layers of data by using a hierarchy. For
example, you can initially view sales by year, drill down to sales by month, and then drill down further to
sales by day.
You can also filter by using dimension values that use slicing and dicing:

• Slicing. Involves using a member of one dimension to provide a slice of the cube. For example, you
could slice a cube by 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.
One key difference with a relational system, or the new tabular data model, is processing. The
aggregations of measures are calculated when the cube is processed. This enables you to perform the
complex queries when the system has performance capacity, perhaps at night. When business users run
the queries, results are extremely fast because the complex processing has already been done.

SQL Server Analysis Services provides a platform for multidimensional databases that contain OLAP cubes.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-7

Data Sources

A data source is an object that provides a SQL Server Analysis Services database with the information that
is needed for it to connect to a source of data for the cubes it contains. Analysis Services can access data
from one or more sources of data. 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, SQL Server Analysis Services can use virtually any database
as a data source and abstract the underlying data model with a data source view.

At a minimum, a data source includes an identifier, a name, and a connection string. The connection
string that is used to access the source data specifies the following information:
• The provider name.

• The information that is needed to connect to the data source by using the specified provider. The
property settings for particular data source objects vary according to the provider.

• Other properties that the provider supports or requires.


5-8 Creating Multidimensional Databases

Data Source Views

A data source view is used to define the specific tables that are retrieved from the data source. It can also
change the presentation of those tables and their columns to make it more user friendly to users of
Analysis Services, for example by changing column names.

A data source view contains the following items:

• A name and a description.


• A definition of any subset of the schema retrieved from one or more data sources, up to and
including the whole schema, including the following:

• Table names
• Column names

• Data types

• Nullability

• Column lengths

• Primary keys

• Primary key–foreign key relationships


• Enhancements to the schema from the underlying data sources, including the following:

• Friendly names for tables, views, and columns.

• Named queries that return columns from one or more data sources (that show as tables in the
schema).

• Named calculations that return columns from a data source (that show as columns in tables or
views).
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-9

• 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).

• Logical primary key–foreign key relationships between tables, views, and named queries.
You can create multiple diagrams that show different subsets of the data source view. Unlike different
data source views, different diagrams reference the same schema. Therefore, any changes that you make
in one diagram apply to all other diagrams in the data source view. Diagrams are useful when you create
multiple cubes within the same solution.
5-10 Creating Multidimensional Databases

Dimensions

Dimensions provide the context for the facts that are stored in the OLAP cube. If you visualize an OLAP
cube as a physical cube, the dimensions are the axes of the cube. The dimension has a key attribute that
enables SSAS to join records to related data in the fact table.

Dimensions are hierarchical, not flat. Therefore, a time dimension typically has years, months, and days
and a geography dimension typically has country, state, and town. A dimension can have more than one
hierarchy, enabling you to drill down from year to month to day, but using another hierarchy to drill
down from year to week to day.
Dimensions can also be unbalanced and ragged. An unbalanced dimension does not have the same
number of levels in every branch. For example, 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 is a particular type of unbalanced dimension where there are
missing or duplicated levels in the hierarchy. For example, in a hierarchy that contains Continent, Country,
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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-11

Measures and Measure Groups

There is a particular dimension called the Measures dimension. Measures are the facts that are
aggregated at each intersection of dimension members. They are typically numeric and additive, and are
aggregated by using a sum calculation, although there are measures that do not meet these criteria.

Measures are also part of a dimension because there are often multiple measures in a cube. For example,
you could select the state of California from the Geography dimension, the year 2010 from the Time
dimension, and the Sales Units measure from the Measures dimension. You could then modify this by
changing to the Sales Amount measure from the Measures dimension.
You can use a measure expression to define the value of a measure. This enables you to apply calculations
to measure values, or use multiple columns from a fact table in a measure expression.

You can also use attribute columns from dimension tables to define a measure. These attributes would not
typically contain facts and would not typically be additive, but could provide useful information. For
example, you could use them to provide a count of members.

Measures are grouped into measure groups based on their underlying fact tables. Measure groups are
used to define the relationship between the dimensions and the 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.
5-12 Creating Multidimensional Databases

Cubes

A cube is the unit that defines the 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 nature of relational tables. However, almost all cubes have more
than three dimensions.
Cubes bring together all of the functionality of dimensions and measures and enable you to display this in
a user-friendly interface such as an Excel PivotTable table. The PivotTable interface with SSAS enables you
to display aggregated measure data and slice and dice this data by using dimension members.
Cubes contain all of the settings that define storage, aggregation levels, and processing frequency.

By providing a multidimensional structure and the ability to use a user-friendly interface such as Excel,
cubes are highly intuitive for business users to navigate.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-13

SQL Server Analysis Services as an OLAP Platform

SSAS provides a service in which you can host multidimensional databases. These databases contain the
data sources, data source views, dimensions, measures, and cubes that business users need to perform
multidimensional analysis.

SSAS is a scalable enterprise OLAP solution. It optimizes performance by using innovative techniques such
as block computation and is highly scalable due to tools such as the Aggregation Design Wizard.
SSAS provides you with a wide range of tools for your OLAP data including key performance indicators
(KPIs), multilingual translation capabilities, and data mining analysis on your data. This functionality will be
covered in more detail in subsequent modules.
Microsoft provides intuitive front-end tools through Microsoft Office and Microsoft SharePoint®,
enabling business users to quickly access the data that they need with little or no knowledge of the
underlying system.
5-14 Creating Multidimensional Databases

Software Requirements for Multidimensional Analysis

Multidimensional analysis is supported in SQL Server Standard, Business Intelligence, Enterprise,


Developer, or Evaluation edition. To install SSAS for multidimensional analysis, your server must meet the
same software prerequisites as the SQL Server database engine.

• Windows Server® 2008 Service Pack 2 (SP2) or R2 (64-bit) or later

• SQL Server 2012 Standard, Business Intelligence, Enterprise, Developer, or Evaluation Edition.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-15

Lesson 2
Creating 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. This logical data model is called a data source view.
Data source views enable you to define a subset of the data that populates a large data warehouse.
This lesson describes how to create and modify a data source.

After completing this lesson, you will be able to:

• Describe how to create a data source.


• Describe how to create a data source view.

• Describe how to modify a data source view.


5-16 Creating Multidimensional Databases

Creating a Data Source

You can use the Data Source Wizard in SQL Server Data Tools to define one or more data sources for an
SSAS project. Data sources use a Connection object that defines the connection string. In the first step of
the Data Source Wizard, you must define the Connection object or use an existing Connection object.

The default provider for a new connection is the Native OLE DB\SQL Server Native Client provider. Other
supported providers include:
• SQL Server 7.0 using the SQL OLE DB provider or the .NET native OLE DB provider.

• SQL Server 2000 using the SQL OLE DB provider or the .NET native OLE DB provider.

• SQL Server using the SQL OLE DB provider or the .NET native OLE DB provider.
• Oracle using the Oracle OLE DB provider or the OracleClient.NET native OLE DB provider.

• Microsoft Access® with the Microsoft Office 12.0 Access Database Engine OLE DB provider.

• Teradata v2R6 with the OLE DB 1.3 provider from NCR (x86 only).

If you have an existing data source that is 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 simply copy properties
of the first data source object into a new data source object.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-17

Creating a Data Source View

SSAS design tools use data source views to maintain a cache of relational metadata and to take advantage
of some of the annotations within a data source view. Advantages of this approach include:

• A data source view makes available only the tables that OLAP and data mining objects require by
describing a subset of tables and views in a data source.

• A data source view handles the layout of tables, filters, Structured Query Language (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.
• You can define a data source view by using the Data Source View Wizard in SQL Server Data Tools.
One of the benefits of data source views is that they can bring together data from multiple data
sources. To do this, you can specify secondary data sources in the Data Source View Designer. You
can also use the Data Source View Designer to browse source data.
5-18 Creating Multidimensional Databases

Modifying a Data Source View

After you have created a data source view, you can modify it to make the data more user-friendly. Often,
underlying data sources use naming conventions to help developers understand the schema. Also the
underlying data does not typically store additional formatting information. Using the Data Source View
Designer, you can make several modifications to a data source view without modifying the underlying
source data or database schemas. This enables you to present user-friendly names and formatting without
making any changes to the source database systems. For example, you can:

• Use the FriendlyName property to specify a name for a column from a table or view that is easier for
users to understand or more relevant to the subject area.
• Create a named query and named calculations that enable you to extend the relational schema of
existing tables in a data source view without modifying the underlying data source.

• Create logical primary keys and relationships for improved performance.

• Create diagrams to reduce the visual clutter when you only want to view a subset of the tables in the
data source view.

To make changes to a data source view:


1. Right-click the data source view.

2. Click Properties.

3. In the Properties pane, specify settings such as FriendlyName.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-19

Demonstration: Creating a Data Source and a Data Source View

 Task 1: Create a new SSAS project


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the
D:\10778A\Demofiles\Mod05 folder, run Setup.cmd as Administrator.

2. Click Start, click All Programs, click Microsoft SQL Server 2012, and then click SQL Server Data
Tools.

3. Click New Project.

4. Select Analysis Services Multidimensional and Data Mining Project.


5. In the Name field, type Demo.

6. In the Location field, type D:\10778A\Demofiles\Mod05, and then click OK.

 Task 2: Create a data source for the AdventureWorksDW relational database


1. In Solution Explorer, right-click Data Sources, and then click New Data Source.

2. On the Welcome to the Data Source Wizard page, click Next.


3. On the Select how to define the connection page, click New.

4. In the Server name field, type localhost.

5. In the Select or enter a database name field, click AdventureWorksDW, and then click OK.
6. Click Next.

7. Click Use a Specific Windows user name and password, and enter the user name
ADVENTUREWORKS\Student and the password Pa$$w0rd. Then click Next.
8. In the Data source name field, type AdventureWorks Demo DS, and then click Finish.
5-20 Creating Multidimensional Databases

 Task 3: Create a data source view


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. Ensure that AdventureWorks Demo DS is selected, and then click Next.

4. Select the DimCustomer, DimDate, DimGeography, DimProduct, and FactInternetSales tables,


and then add them to Included objects.

5. Click Next.
6. In the Name field, type AdventureWorks Demo DSV, and then click Finish.

 Task 4: Modify the data source view


1. In Solution Explorer, right-click AdventureWorks Demo DSV, and then click Open.

2. In Data Source Designer, navigate through the database diagram until you locate the
FactInternetSales table.

3. Click the table name of the FactInternetSales table and press F4.

4. In the Properties pane, change the FriendlyName property to Internet Sales.


5. Right-click the DimCustomer table, and then click New Named Calculation.

6. In the Column name field, type Full Name.

7. In the Expression field, type FirstName + ' ' + LastName, and then click OK.

8. On the File menu, click Save All. Then minimize SQL Server Data Tools. You will return to it in a later
demonstration.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-21

Lesson 3
Creating a Cube

A cube is a multidimensional structure that contains 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 defined every
possible summarized value.
This lesson describes how to create and modify cubes in addition to some considerations for cube design.
After completing this lesson, you will be able to:

• Create a multidimensional cube.

• Describe the considerations for time dimensions.

• Modify a cube by using the Cube Designer.

• Browse a multidimensional cube.


5-22 Creating Multidimensional Databases

Options for Creating a Cube

Use the Cube Wizard to create a cube quickly and easily:

• The Cube Wizard guides you through the steps to specify the data source view and measures in the
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, using the Dimension Wizard, and then add them to a
cube.

• You can create a cube by choosing the relevant data source and data source view. Alternatively, you
can build the cube without using a data source and then subsequently generate the database
schema. Another option is to create the cube and enable SSAS to create the underlying schema to
support 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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-23

Considerations for Time Dimensions

Most cubes include a time dimension, although some solutions do not use time and instead use another
factor to delineate the data, such as a unit of work or a project.

Often, time requires multiple hierarchies. For example, you could have a hierarchy that has Years, Weeks,
and Days and a hierarchy that has Years, Months, and Days, but not a hierarchy that has Years, Months,
Weeks, and Days because Weeks do not fit into Months. Therefore, you need two hierarchies to represent
this. You can create multiple time dimensions or one time dimension that has multiple hierarchies. In the
previous example, you would typically create one time dimension that has multiple hierarchies, but if you
require a time dimension for a different purpose, such as Fiscal Time, you would typically create it as a
separate dimension.

Time dimensions are distinct from other dimensions because SSAS contains inherent functionality to
group the members into levels. SSAS has built-in logic that puts the correct days into the correct months
and the correct months into the correct quarter. This is the only dimension type that behaves in this way
because, for example, SSAS has no way of detecting which product should be assigned to each product
group.
You can either use a Server Time dimension, or use a dimension table that contains time data. A Server
Time dimension avoids joins and can be faster to process. However, many time dimensions include
additional data, for example, corporate time information such as quarters, which do not follow calendar
quarters, or public holidays. A time dimension table enables you to add detail to the time members. This
enables you to store the additional properties for each date.

Server time dimensions contain hierarchies, levels, and attributes, but these are stored on the server rather
than in a separate dimension table.
5-24 Creating Multidimensional Databases

The Cube Designer

Although the Cube Wizard creates the cube, many of the properties of the cube will be set by using the
Cube Designer. The Cube Designer in SQL Server Data Tools enables you to view and edit the properties
of the cube and its objects, and to browse cube data:

• You can modify cube structure, dimension usage, and calculations.

• You can add KPIs and actions, change cube partitioning and storage, create aggregations, create
perspectives on cube data, and add translations to localize cube data.

• You can also browse the cube, to see how modifications will affect the cube.

Note Creating and modifying a cube is covered in more detail in Module 6, “Working with
Cubes and Dimensions.”
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-25

Browsing a Cube

SSAS enables you to browse the cube from within SQL Server Data Tools. This enables you to test the cube
without having to switch backward and forward between a client application and SQL Server Data Tools.
Furthermore, you can change the security context and browse the cube as another user. Before browsing
cube data in the Cube Browser tab, the cube must be deployed.

After it is deployed, you can click the Browser tab from within the Cube Designer to browse the cube and
see its measures aggregated by dimensions.

Additionally, you can click the Analyze in Excel icon on the toobar in the Browser tab to create an Excel
workbook with a connection to the cube. This enables you to see how the cube behaves when used as a
source for an Excel PivotTable.
5-26 Creating Multidimensional Databases

Demonstration: Creating and Browsing a Cube

 Task 1: Create a cube


1. Ensure that you have completed the previous demonstration in this module.
2. Maximize SQL Server Data Tools, which should be open with the Demo project loaded.

3. In Solution Explorer, right-click Cubes, and click New Cube.

4. On the Welcome to the Cube Wizard page, click Next.


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
Internet Sales as a measure group table, and click Next.
7. On the Select Measures page, clear the Internet Sales checkbox to clear all selections, and then
select the Total Product Cost and Sales Amount measures. Then click Next.

8. On the Select New Dimensions page, clear the parent Internet Sales checkbox, and click Next.
9. On the Completing the Wizard page, change the cube name to Demo Cube and click Finish. The
cube is created and opened in the cube designer.

 Task 2: Deploy and browse a cube


1. In Solution Explorer, right-click Demo and click Deploy. If prompted, enter the password Pa$$w0rd
for the ADVENTUREWORKS\Student user. Then wait for the deployment process to finish.
2. In the cube designer, click the Browser tab.

3. In the Metadata pane, expand Measures and expand Internet Sales. 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 Internet sales is shown.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-27

5. In the Metadata pane, note that the wizard has created dimensions for the DimCustomer and
DimProduct tables. It has also determined that there are three relationships defined between the
Internet 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 of the dimensions and note 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 and drop it to the left of the Sales
Amount value in the grid. The browser now shows the aggregated sales amount totals for each
product key.

 Task 3: Customize cube measures and dimensions


1. In the cube designer, click the Cube Structure tab. Then, in the Measures pane, expand Internet
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 Customer and click Rename, and change the name of the
dimension to Customer. Then rename Dim Product to Product.
4. Right-click the Product dimension and click Edit Dimension. This opens the dimension designer for
the Dim Product dimension (the dimension is named Product in the Demo Cube cube, but still
named Dim Product in the database).

5. In the Data Source View pane, in the DimProduct table, drag the EnglishProductName field to the
Attributes pane.

6. In the Attributes pane, right-click English Product Name and click Rename. Then rename the
attribute to Product Name.

7. In Solution Explorer, right-click Demo and click Deploy. If prompted, enter the password Pa$$w0rd
for the ADVENTUREWORKS\Student user. Then wait for the deployment process to finish.
8. Click the Demo Cube.cube [Design] tab to return to the cube designer, and then in the cube
designer, click the Browser tab.

9. On the Browser tab, click the Reconnect button in the upper left. If the grid contains any data from
previous queries, right-click in the grid and click Clear Grid.
10. In the Metadata pane, expand Measures and Internet Sales, and drag Cost to the Drag levels or
measures here to add to the query area.
11. 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.

12. On the File menu, click Save All, and then minimize SQL Server Data Tools. You will use it again in a
later demonstration.
5-28 Creating Multidimensional Databases

Lesson 4
Overview of Cube Security

After you install an instance of SSAS, only the members of the server role have server-wide permissions to
perform any task within the instance of SSAS. By default, no other users have any 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.

After completing this lesson, you will be able to:


• Describe the SSAS security model.

• Describe the server role.

• Describe database roles.


• Explain cube permissions.

• Describe cell permissions.


• Describe dimension security.

• Test cube security.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-29

SSAS Security Model

SSAS relies on Windows® authentication to authenticate users. After a user has been authenticated, SSAS
controls permissions within the databases based on the user’s role membership:

• Principals are entities that can request SQL Server resources.

• Securables are the resources to which the SQL Server Database Engine authorization system regulates
access.
• SSAS has a single fixed server role for administrators. Members of this role have full permissions to
perform any action in the instance.

• Administrators can create database roles for users. You can grant these roles user access and database
administrator rights. Role permissions are database-specific.

• You can grant database role permissions for database and cube dimensions, individual dimension
members, cubes, individual cells within a cube, mining structures, mining models, data sources, and
stored procedures.

Note At least one user must be specified during the installation of an SSAS instance,
otherwise the instance will be inaccessible.
5-30 Creating Multidimensional Databases

Adding Members to the Server Role

The server role is a fixed role at the server level. You cannot change its permissions and you cannot add
further server roles.

The server role gives the administrator access to SSAS. Members of this role have access to all SSAS
databases and objects on that instance of SSAS. To give lower-level administrative rights, you should
consider adding users to a database role and granting the relevant permissions to that.
Use SQL Server Management Studio to add members to the server role. You can add members to the
server role on the Security page of the Analysis Server Properties dialog box.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-31

Creating Database Roles

To assign permissions to users, or to administrators who do not have server-wide administrative rights,
you should create database roles.

Initially, you should decide what levels of access are required within your organization including basic
users through power users, managers, and department administrators. Remove groups with duplicated
permissions and, where possible, consolidate groups with similar permissions as long as this does not give
any sensitive permission to another group. After you have defined the groups, you should then create the
groups and add users to these groups.
To create a database role:
• You can create database roles by using SQL Server Management Studio or SQL Server Data Tools.

• In SQL Server Management Studio, expand the database, and then right-click the Roles folder to add
a new role.

• In SQL Server Data Tools, roles are displayed in Solution Explorer and you can add them from the
Project menu.
5-32 Creating Multidimensional Databases

Granting Data Source and Cube Permissions

To access data within the database, users must be members of a role that has permissions to access the
cube. Permissions to access a data source are not required to access cube data:

• Users do not typically need access to data sources.

• You can grant roles read or read/write permission to cubes within the database. By default, a role that
has permissions for the cube has:
• Access to the individual cells within the cube.

• Read permissions on the dimensions and dimension members that the cube contains.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-33

Granting Cell Permissions

A role that has read-only or read/write permissions is granted permissions on the individual cells until you
apply cell security. However, by applying cell permissions, you can override the default permissions that
are inherited from cube permissions. By default, cell permissions apply to all cells in the cube, but if you
grant access to one or more cells, the role is denied access to all other cells until you grant permissions on
them. Use a Multidimensional Expressions (MDX) statement to limit the range of cells to which the
permissions apply.

Note MDX statements are discussed in more detail in Module 8, “Introduction to MDX.”

Read access and read/write access are self-explanatory, but there is also read-contingent access. Read-
contingent access gives you permissions on a calculated cell only if you have permissions on all cells that
are referenced in the calculation. For example, the Sales Manager role has read access to the Sales Value
measure, but no access to the Product Cost measure. The Sales Manager role has also been granted read
access to the Profit calculated measure. The Profit measure is Sales Value minus Product Cost. With
read access, members of the Sales role can see the results of the Profit measure and, because they also
have access to the Sales Value measure, can infer the Product Cost measure even though they have no
direct access to this measure. If you apply read-contingent access to the Profit measure, users would only
be able to see the results if they have permission to see both the Sales Value and Product Cost data.
5-34 Creating Multidimensional Databases

Granting Dimension and Dimension Data Permissions

By default, a role that has access to a cube has read access to all of the dimensions in the cube. You can
modify this access and deny access to one or more members in the dimension.

The default access is read-only, so users cannot process the cube. However, if you change the permissions
of a relevant role to read/write, it will enable users to process the cube.

By default, permissions apply to all dimension members, but you can write an MDX statement to define a
subset of the dimension.

Note MDX statements are discussed in more detail in Module 8, “Introduction to MDX.”

You can use an MDX statement for an allowed member set or a denied member set. You can also define a
default member to control which member users see when they first connect to the cube. You can also
define this by using MDX, enabling you to create versatile default members. For example, you could use
an MDX statement to use the current calendar year as the default member of a time dimension.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-35

Testing Security Permissions

After you have configured security for an SSAS database, it is important to test your security settings and
permissions. Fortunately, you can test permissions without logging off from your Windows session
through SQL Server Data Tools.

The most straightforward method for testing security is to use SQL Server Data Tools. This enables you to
test and modify security in one place. Using SQL Server Data Tools to test user permissions:
• In the Cube Designer, on the Browser tab, you can change user to an individual or to a role to test
security by clicking the Change User button.
• In Role Designer, on the Cell Data tab, you can click the Test cube security hyperlink. This has the
advantage that it saves objects if necessary and defaults to the current role.

You may also need to test security from SQL Server Management Studio, for example, if you are testing
role membership, or you may want to test a client application such as Excel. Using other applications to
test user permissions:

• You can use the Windows Run as feature to start an application such as SQL Server Management
Studio, and test administrative permissions such as those granted through membership in the server
role or the database-level Full Control (Administrator) permission.
5-36 Creating Multidimensional Databases

Demonstration: Applying Cube Security

 Task 1: Create a role


1. Ensure that you have completed the previous demonstration in this module.
2. Maximize SQL Server Data Tools, which should be open with the Demo project loaded.

3. In Solution Explorer, right-click Roles, and click New Role. Then 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 as well, click Yes.
4. In the role designer, on the General tab, note that by default this role has no database permissions.

5. On the Membership tab, note that this is where you can add Windows users and groups to the role.
6. On the Data Sources tab, note that by default the role has no access to any data sources.

7. On the Cubes tab, change the Access value for Demo Cube to Read. This allows the role to access
the cube and read its data.

8. On the Cell Data tab, note that this is where you can specify MDX statements that define cells in the
cube which you want to permit or deny this role to access.

9. On the Dimensions tab, note that the role has Read access to all dimensions in the database. Then in
the Select Dimension Set list at the top of the page, click Demo Cube cube dimensions and note
that these permissions are inherited by the dimensions in the Demo Cube cube.

10. On the Dimension Data tab, in the Dimension list, under Demo Cube, select Measures Dimension.
Then on the Basic tab, clear the checkbox for the Cost measure.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-37

11. In the Dimension list, under Demo Cube, select Product, and on the Basic tab, in the Attribute
hierarchy list, select Product Name.

12. Select Deselect all members. Then scroll to the bottom of the list of product names and select only
the products that begin with the word Touring.
13. On the File menu, click Save All.

 Task 2: Test a role


1. In Solution Explorer, right-click Demo and click Deploy. If prompted, enter the password Pa$$w0rd
for the ADVENTUREWORKS\Student user.

2. When deployment is complete, in Solution Explorer, double-click Demo Cube.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 Internet Sales, and drag Sales Amount and Cost to
the Drag levels or measures here to add to the query area. Then expand the Product dimension
and drag Product Name to the left of the measure values. The browser shows cost and sales amount
for all products.

5. In the top left area of the browser window, click the Change User button. Then, 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.
6. Note that the grid has been cleared. Then, in the Metadata pane, expand Measures and Internet
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.

7. Expand the Product dimension and drag Product Name to the left of the measure values. The
browser shows sales amount for only the Touring products.

8. On the File menu, click Save All, and then close SQL Server Data Tools.
5-38 Creating Multidimensional Databases

Lab Scenario

You have created a reporting solution at Adventure Works Cycles, but some business analysts have
requested an analytical solution that enables them to “slice and dice” business data to perform their own
business analysis.

To accomplish this, you will create a multidimensional database that includes an OLAP cube.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-39

Lab 5: Creating a Multidimensional Database

Exercise 1: Creating a Data Source


Scenario
Users are finding the reporting solution at Adventure Works Cycles extremely useful, but many
information workers want to perform their own analysis of the data in Excel. To support this, you plan to
implement a multidimensional database. Initially, you need to create a connection and data source to the
data warehouse.
The main tasks for this exercise are as follows:

1. Prepare the lab environment.

2. Create a new SSAS project.

3. Create a data source for the AdventureWorksDW relational database.

 Task 1: Prepare the lab environment


• Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab05\Starter
folder as Administrator.

 Task 2: Create a new SSAS project


• Use SQL Server Data Tools to create a new SSAS project.

• Name the project Adventure Works OLAP, and then save it in the D:\10778A\Labfiles\Lab05\Starter
folder.
5-40 Creating Multidimensional Databases

 Task 3: Create a data source for the AdventureWorksDW relational database


• Use the Data Source Wizard in SQL Server Data Tools.

• The AdventureWorksDW database is on the local server.

• Use Windows authentication to connect to the data source.

• Use the ADVENTUREWORKS\Student account with the password Pa$$w0rd.

• Name the data source Adventure Works Data Warehouse.

Results: After this exercise, you should see the Adventure Works Data Warehouse.ds data source in the
Data Sources folder.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-41

Exercise 2: Creating and Modifying a Data Source View


Scenario
The AdventureWorksDW database includes a large amount of data that is not required by your users
and the tables use naming conventions that are confusing to business analysts. You need to define which
tables you require and then change the names of the tables to be more user-friendly. Users have also
requested that they can retrieve full names of customers in addition to their first, middle, and last names.

The main tasks for this exercise are as follows:

1. Create a data source view.

2. Modify the data source view

 Task 1: Create a data source view


• Use the Data Source View Wizard in SQL Server Data Tools.

• Use the Adventure Works Data Warehouse data source.


• Include the DimCustomer, DimDate, DimGeography, DimProduct, and FactInternetSales tables.

• Name the data source view Adventure Works DSV.

 Task 2: Modify the data source view


• Use the Data Source View Designer in SQL Server Data Tools to:
• Change the FriendlyName property of FactInternetSales to InternetSales.

• Change the FriendlyName property of the remaining tables to remove the “Dim” prefix from the
name.
• Verify that the modified data source resembles the following image.

• Add a named calculation named Full Name to the Customer table. The expression should
concatenate the FirstName, MiddleName (if it exists), and LastName columns.

Results: After this exercise, you have created a data source view for the cube that you need to create.
5-42 Creating Multidimensional Databases

Exercise 3: Creating and Modifying a Cube


Scenario
Now that you have created a data source view, you are ready to create a cube that enables business users
to perform multidimensional analysis on the data. You will then modify the cube to give the measures in
the cube user-friendly names to make analysis simpler for your business users. You will also add additional
attributes to dimensions to provide users with multiple ways to aggregate the measures.

You need to modify the attributes of the dimension used for dates in your cube to ensure uniqueness
across temporal periods. For example, the month of January is not unique because it occurs in every year,
so you must modify the month attribute so that its key is based on both month and year, and then specify
which of these key columns is to be used when displaying the attribute name.

The main tasks for this exercise are as follows:

1. Create a cube.

2. Modify the cube.

3. Modify dimensions.

4. Modify attribute columns.


5. Browse the cube.

 Task 1: Create a cube


• Use the Cube Wizard in SQL Server Data Tools to create a new cube.
• Build the cube by using existing tables.

• Have the Cube Wizard suggest measure group tables.

• Use all suggested dimensions other than Internet Sales.


• Name the cube Adventure Works Cube.

• Verify that the cube resembles the following image.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-43

 Task 2: Modify the cube


• Change the name of the Unit Price Discount Pct measure to Unit Price Discount Percent.

• Change the name of the Tax Amt measure to Tax Amount.

 Task 3: Modify dimensions


• Modify the Customer dimension in Dimension Designer.

• Add the City, StateProvinceName, EnglishCountryRegionName, and SalesTerritoryKey


attributes from the Geography table to the dimension.

• Add the CustomerAlternateKey, Title, FirstName, MiddleName, LastName, and Full Name
attributes from the Customer table to the dimension.

• Verify that the modified dimension resembles the following image:

• Modify the Product dimension in Dimension Designer.

• Add the ProductAlternateKey, ProductSubcategoryKey, EnglishProductName, and ListPrice


attributes from the Product table to the dimension.
5-44 Creating Multidimensional Databases

• Verify that the modified dimension resembles the following image:

• Modify the Date dimension in Dimension Designer.


• Add the EnglishDayNameOfWeek, EnglishMonthName, MonthNumberOfYear,
CalendarQuarter, CalendarYear, and CalendarSemester attributes from the Date table to the
dimension.
• Verify that the modified dimension resembles the following image:
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-45

 Task 4: Modify attribute columns


• 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 the calendar semester, but displayed
using only the calendar semester value:

• In the properties for the Calendar Semester attribute, set the KeyColumns property so that the
key columns are CalendarYear followed by CalendarSemester.

• Set the NameColumn property so that the Source column value is Calendar Semester.

• Modify the Calendar Quarter attribute so that the keys that a quarter is uniquely identified by both
the calendar year and the calendar quarter, but displayed using only the calendar quarter value:

• In the properties of the Calendar Quarter attribute, set the KeyColumns property so that the
key columns are CalendarYear followed by CalendarQuarter.

• Set the NameColumn property so that the Source column value is Calendar Quarter.

• Modify the English Month Name 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:

• In the properties for the English Month Name attribute, change the Name property to Month.

• Set the KeyColumns property so that the key columns are Calendar Year followed by
MonthNumberOfYear.

• Set the NameColumn property so that the Source column value is EnglishMonthName.

 Task 5: Browse the cube


• Deploy the Adventure Works OLAP project, entering the user name ADVENTUREWORKS\Student
and the password Pa$$w0rd if prompted. Then use Cube Browser to view the Adventure Works
Cube cube.

• Add the Sales Amount and Internet Sales Count measures to the data area, and then drag the
Order Date.Calendar Year hierarchy to the left of the Sales Amount column. The cube browser
shows sales amounts and counts for multiple years as shown in the following image.
5-46 Creating Multidimensional Databases

• Open Microsoft Excel 2010, and then on the Data tab, make a connection to get external data from
Analysis Services.

• Your connection should connect to the localhost server by using Windows authentication.
• You should select the Adventure Works OLAP database.

• You should import the data as a PivotTable Report in cell A1 of the existing worksheet.

• When the PivotTable Field List pane is displayed, under Internet Sales, select Sales Amount; and
under Customer, select Full Name so that the PivotTable resembles the following image.

Results: After this exercise, you should have successfully deployed the cube and reviewed the
modifications made to ensure that they are reflected when users browse the cube.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 5-47

Module Review and Takeaways

Review Questions
1. What are some of the name matching methods available when creating a data source view?
2. How can you use the Cube Designer to configure a cube after it has been created?

3. After creating a data source by using the Data Source Wizard, what tool would you use to modify the
data source?
4. How do time dimensions differ from other dimensions?
5-48 Creating Multidimensional Databases
6-1

Module 6
Working with Cubes and Dimensions
Contents:
Lesson 1: Configuring Dimensions 6-3

Lesson 2: Defining Attribute Hierarchies 6-12


Lesson 3: Sorting and Grouping Attributes 6-21

Lab 6: Defining Dimensions 6-25


6-2 Working with Cubes and Dimensions

Module Overview

In Microsoft® SQL Server® Analysis Services, dimensions are a fundamental component of cubes. The
facts, or measures, provide the values that interest you, however, dimensions provide the business context
by which these measures are aggregated. Dimensions organize your data by category and show results
grouped by these categories such as product, customer, or month.

Dimensions in Analysis Services contain attributes that correspond to columns in dimension tables. These
attributes appear as attribute hierarchies and can be organized into user-defined hierarchies, or can be
defined as parent-child hierarchies based on columns in the underlying dimension table. Hierarchies are
used to organize measures that are contained in a cube.
This module provides an insight into the creation and configuration of dimensions and dimension
hierarchies.

After completing this module, you will be able to:

• Configure dimensions.
• Define attribute hierarchies.

• Sort and group attributes.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-3

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, can be used in multiple cubes, can be used
multiple times in a single cube, and can be linked between Analysis Services instances. A dimension that
exists independent of a cube is called a database dimension and an instance of a database dimension
within a cube is called a cube dimension.

After completing this lesson, you will be able to:

• Describe the concepts of a dimension.


• Edit dimensions with the Dimension Designer.

• Describe the dimension storage options.

• Describe the use of dimension attributes.


• Define the columns used to connect dimensions to the fact table, to display to users, and to use in
MDX calculations.

• Describe dimension types.


6-4 Working with Cubes and Dimensions

Dimension Concepts

Dimensions form the contexts for the facts, and define the aspects of the business by which the facts are
aggregated. For example, Product and Time dimensions might provide context to the SalesValue measure.

Dimensions are collections of attributes from tables or views. You can use dimensions in multiple cubes
and link to them from remote instances.

Attributes add meaning to dimensions. Each column in the dimension table can provide an attribute that
provides a piece of information about the dimension member. For example, a RetailStore dimension
might have Manager and PostalCode attributes.
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.

Attributes are typically arranged 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 other hierarchies could be defined with attributes such as Week, Quarter,
and Century.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-5

Every attribute that is defined within a dimension, by default, is part of a two level hierarchy known as an
attribute hierarchy. The top level is named ALL, the second level is the leaf level that contains values for
each individual member of the attribute. While they can help in browsing the data, typically the data
within an attribute hierarchy can be too large and difficult to navigate. As a result, attribute hierarchies are
often replaced with user defined hierarchies which enable you to define more levels and make the data
more manageable. For example, a Date attribute hierarchy has an ALL level and a second level containing
all the dates within the dimension. To make this more manageable, you replace the attribute hierarchy for
Date with a user defined hierarchy named Calendar Year that contains Year, Quarter and Month levels to
make the data easier to navigate within the hierarchy.

Analysis Services can add dimension intelligence to some dimensions. For example, time dimensions have
a fixed structure and this can be used by Analysis Services. It knows which months are in each quarter,
which days are in each month, and so on.
6-6 Working with Cubes and Dimensions

The Dimension Designer

Use the Dimension Designer to edit the attributes, levels, hierarchies, and translations of a dimension, and
to browse the dimension.

• Use the Dimension Structure tab to view and edit the attributes, levels, and hierarchies of the
dimension.

• Use the Attribute Relationships tab to create, modify or delete the attribute relationships of the
selected dimension.

• Use the Translations tab to view and edit the multi-language 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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-7

Configuring Dimension Storage

The two dimension storage modes in Analysis Services are Multidimensional OLAP (MOLAP) and
Relational OLAP (ROLAP). These storage modes define where, and in what structure type, the dimension
data is stored.

• Data for a dimension that uses MOLAP is stored in a multidimensional structure in the instance of
Analysis Services. This multidimensional structure is created and populated when the dimension is
processed. MOLAP dimensions provide better query performance than ROLAP dimensions.

• Data for a dimension that uses ROLAP is stored in the 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.
6-8 Working with Cubes and Dimensions

Configuring Dimension Attributes

The Cube Wizard and Dimension Wizard create attributes for a dimension. Other wizards and elements of
the Analysis Services user interface may further modify these attributes. These default settings are
sufficient in most situations, but you can use Dimension Designer to edit the attributes if necessary.

You can remove attributes from the dimension by right-clicking the attribute and clicking Delete.
Removing attributes from a dimension does not affect the data source view, which makes it possible for a
data source view to be used by multiple dimensions without forcing each dimension to use all of the same
attributes.
You can rename an attribute to provide a more meaningful or user-friendly name than the dimension
table. You can 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 be confusing for 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 the hierarchies or attributes. After you have created display folders,
you should 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 can also be used to add additional 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 and are not used to sort or group
members, but are often needed to provide additional detail to dimension members without having to
drill-down to relational data.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-9

Attribute Column Bindings

To control the output from attributes, you can define the column that connects to the fact table, the
column that users see, and an optional value column that you can use for MDX calculations.

• The KeyColumn is the column, or columns, that are used to connect to the fact table. This is typically
the primary key of the dimension table, and is used when you choose to order the hierarchy by key.

• The NameColumn provides the value that a user will see. This can provide more useful information
to a user than the key column. You can define a name column as a calculated column that you have
created in a data source view. For example, an Employee dimension might have an EmployeeID key
column, but you might want the name of the employee to be displayed. To do this, you can create a
calculated column based on first name and last name in the data source view, and then use this as the
name column.
• The ValueColumn is returned by the MDX MemberValue function. This allows you to create
calculations that are 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 it also allows the key column to hold a smaller value. A value from the key column
occurs in every row of the fact table and so reducing the size of this value makes the fact table
smaller and makes joins between the fact table and the time dimension faster.
6-10 Working with Cubes and Dimensions

Dimension Types

Initially all dimensions have a type of Regular, but you can also define the type of a dimension as Time,
Organization, Geography, BillOfMaterials, Accounts, Customers, Products, Scenario, Quantitative,
Utility, Rates, Channel, or Promotion.

In most cases the type of the dimension has no effect in Analysis Services and it is merely a value that is
passed to client applications. They could use this example to alter formatting, for example. However, there
are three types that have a functional effect in Analysis Services, the Time dimension type, the Currency
dimension type, and the Accounts dimension type.

Time Dimensions
If your time data is stored as a regular dimension (not as a server time dimension), and it has a Time
dimension type, you can add time intelligence. The Business Intelligence Wizard will create a hierarchy for
the dimension and enable you to use time-dependent MDX functions such as Periodstodate.

Currency Dimensions
Currency dimensions store values in one base currency and then convert the value to a local currency
based on the locale of the client. You must have a measure group that contains the exchange rate.
To create a currency dimension change the Type of the dimension Currency. You can then run the
Business Intelligence Wizard and this will design the currency conversion process.

Accounts Dimensions
Financial accounts are not standard dimensions. The aggregation of accounts is non-standard and without
a mechanism to add specific accounts functionality, you would have to create custom rollup formulas and
calculated members. Accounts dimensions are parent child dimensions with accounts being children of
other accounts.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-11

To create a financial account dimension set the dimension type to Accounts and then run the Business
Intelligence Wizard to add account intelligence to the dimension. The wizard will then guide you through
the process of defining individual accounts as an account type such as income or expense.

For More Information For more information about how to Add Account Intelligence to a
Dimension, see http://go.microsoft.com/fwlink/?LinkID=246781.

For More Information For more information about Dimension Types, see
http://go.microsoft.com/fwlink/?LinkID=246782.
6-12 Working with Cubes and Dimensions

Lesson 2
Defining Attribute Hierarchies

Hierarchies defined the multi-level structure of a dimension and the relationships between the levels in a
hierarchy can affect query and processing performance..

After completing this lesson, you will be able to:

• Describe hierarchies.
• Distinguish parent-child hierarchies from balanced hierarchies and describe when each type would be
used.
• Describe ragged hierarchies and the options you have to configure them.

• Describe considerations for using hierarchies.

• Create attribute relationships.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-13

What Are Hierarchies?

Attributes are exposed to users through attribute hierarchies. An attribute hierarchy in a dimension
includes an optional All level and distinct members of the attribute. For example, a Customer dimension
might include a Name attribute hierarchy with two levels: the All level and a second level with a member
for each name. It is attribute hierarchies that define the space of a cube. You can think of a cube as the
multidimensional space created by the product of its attribute hierarchies. Dimensions are containers for
attribute hierarchies. A dimension can also contain user hierarchies as a navigational convenience, but
these do not affect the space in the cube.

Defining relationships between levels in a hierarchy enables Analysis Services to define more useful
aggregations to increase query performance and can also save memory during processing performance,
which can be important with large or complex cubes.
When attributes are arranged into user-defined hierarchies, you define relationships between hierarchy
levels. The levels are related in a many-to-one or a one-to-one relationship (called a natural relationship).
For example, in a Calendar Time hierarchy, a Day level should be related to the Month level, the Month
level related to the Quarter level, and so on.

A natural hierarchy is composed of attributes where each attribute is a member property of the attribute
below. For example, the Customer Geography hierarchy Country, State-Province, City, Postal Code and
Customer is a natural hierarchy because of the relationships between the attributes. The hierarchy Marital
Status-Gender is a non-natural hierarchy because the Marital Status and Gender attributes do not have a
relationship to each other.

Natural hierarchies are preferred for performance reasons. 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 quite plausible that you would want to drill down from marital status
to gender. You might be primarily interested in whether a customer is married and then drill down to
their gender. The gender on its own is of no use to you, but when combined with the marital status it
returns useful data.
6-14 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. Only the most senior employee has no manager; all
other employees have a position in the hierarchy that is defined by the identities of their managers and of
those that they manage.

A parent-child hierarchy is an unbalanced hierarchy. This imbalance occurs when the number of levels
from leaf to root is different for different leaf members. For example, some managers might have three
levels of employee working for them while others have just two.
Parent-child hierarchies are not defined by the order in which attributes are added, and are defined by
the relationships in the dimension table instead.

Parent-child dimensions are changing dimensions. This means that rows can be modified without the
need for processing. They are also the only dimension type that you can write-enable.

The reason that parent-child dimensions can be read-only and are changing dimensions is that the
structure of the hierarchy is calculated at run-time. This can be highly beneficial if the records in the
dimension change frequently, however there are performance considerations. Because the parent-child
hierarchy is calculated at run-time, no aggregates are calculated when the cube is processed. Therefore,
for example, the total sales for each sales manager, including their own sales and all the sales of each
employee that reports to them, is 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 dimensions can be recreated
as traditional dimensions. For example, an employee could list their level one manager, level two
manager, and so-on up the hierarchy. This would allow the aggregates for the dimension to be calculated
during processing, but with a loss of flexibility.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-15

You should also consider what to do with non-leaf data. In the example we have used 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 Nonleaf data visible or Nonleaf
data hidden. Otherwise, processing the cube fails. If you use Nonleaf data visible the parent, in this
case, the sales manager, will also appear in the level below. They will appear to report to themselves. If
you use Nonleaf data hidden, the sales manager will not appear in the level below, however if you
perform a sum on all employee sales, the value will not include the sales manager and, therefore, will not
equal the total for that department.

For More Information For more information about Parent-Child Dimensions, see
http://go.microsoft.com/fwlink/?LinkID=246783.
6-16 Working with Cubes and Dimensions

Ragged Hierarchies

Ragged hierarchies often seem similar to parent-child hierarchies to the user. Like a parent-child
hierarchy, a ragged hierarchy will also have a different number of levels in different parts of the hierarchy,
but these levels are formed from different columns in the dimension table 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 may only be used for the United States, Canada, and Australia. All
other countries in the dimension may skip the State level.

The HideMemberIf property makes a regular hierarchy ragged. There are five possible values for this
property:
• Never This value creates a regular hierarchy.

• OnlyChildWithNoName This value hides a level member when it is an only child and is null or a
zero-length string.

• OnlyChildWithParentName This value hides a level member when it is an only child and it has 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 dimension. The aggregates are
calculated when the cube is processed improving query performance, however a ragged hierarchy is not a
changing dimension and therefore the flexibility of parent-child dimensions is lost.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-17

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.

There are several important hierarchy properties:

• The IsAggregatable property defines whether an All level is created. In some scenarios, an All level is
irrelevant. For example, the Time dimension in a solution holds data from 12th January 1995, because
earlier data is too costly to convert and gives minimal business benefit. This range of dates is not
relevant to the business and does not need to be aggregated.
• The AttributeHierarchyOrdered property defines whether the hierarchy is ordered. If this is set to
False and you do not query the attribute hierarchy, you will reduce processing time. If you only use
an attribute hierarchy to order another attribute hierarchy, it is not queried.

• The AttributeHierarchyOptimizedState can be set to NotOptimized to prevent Analysis Services


from creating indexes on the attribute hierarchy. This will reduce processing time but increase query
time, and you should only use this when you do not query the attribute hierarchy.
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 would not add any benefit.
6-18 Working with Cubes and Dimensions

Attribute Relationships

Attributes are always related directly or indirectly to the key attribute. Initially all attributes are directly
related to the key attribute and in this might be the relationship that you require. For example, a Product
dimension contains ProductKey, Name, Weight, ProductionCost, RecommendedSalesCost. In this
dimension you do not group by any attribute and there is only a need for the ALL level and one level
containing every member.

In most dimensions however, there are levels and relationships between levels. For example, you have a
Customer dimension containing attributes for CustomerKey, Name, Address, City, Region, and
Country. Name and Address relate directly to the CustomerKey, but you want to create relationships for
the other attributes. You create a relationship from Country to Region, from Region to City, and from
City to CustomerKey. This relationship now supports the levels within the data and will be used to create
aggregates to improve query performance.

Attribute relationships are straightforward to create by 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 attribute and related attribute. 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 and therefore, in
this relationship, the month is the source attribute and the quarter is the related attribute.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-19

Demonstration: Creating a Parent-Child Hierarchy

 Task 1: Create a parent-child hierarchy


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the
D:\10778A\Demofiles\Mod06 folder, run Setup.cmd as Administrator.

2. In the D:\10778A\Demofiles\Mod06 folder, double-click Adventure Works OLAP.sln to open the


solution in SQL Server Data Tools.

3. In Solution Explorer, right-click Dimensions and click New Dimension.

4. On the Welcome to the Dimension Wizard page, click Next.


5. On the Select Creation Method page, select Use an existing table and click Next.

6. On the Specify Source Information page:

• In the Main Table box select DimEmployee.

• In the Key column list, ensure that EmployeeKey is selected.

• In the Name Column box select FullName.

• Click Next.

7. On the Select Related Tables page, ensure that DimSalesTerritory is selected and click Next.

8. On the Select Dimension Attributes page, click Next.

9. On the Completing the Wizard page, in the Name box, type Employee and click Finish.

 Task 2: Name the levels in a parent-child hierarchy


1. On the Dimension Structure tab, In the Attributes section, click Parent Employee Key.
2. In the Properties pane click the ellipses (…) button for NamingTemplate.
6-20 Working with Cubes and Dimensions

3. In the Level Naming Template dialog box type Senior Management in the first blank cell.

4. Move down one cell and type Middle Management and move down another cell and type
Employee.
5. Click OK.

6. In the Properties pane change the MemebersWithData property value to NonLeafDataHidden.

7. In Solution Explorer, right-click Adventure Works OLAP and click Deploy. If prompted, specify the
password Pa$$w0rd for the ADVENTUREWORKS\Student user.
8. When deployment has completed, click the Browser tab and 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.
9. Close SQL Server Data Tools.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-21

Lesson 3
Sorting and Grouping 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, members of an attribute can be grouped into a number of
member groups through a process called discretization.

This lesson describes sorting and grouping attributes. After completing this lesson, you will be able to:

• Sort attributes.
• Group attributes.
6-22 Working with Cubes and Dimensions

Sorting Attributes

You can choose any attribute to sort the hierarchy by. 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 order the members in alphanumeric order.

• If you order by key, you can specify one or more key columns and use these to sort the members. This
allows you to sort dates by quarters. With a single key, the order of quarters would be Q1, Q2, Q3,
and Q4 with all years aggregated, for example, Q1 would aggregate all Q1 data from every year. If
you add the Year column to the key, the order would be Q1 2000, Q2 2000, Q3 2000, Q4 2000, Q1
2001, Q2 2001, Q3 2001, and so on.
• You can also order by a secondary attribute. This attribute can be a standard column or a calculated
column created in the Data Source View. For example, you want to sort a Course dimension. The
name of the course runs from “Course 1” to “Course 450”. The key of the course is provided by the
course vendor and is not a relevant sort order. If you sort by the 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 the data
in the correct order.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-23

Grouping Attributes

Some hierarchies have no natural levels, so Analysis Services only creates an All level and the leaf level.
This can make the cube difficult to navigate if there are many members of the hierarchy. You can use
grouping to organize these 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 enable grouping, you must set the DiscretizationMethod property of the attribute. This can be set to:

• Equal Areas, to divide the members into groups with an equal number of members.
• Clusters, to use a clustering algorithm to group members based on the training data. This can form
useful groups, but has a higher processing cost.

• 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 that they contain, the names of groups can change as
members are added or removed.
6-24 Working with Cubes and Dimensions

Lab Scenario

Some hierarchies have no natural levels, so Analysis Services only creates an All level and the leaf level.
This can make the cube difficult to navigate if there are many members of the hierarchy. You can use
grouping to organize these 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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-25

Lab 6: Defining Dimensions

Exercise 1: Configuring Dimensions


Scenario
Several users in the Adventure Works Cycle company have reported that they want to be able to view
data across time periods, so you need to configure the Date dimension as a Time dimension so that
Analysis Services can apply temporal calculations to values in this dimension.

The main tasks for this exercise are as follows:

1. Prepare the lab environment.


2. Remove unused attributes from dimensions.

3. Add dimension intelligence.

 Task 1: Prepare the lab environment


• Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab06\Starter
folder as Administrator.

 Task 2: Remove unused attributes from dimensions


• Open the Adventure Works OLAP.sln solution in the D:\10778A\Labfiles\Lab06\Starter folder in SQL
Server Data Tools.

• Open the Customer dimension in the dimension designer and note that many attributes have been
added to this dimension 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.
6-26 Working with Cubes and Dimensions

• Delete the Commute Distance, Number Cars Owned, and Number Children At Home attributes
from the Customer dimension.

• Delete the Days To Manufacture and Safety Stock Level attributes from the Product dimension.

 Task 3: Add dimension intelligence


• Use the Business Intelligence Wizard on the Date dimension to define dimension intelligence.

• Specify that the dimension is a Time dimension.

• Map the dimension attribute columns as follows:

Attribute Type Dimension Attribute

Year Calendar Year

Half Year Calendar Semester

Quarter Calendar Quarter

Month Month

Date Simple Date

Results: After this exercise, the Customer and Product dimensions have had some attributes removed,
and time intelligence has been added to the Date dimension.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-27

Exercise 2: Defining Relationships and Hierarchies


Scenario
Another way in which users want to simplify analysis is to group dimension attributes into hierarchies that
can be used to summarize data at multiple levels. Specifically, dates must be organized in temporal
hierarchies, such as years, semesters, quarters, and months; customers should be grouped into hierarchies
based on their geographical address and their marital status and gender; and products should be
grouped based on their category and subcategory.

The main tasks for this exercise are as follows:


1. Create attributes in the Date dimension.

2. Create a natural hierarchy in the Date dimension.

3. Create attribute relationships in the Customer dimension


4. Create hierarchies in the Customer dimension.

5. Create attribute relationships in the Product dimension.

6. Create hierarchies in the Product dimension.

7. Browse the hierarchies you have created.

 Task 1: Create attribute relationships in the Date dimension


• Open the Date dimension in Dimension Designer.

• In the Attribute Relationships tab, create the following new attribute relationships. Note that all of
these relationships are rigid (because, for example, a particular month will always be in the same
calendar quarter).

Source Attribute Related Attribute Relationship Type

Simple Date Month Rigid (will not change over time)

Month Calendar Quarter Rigid (will not change over time)

Calendar Quarter Calendar Semester Rigid (will not change over time)

Calendar Semester Calendar Year Rigid (will not change over time)
6-28 Working with Cubes and Dimensions

When you have finished, the Attribute Relationships pane should resemble the following image.

 Task 2: Create a natural hierarchy in the Date dimension


• In the Dimension Structure for the Date dimension, create a hierarchy based on the relationships
you created in the previous task:

• Drag the Calendar Year attribute to the Hierarchies pane.

• Add the following attributes to the <new level> indicator in the hierarchy in this order:
Calendar Semester

Calendar Quarter

Month
Simple Date

• Change the hierarchy name to Calendar Date.

The completed hierarchy should resemble the following image.

• Set the AttributeHierarchyVisible property of all of the attributes you added to the hierarchy 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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-29

 Task 3: Create attribute relationships in the Customer dimension


• Open the Customer dimension in Dimension Designer.

• In the Attribute Relationships tab, create the following new attribute relationships. Note that all of
these relationships are flexible (because, for example, a particular city could potentially be re-
designated as belonging to a different state; or a customer who is single could get married).

Source Attribute Related Attribute Relationship Type

Postal Code City Flexible (may change over time)

City State-Province Name Flexible (may change over time)

State-Province Name English Country Region Name Flexible (may change over time)

Marital Status Gender Flexible (may change over time)

When you have finished, the Attribute Relationships pane should resemble the following image.

 Task 4: Create hierarchies in the Customer dimension


• In the Dimension Structure for the Customer dimension, create a hierarchy based on the
relationships you created in the previous task:
• Drag the English Country Region Name attribute to the Hierarchies pane.
6-30 Working with Cubes and Dimensions

• Add the State Province Name, City, Postal Code, and Full Name attributes to the hierarchy.

• Change the hierarchy name to Customer Geography, so that the completed hierarchy resembles
the following image.

• Create a second hierarchy named Gender - Marital Status in this dimension, with levels for Gender
and Marital Status, as shown in the following image.

• Set the AttributeHierarchyVisible property of all of the attributes you added to the hierarchies to
False.

 Task 5: Create attribute relationships in the Product dimension


• Open the Product dimension in Dimension Designer.
• In the Attribute Relationships tab, create the following new attribute relationships. Note that all of
these relationships are flexible (because, for example, a particular product could potentially be re-
categorized as belonging to a different subcategory).

Source Attribute Related Attribute Relationship Type

English Product Name English Product Subcategory Name Flexible (may


change over time)

English Product Subcategory Name English Product Category Name Flexible (may
change over time)
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-31

When you have finished, the Attribute Relationships pane should resemble the following image.

 Task 6: Create hierarchies in the Product dimension


• In the Dimension Structure for the Product dimension, create a hierarchy based on the relationships
you created in the previous task:
• Drag the English Product Category Name attribute to the Hierarchies pane.

• Add the English Product Subcategory Name and English Product Name attributes to the
hierarchy.
• Change the hierarchy name to Product Category, so that the completed hierarchy should
resemble the following image.

• Set the AttributeHierarchyVisible property of all of the attributes you added to the hierarchies to
False.
 
6-32 Working with Cubes and Dimensions

 Task 7: Browse the hierarchies you have created


• Deploy the Adventure Works OLAP project, entering the user name ADVENTUREWORKS\Student
and the password Pa$$w0rd if prompted.

• Browse the Customer dimension, and verify that the Customer Geography and Gender – Marital
Status hierarchies behave as expected.
• Open the Adventure Works Cube.cube cube in the cube designer, and then on the Browse tab,
view the Sales Amount measure aggregated by the Product Category hierarchy, and verify that the
hierarchy displays product by category, subcategory, and product name.

Results: After this exercise, you should have created a Calendar Date hierarchy, a Customer Geography
hierarchy, a Gender - Marital Status hierarchy, and a Product Category hierarchy.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-33

Exercise 3: Sorting and Grouping Dimension Attributes


Scenario
Users in Adventure Works Cycles have noticed that when browsing data by month, the data is sorted
alphabetically instead of in chronological order. They have asked you to correct this behavior so that
months are shown in calendar order. Additionally, when analyzing customer data by salary, users have
come to the conclusion that it would be more useful to group customer salaries into discrete bands rather
than view data by individual salary amounts. You have therefore been asked to create salary groupings for
customer data.

The main tasks for this exercise are as follows:


1. Modify the sort order of the Month attribute.

2. Group the Yearly Income attribute hierarchy members.

 Task 1: Modify the sort order of the Month attribute


• Open the Date dimension in Dimension Designer, and browse Calendar Date hierarchy. Note that
the month level is sorted in alphabetical rather than chronological order.

• On the Dimension Structure tab for the Date dimension, modify the following properties of the
Month Number of Year attribute:

• AttributeHierarchyOptimizedState: NotOptimized

• AttributeHierarchyOrdered: False
• On the Attribute Relationships tab, create the following attribute relationship.

Source Attribute Related Attribute Relationship Type

Month Month Number of Year Rigid (will not change over time)

• On the Dimension Structure tab for the Date dimension, modify the following properties of the
Month attribute:
• OrderBy: AttributeKey

• OrderByAttribute: Month Number Of Year

• Deploy the project and browse the Calendar Date hierarchy to verify that the values are now sorted
in the correct order.
6-34 Working with Cubes and Dimensions

 Task 2: Group the Yearly Income attribute hierarchy members


• Open the Customer dimension in Dimension Designer, and browse Yearly Income hierarchy. Note
that the salaries have no hierarchy, as shown in the following image.

• On the Dimension Structure tab for the Customer dimension, modify the following properties of
the Yearly Income attribute:

• DiscretizationMethod: Automatic

• DiscretizationBucketCount: 5
• OrderBy: Key

• Deploy the project and browse the Yearly Income hierarchy to verify that the values are now
grouped into salary bands are shown in the following image.

• Open Adventure Works Cube in the cube designer and browse the cube to view the Internet sales
amount by customer yearly income. Verify that the sales are aggregated by the salary bands you
defined for the Yearly Income hierarchy.

Results: After this exercise, you should be able to view the correctly sorted and grouped dimensions in
the cube.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 6-35

Module Review and Takeaways

Review Questions
1. How do dimensions, attributes, and fact tables relate to one another?
2. Aside from organizational charts, where else might you find parent-child hierarchies?

3. When might you want to use a secondary attribute for sorting data?
6-36 Working with Cubes and Dimensions
7-1

Module 7
Working with Measures and Measure Groups
Contents:
Lesson 1: Working with Measures 7-3

Lesson 2: Working with Measure Groups 7-10


Lab 7: Configuring Measures and Measure Groups 7-24
7-2 Working with Measures and Measure Groups

Module Overview

Measures and measure groups provide the data values that your cube can aggregate in order 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.
After completing this module, you will be able to:

• Describe measures.

• Describe measure groups.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-3

Lesson 1
Working with Measures

This lesson explains how to work with measures, including configuring how measures are displayed,
information about measure values, and configuring how measures are aggregated.

After completing this lesson, you will be able to:

• Describe the concept of a measure.


• List the properties of measures.

• Configure measure formatting.

• Chose appropriate aggregation functions for required additivity.


7-4 Working with Measures and Measure Groups

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 are of most interest to the
business user. Measures are organized into measure groups.

For example, in a retail cube that has dimensions for stores, products, time, and salespeople, the measures
might include sales value and sales units. These measures are then aggregated to provide total sales units
and total sales value for each store, product, day, and salesperson.

You could also pick a specific store from the stores dimension, a specific product from the products
dimension, a specific day from the time dimension, a specific salesperson from the salesperson dimension,
and either sales units or sales value from the measures dimension to provide specific aggregated details.
Although measures are part of the measures dimension, they are distinct from all other dimensions and
are typically just referred to as measures.
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 column in a fact table as modified by a
Multidimensional Expression (MDX) statement. You should consider the performance impact of using
calculated measures because they are calculated at run time. If a calculated measure is infrequently used
and is quite a simple calculation—for example, the sum of two measures—it will have little performance
impact on your queries, but it might reduce processing times. Conversely, if a measure is frequently used
and involves a complex calculation, it might cause unacceptable query times.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-5

Measures from Attribute Columns


You can use attribute columns from dimension tables to define measures, but such measures are typically
semiadditive or nonadditive in terms of their aggregation behavior. For example, a customer might have
an account balance. This can be added for all customers, but it should not be added for an individual
customer over time. If a customer has a positive balance of $10.00 and maintains this for a year, it should
not be summed by week; otherwise, the customer would have a balance of $520.00 rather than $10.00.

Aggregation
The aggregation behavior of each measure is determined by the aggregation function that is associated
with the measure.

For More Information For more information about aggregation, see the Aggregation
Functions topic later in this lesson.

Granularity
You should consider the granularity of measures. 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 levels of day, month, quarter, and year, it is not possible to store sales
measures at a granularity of hours, but it would be possible to store them at a granularity of months. You
can specify the granularity of a measure group with relation to a specific dimension by using the
Dimension Usage tab of the Cube Designer.

Note Granularity 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.
7-6 Working with Measures and Measure Groups

Measure Properties

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.

Measures inherit certain properties from the measure group of which they are a member, unless those
properties are overridden at the measure level.

Measure properties determine:


• How measures are aggregated.

• 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 description of the measure, which may be exposed in client applications.

• The name that is displayed to the user.

• 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.

• Any MDX expressions that define the measure.

• The visibility of the measure.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-7

Configuring How Measures Are Displayed

The measure property FormatString determines how measure values are displayed to users, and you can
configure it by using the Properties window of a measure in the Cube Designer.

Typical FormatString values include General Number or Medium Date, but although a list of display
formats is provided, you can specify many additional formats that are not in the list by specifying any
named or user-defined format that is valid in Microsoft® Visual Basic®. This might include changing the
order of a date or introducing currency symbols.

Note The currency format will display the currency symbol of the location of the client.
Therefore, the value may be incorrect, and in most scenarios it would be more appropriate
to use a user-defined FormatString.

The table on the slide assumes that the regional setting in Control Panel on the client computer is English
(United States).
7-8 Working with Measures and Measure Groups

Aggregation Functions

The measure property AggregateFunction determines how measures are aggregated, and you can
configure it by using the Properties window of a measure in the Cube Designer. Some measures do not
use the SUM function and aggregate in another way. For example, you might have a profit margin
measure. This is typically about 50 percent, and a supplier typically has about 100 products. If you display
the aggregated profit margin for each supplier, you would expect the value to be about 50 percent and
not about 5000 percent, and therefore you would use the AVG function in place of SUM.

Aggregation functions have different levels of additivity. Based on the function that is used, the additivity
will fall into one of three categories:
1. An additive measure. This is also called a fully additive measure, and you can aggregate it along all of
the dimensions that are included in the measure group that contains the measure, without restriction.
Additive measures are the most commonly used in Microsoft SQL Server® Analysis Services (SSAS)
and consist of the SUM and COUNT functions.

2. A semiadditive measure. You can aggregate this along some, but not all, dimensions that are included
in the measure group that contains the measure. An example of a semiadditive aggregation would be
a units-in-stock value for warehouse goods. This would be additive by region to give you the total
units in stock, but it would not be additive by time because if you add last week's stock to this week's
stock, you could end up with a value that lists twice as much stock as you have.
3. A nonadditive measure. You cannot aggregate this along any dimension in the measure group that
contains the measure. Instead, you must individually calculate the measure for each cell in the cube
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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-9

Use the AggregateFunction property to define the function that is used to aggregate the measure.
Commonly used aggregation functions include:

• 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.

Other semiadditive aggregation functions include:

• The ByAccount function. This calculates the aggregation according to the aggregation function that
is assigned to the account type for a member in an account dimension.

• 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.

For More Information For more information about how to Configure Measure
Properties, see http://go.microsoft.com/fwlink/?LinkID=246784.
7-10 Working with Measures and Measure Groups

Lesson 2
Working with Measure Groups

You use measure groups to associate dimensions with measures. There are a number of properties that
you can configure at the measure group level, including:

• 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.

This lesson describes measure group properties and the relationships between measure groups and
dimensions. It also explains partitions, aggregations, and how to configure measure group storage.
After completing this lesson, you will be able to:

• Describe measure groups.

• List the properties of measure groups.


• Describe the relationships between measure groups and dimensions.

• Explain partitions and measure group storage.


• Describe aggregations and their effect on performance.

• Explain how to configure measure group storage.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-11

Introducing Measure Groups

In a cube, measures are grouped by their underlying fact tables into measure groups. You use measure
groups to associate dimensions with the measures in the fact table.

A measure group defines:

• The dimensions the measures can be aggregated by. This is achieved by creating relationships
between measure groups and dimensions in the cube. For example, you might relate an Internet
Sales measure group to Product, Date, and Customer dimensions; and in the same cube you might
relate a Reseller Sales measure group to Product, Date, and Reseller dimensions. Measures in both
groups can be aggregated by product and date, Internet sales measures can be aggregated by
customer, and reseller sales measures can be aggregated by reseller.

• The granularity at which the measures are related to the dimensions. For example, a cube might
include a Reseller Sales measure group that is related to the Date dimension based on a key for an
individual day (because each sale is associated with the specific date on which the sale occurred), and
a Sales Quota measure group that is related to the Date dimension based on the year (because sales
quotas are set for each year, not for individual days, weeks, or months).

• How measure aggregations should be stored. For example, you might optimize cube performance by
storing pre-aggregated values for some or all of the possible aggregations for measures in a measure
group and its related dimensions.

You define one or more measure groups in SQL Server Data Tools by using the Cube Wizard and then add
and configure measure groups by using the Cube Designer.

The DistinctCount aggregation looks for the number of distinct values in a column of the fact table. For
example, you might want to know how many salespeople sold a particular product. This is query is very
resource-intensive and, therefore, Analysis Services creates a separate measure group for DistinctCount
measures.
7-12 Working with Measures and Measure Groups

Measure Group Properties

Measure group properties determine behaviors for the entire measure group and set the default
behaviors for certain properties of measures within a measure group. Measure group properties include:

• AggregationPrefix This specifies the common prefix that is used for all aggregation names of the
measure group.

• DataAggregation This determines whether SSAS can aggregate persisted data or cached data for
the measure group. The default value is DataAndCacheAggregatable, which will aggregate
persisted data and cached data. You can change this to CacheAggregatable or DataAggregatable.
DataAggregatable can be useful on systems with limited RAM because the other two settings will
attempt to keep the aggregations in memory to improve performance.

• ErrorConfiguration This provides configurable error-handling settings for handling of duplicate


keys, unknown keys, null keys, error limits, action upon error detection, and the error log file.

• 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 size (in bytes) of the measure group. You use this when
you design aggregations

• ID This specifies the identifier of the object.


• IgnoreUnrelatedDimensions This determines whether unrelated dimensions are forced to their top
level when members of dimensions that are unrelated to the measure group are included in a query.
• ProactiveCaching This defines how data is reprocessed when there are changes in the underlying
data source.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-13

• ProcessingMode This indicates whether indexing and aggregating should occur during or after
processing. You can use lazy processing to enable SSAS to choose a time when workload is low;
however, if you use lazy processing, you will not know exactly when the indexing workload will occur
or when indexing has occurred and queries will be at peak performance.

• 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.

• Type This specifies the type of the measure group.


7-14 Working with Measures and Measure Groups

Relationships Between Measure Groups and Dimensions

A relationship between a dimension and a measure group consists of the dimension and fact tables that
are participating in the relationship and a granularity attribute that specifies the granularity of the
dimension in the particular measure group. This relationship is configured in the Dimension Usage tab of
the Cube Designer.

Note When a measure group is updated, dimension relationship information is


unavailable until the cube is processed.

Regular Dimension Relationship


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 Dimension Relationship


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 Dimension Relationship


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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-15

Many-to-Many Dimension Relationship


Typically, each dimension member relates to many facts, but each fact relates to just one member in each
dimension. This is a standard one-to-many relationship. You may also have many-to-many relationships;
for example, a customer might have multiple reasons for making a purchase, and each purchase reason
will have multiple customers. In a relational database, this relationship would be achieved through an
intermediate table, and in SSAS, 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 involved in a many-to-many


relationship must exist in the underlying data source view.

You can use the Granularity attribute list to define the granularity of a particular relationship. Most
cubes will have time data, so it is common to have a fact dimension table. This will store time data at the
highest level of granularity of any fact table, but, although some fact tables may require data that is
accurate to the minute, many will have day, month, or quarter granularity. By allowing you to specify the
granularity of a measure group, you can use one time dimension for all of these fact tables.
7-16 Working with Measures and Measure Groups

Demonstration: Defining Relationships Between Dimensions and


Measure Groups

 Task 1: Define a referenced relationship


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the
D:\10778A\Demofiles\Mod07 folder, run Setup.cmd as Administrator.
2. In the D:\10778A\Demofiles\Mod07 folder, double-click Adventure Works OLAP.sln to open the
solution in SQL Server Data Tools.

3. In Solution Explorer, right-click Adventure Works OLAP and click Deploy. If prompted, specify the
user name ADVENTUREWORKS\Student and the password Pa$$w0rd.

4. In Solution Explorer, double-click Adventure Works Cube.cube, and on the Browser tab, expand
Measures and Internet Sales and drag the Sales Amount measure to the Drag levels or measures
here to add to the query area. Then expand the Geography dimension and drag Country-Region
to the left of the Sales Amount value.

Note that the values for each region are the same. The aggregation is incorrect.
5. In Solution Explorer, 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.

6. In Solution Explorer, right-click Customer.dim, and then click View Designer. Note that this
dimension is based on the Customer table, which includes a GeographyKey attribute that relates it
to the Geography table.

7. Click the tab for the Adventure Works Cube.cube, and on the Cube Structure tab, in the Data
Source View pane, note that there is no direct relationship between the InternetSales fact table and
the Geography dimension table.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-17

8. On the Dimension Usage tab, click the intersection of the Internet Sales measure group and the
Geography dimension, click the ellipses (…) button.

9. In the Select relationship type list, select Referenced.


10. In the Intermediate dimension list, select Customer.

11. In the Reference dimension attribute list, select Geography Key, and in the Intermediate
dimension attribute list, select Geography Key.

12. Click OK.


13. In Solution Explorer, right-click Adventure Works OLAP and click Deploy. If prompted, specify the
user name ADVENTUREWORKS\Student and the password Pa$$w0rd.

14. Click the tab for the Adventure Works Cube.cube, and on the Browser tab, click the Reconnect
button. Then in the data grid area, click the Click to execute the query link.

Note that the values for each region are now correct.
15. On the Dimension Usage tab, in the Dimensions list, right-click Geography, and then click
Rename.

16. Change the name of this cube dimension to Reseller Geography, and then press Enter to make this
name change take effect.
7-18 Working with Measures and Measure Groups

Aggregations

Aggregations are precalculated summaries of data from leaf cells that improve query response time by
preparing the answers before the questions are asked.

A simple Aggregation object consists of:

• Basic information that includes the name of the aggregation, the ID, annotations, and a description.

• A collection of AggregationDimension objects that contain the list of granularity attributes for the
dimension.

Aggregations are what give multidimensional cubes their performance benefits. They precalculate the
answer to queries at processing time; therefore, when the query is run, the performance is hugely
improved. If you consider that a query might have to aggregate thousands of individual values to produce
one summarized output value, and there may be hundreds of output values, it becomes clear that
precalculating these results will have enormous benefits.
It might seem appropriate to precalculate every single possible result; however, some aggregations
provide little benefit. The Aggregation Design Wizard provides options for you to specify storage and
percentage constraints on the algorithm to achieve a satisfactory tradeoff between query response time
and storage requirements. For example, if SSAS stores aggregates at a month level, it takes little
processing to generate quarter data at query run time. Typically, there is little benefit from preprocessing
more than 35 percent of aggregations, and you can specify this in the Aggregation Design Wizard.

SSAS incorporates a sophisticated algorithm to select aggregations for precalculation so that other
aggregations can be quickly computed from the precalculated values. To improve aggregation design for
your specific system further, you can use SSAS for some time with normal workloads and then run the
Usage-Based Optimization Wizard. This is almost identical to the Aggregation Design Wizard; however, it
bases the optimization on queries submitted to SSAS and therefore should give better query response
with less processing time.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-19

Configuring Measure Group Storage

There are three modes of multidimensional storage in SSAS: multidimensional online analytical processing
(MOLAP), relational OLAP (ROLAP), and hybrid OLAP (HOLAP).

MOLAP
MOLAP storage 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 only refreshed when the cube is
processed, so changes from the data source are only updated periodically.
Typically the cube is available during processing; however, query performance is affected, and if structural
changes occur to cube objects, the cube may need to be taken offline. To avoid these issues, you can
schedule processing to occur when the cube is rarely used, for example, at night. Often, this is not
possible because many systems are in use 24 hours a day, seven days a week and you must therefore use
other strategies. If you process the cube to a storage server, you can then use database synchronization to
copy the processed data to the production server. You could also use proactive caching.

Proactive caching uses MOLAP storage, but it incorporates changes made to the data source by using
notifications. 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.

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 slower to process than MOLAP or
HOLAP, but it enables real-time access to data and uses less storage space.
7-20 Working with Measures and Measure Groups

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 10,
“Implementing a Tabular Data Model with Microsoft PowerPivot”

Storage Settings
You can use the Storage Settings dialog box to configure storage.

Storage settings for partitions are set in the Storage Options dialog box, which you can open in one of
several different ways.

To configure default storage settings for new measure groups that are added to a cube:

• In the Cube Wizard, on the Cube Builder tab, in either the Measures or Dimensions pane, click the
cube object, and in the Properties window, click the browse button for the ProactiveCaching
property setting.

• To configure default storage settings for new partitions that are added to a measure group, in the
Cube Wizard 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 storage for an existing partition, in the Cube Wizard on the Partitions tab, expand the
measure group, and then use one of the following methods:

• Right-click the partition, and then click Storage Settings.


• Click the partition, and on the Cube menu, click Storage Settings.

• Click the partition, and on the toolbar, click Set Proactive-cache Settings.

• Click the partition, and in the Properties window, click the ellipses (...) button for the
ProactiveCaching property setting.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-21

Partitions

A partition is a container for all, or a portion of, the measure group data.

SSAS Enterprise Edition uses partitions to manage and store data and aggregations for a measure group
in a cube. By splitting the data into multiple partitions, there are a number of performance benefits:

• If you partition based on date, you only need to process the latest partition, which reduces processing
time.
• You can store frequently used data differently from aggregated data. This enables you to use higher
levels of aggregation and a faster storage mode to improve query times and reduce processing times
and storage requirements for older data.

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.
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. You should
consider data integrity when you incrementally update individual partitions. For example, if a change in
the source data results in a record moving from one partition to another, but only one partition is
updated, the data may either disappear or be duplicated.

For More Information For more information about Remote Partitions, see
http://go.microsoft.com/fwlink/?LinkID=246785.
7-22 Working with Measures and Measure Groups

A simple Partition object consists of:

• Basic information that includes the name of the partition, the storage mode, and the processing
mode.
• A slicing definition that is an MDX expression that specifies a tuple or a set.

• An aggregation design that is a collection of aggregation definitions that you can share across
multiple partitions.

Typically, you can partition a measure group horizontally or vertically.


In a horizontally partitioned measure group, each partition in a measure group is based on a separate
table, and these fact tables can be from different data sources.

In a vertically partitioned measure group, a measure group is based on a single table, and each partition is
based on a source system query that filters the data for the partition.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-23

Lab Scenario

Business users are performing analysis of Internet sales with the multidimensional cube you have created.
However, they also need to analyze reseller sales. You have reseller sales data in the data warehouse on
which the cube is based, so you plan to add a second measure group containing the reseller measures.

Users have also requested that you remove some measures that they do not need to use when analyzing
data, and 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 used by the cube, but your users
are concerned about performance when analyzing Internet sales. You must optimize the storage and
aggregations of the cube to balance these concerns.
7-24 Working with Measures and Measure Groups

Lab 7: Configuring Measures and Measure Groups

Exercise 1: Configuring Measures


Scenario
You are refining the OLAP cube for your company. Your users can currently view measures for Internet
sales, but you have additional data for reseller sales in your data warehouse and they would like to
analyze this data as well as Internet sales. When you add the reseller sales measures, your users have
requested that you remove some measures that are not required for business analysis, and ensure that the
measures in the cube are clearly named.

In this exercise, you will configure format strings and display folders for measures.

The main tasks for this exercise are as follows:

1. Prepare the lab environment.


2. Create a measure group.

3. Modify measure groups.

 Task 1: Prepare the lab environment


• Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab07\Starter
folder as Administrator.
 
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-25

 Task 2: Create a measure group


• Use SQL Server Data Tools to open the Adventure Works OLAP.sln solution in the
D:\Labfiles\Lab07\Starter folder.

• Open the Adventure Works DSV data source view and add the FactResellerSales table, together
with all related tables.
• Open Adventure Works Cube in cube designer, and add a new measure group named Reseller
Sales based on the FactResellerSales table.

• Review the names of the measures in both the Internet Sales and Reseller Sales measure groups.
Note that when the Reseller Sales measure group was created, measures were created for all of the
numerical fields in the FactResellerSales table. In cases where an measure with the same field name
already existed, a new measure was created with “ - Fact Reseller Sales” appended to its name, as
shown in the following image.

 
7-26 Working with Measures and Measure Groups

 Task 3: Modify measure groups


• Delete the following measures from the cube.

Tip Click the Show Measures Grid icon to view all of the measures in the cube as a grid.
In this view, you can multi-select measures by holding the Ctrl key.

• Promotion Key

• Currency Key

• Sales Territory Key

• Revision Number

• Extended Amount

• Unit Price Discount Percent


• Discount Amount

• Product Standard Cost


• Freight
• Revision Number – Fact Reseller Sales

• Extended Amount – Fact Reseller Sales

• Unit Price Discount Pct


• Discount Amount – Fact Reseller Sales

• Product Standard Cost – Fact Reseller Sales


• Freight – Fact Reseller Sales

• Rename the following measures:

Measure Rename to:

Order Quantity Order Quantity – Internet Sales

Unit Price Unit Price – Internet Sales

Total Product Cost Total Product Cost – Internet Sales

Sales Amount Sales Amount – Internet Sales

Tax Amount Tax Amount – Internet Sales

Order Quantity – Fact Reseller Sales Order Quantity – Reseller Sales

Unit Price – Fact Reseller Sales Unit Price – Reseller Sales

Total Product Cost – Fact Reseller Sales Total Product Cost – Reseller Sales

Sales Amount – Fact Reseller Sales Sales Amount – Reseller Sales

Tax Amt Tax Amount – Reseller Sales

Fact Reseller Sales Count Reseller Sales Count


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-27

When you view the modified measures as a tree, they should resemble the following image.

Results: After this exercise, you should have created a new measure group for the FactResellerSales
table, removed unrequired measures, and renamed measures.
7-28 Working with Measures and Measure Groups

Exercise 2: Defining a Regular Relationship


Scenario
Your users have specifically stated that they must be able to analyze reseller sales by product, so you must
create the required relationships to support aggregating reseller sales measures by the Product
dimension.

In this exercise, you will create a regular relationship.


The main task for this exercise is as follows:

1. View existing dimensions for measure groups.

2. Create a dimension.

 Task 1: View existing dimensions for measure groups


• Deploy the Adventure Works OLAP project, entering the user name ADVENTUREWORKS\Student
and the password Pa$$w0rd if prompted.
• Open Adventure Works Cube in the cube designer, and on the Browse tab, review the measures
and dimensions available for each measure group by selecting each measure group in turn in the
Measure Group drop-down list in the Metadata pane.
• When the Internet Sales measure group is selected, the Product dimension should be listed.

• When the Reseller Sales measure group is selected, there is no Product dimension.

 Task 2: Create a dimension


• On the Dimensions Usage tab of the cube designer for Adventure Works Cube, define a regular
relationship at the intersection of the Reseller Sales measure group and the Product dimension.
• Define the relationship at the Product Key level of granularity.

• Select ProductKey as the measure group column.


When you have defined the relationship, the Dimensions Usage tab should resemble the
following image.

• Deploy the Adventure Works OLAP project, and then browse the cube, verifying that you can view
Sales Amount – Reseller Sales by Product Category.

Results: After this exercise, you should have defined a regular relationship to enable you to analyze
reseller sales data.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 7-29

Exercise 3: Configuring Measure Group Storage


Scenario
Users have requested that the cube should be optimized to improve performance when analyzing
Internet sales. However, you must balance this need for optimization against the space required to store
aggregations.

The main tasks for this exercise are as follows:


1. Configure the storage mode of the Internet Sales measure group.

2. Design aggregations for the Internet Sales measure group.

 Task 1: Configure the storage mode of the Internet Sales measure group
• Configure proactive caching for the Internet Sales measure group in the Adventure Works Cube
cube.

• Specify that the Automatic MOLAP setting should be used.

 Task 2: Design aggregations for the Internet Sales measure group


• Use the Aggregation Design Wizard to design aggregations for the Internet Sales measure group in
the Adventure Works Cube cube.

• Set all aggregation usage to the default before starting the configuration.

• Use the wizard to count the objects in the measure group.


• Generate aggregations until the performance gain reaches 35%.

• Name the aggregation you have generated InternetSalesAgg.

• Deploy the Adventure Works OLAP project, entering the user name ADVENTUREWORKS\Student
and the password Pa$$w0rd if prompted. Then close SQL Server Data Tools.

• Start SQL Server Management Studio and connect to the localhost instance of Analysis Services.

• In Object Explorer, expand Databases, expand Adventure Works OLAP, expand Cubes, expand
Adventure Works Cube, expand Measure Groups, expand Internet Sales, and expand
Aggregation Designs to verify that the InternetSalesAgg aggregation has been deployed.

Results: After this exercise, you should have defined the storage mode aggregations and for the Internet
Sales measure group.
7-30 Working with Measures and Measure Groups

Module Review and Takeaways

Review Questions
1. Give an example of an additive measure, a semiadditive measure, and a nonadditive measure.
2. What are the two ways in which you can partition a measure group?

3. How can you use aggregations to improve query response time?


8-1

Module 8
Introduction to MDX
Contents:
Lesson 1: MDX Fundamentals 8-3

Lesson 2: Adding Calculations to a Cube 8-12


Lesson 3: Using MDX to Query a Cube 8-24

Lab 8: Using MDX 8-29


8-2 Introduction to MDX

Module Overview

Multidimensional Expressions (MDX) is the query language that you use to work with and retrieve
multidimensional data in Microsoft® SQL Server® 2012 Analysis Services (SSAS). This module describes
the fundamentals of MDX. It also explains how to build calculations, such as calculated members and
named sets.

After completing this module, you will be able to:


• Describe MDX.

• Add calculations to a cube.

• Describe how to use MDX in client applications.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-3

Lesson 1
MDX Fundamentals

You can use MDX to query multidimensional data or to create MDX expressions for use within a cube.
However, you must first understand the fundamentals of MDX. This lesson describes MDX. It explains what
MDX is, discusses basic MDX query syntax, and explains how to specify query and slicer axes. Finally, this
lesson discusses the process that is involved to establish cube context.
After completing this lesson, you will be able to:

• Describe MDX.
• Explain basic MDX query syntax.
• Specify query and slices axes.

• Establish the cube context.


8-4 Introduction to MDX

What Is MDX?

MDX is an industry-standard specification, and a wide range of online analytical processing (OLAP)
vendors have adopted it. MDX was specifically created to query OLAP cubes; using Structured Query
Language (SQL) expressions would be long and complex because the SQL language is designed to
navigate two-dimensional tables. With MDX, it is straightforward to navigate multidimensional cubes and
also to navigate up, down, and across hierarchies.

MDX consists of two parts: MDX statements and MDX expressions. MDX statements return record sets,
and client applications use them to populate the application that the user sees. MDX expressions return
single values and are used in the cube to create values such as calculated members or default members. In
most scenarios in SSAS, you will use MDX expressions, but you might use MDX statements in client
applications or to define subsets of cube data.
Terms that occur frequently when describing MDX statements and expressions include cell, tuple, and set.
A cell is the intersection between a member of the measures dimension and a member of one or more
other dimensions from which you can obtain data. To identify or extract such data, whether it is a single
cell or a block of cells, MDX uses a system called tuples. A set is a collection of tuples that defines multiple
cells from the same dimensions.

You use MDX for many things when you work with multidimensional cubes. In the last illustration on the
slide, you can see an example where MDX is used to limit the cells that can be read by members of a role.
Later in this module, you will also see MDX used in SQL Server Management Studio, Microsoft Excel®,
and SQL Server Reporting Services.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-5

MDX is not limited to multidimensional cubes. You can also use MDX with tabular data models alongside
the new Data Analysis Expressions (DAX) language, which is designed specifically for tabular data model
use.

For More Information For more information about the DAX language, see Module 11,
“Introduction to DAX.”
8-6 Introduction to MDX

Basic MDX Query Syntax

The basic MDX query is the SELECT statement. This is the most frequently used query in MDX and you use
it to retrieve data from a cube.

In MDX, the SELECT statement specifies a result set that contains a subset of multidimensional data that
has been returned from a cube.

To identify the query axes, the cube that sets the context of the query, and the slicer axis, the MDX SELECT
statement uses the following clauses:

• A SELECT clause. This determines the query axes of the displayed result set by using an MDX SELECT
statement.

• A FROM clause. This determines which multidimensional data source to use when extracting data to
populate the result set of the MDX SELECT statement.
• A WHERE clause. This optionally determines which dimension or member to use as the slicer axis that
restricts the extracting of data to a specific dimension or member.

Bracketing Object Names


So that MDX can interpret names, you need to put square brackets around the name of any object from
an OLAP database, that is, a cube, dimension, hierarchy, level, or member, in the following three cases:

• If the name contains a space or other special character. For example, you must refer to the member
Gross Profit in MDX as [Gross Profit] because the name contains a space.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-7

• If the name is the same as a keyword, such as an MDX function. For example, SELECT is an MDX
keyword, so if you have a level named SELECT, you must refer to the level as [Select].

• If the name begins with a numeric character. For example, you must refer to the member 2011 as
[2011].
If a name does not meet any of these conditions, you can still put brackets around the name, but they are
not required.

Qualifying Names to Avoid Ambiguity


The same object name from an OLAP database can appear in more than one place in an OLAP cube—
even in the same dimension or level of a cube. To avoid ambiguity, MDX enables you to add qualifiers to
a member name. The qualifiers ensure that when you read the MDX statement or expression, you know to
which object the name refers. The following are examples of ambiguous situations and how they would
be qualified:

• In a Time dimension, the member Q1 might appear as a child of multiple years. Q1 for each year
would be qualified as follows: [2010].[Q1], [2011].[Q1], and so on.

• A cube could have West as a member name in the Region dimension and an employee with the
name West in the Sales Rep dimension. The two members would be qualified as follows:
Region].[West] and [Sales Rep].[West].

Ensuring Correct Member is Returned


MDX does not return an error if a name is ambiguous, that is, if the name appears in more than one place
in a cube. MDX follows the simple rule of using the first occurrence of the name in the database. For
example:
• If you use [Q1] as a name in a cube that includes the years 2010 and 2011, MDX interprets the name
as [2010].[Q1] because 2010 is the first occurrence in the Time dimension.

• If you use [West] in a cube that includes that member name in both the Region and the Sales Rep
dimensions, MDX interprets the name according to which of the two dimensions appears first in the
Cube Editor.

Note The slide uses SELECT, FROM, and WHERE clauses, has bracketed object names, and
qualifies names to avoid ambiguity.
8-8 Introduction to MDX

Specifying Query and Slicer Axes

Query axes and slicer axes are each a set of hierarchies from which data is retrieved. Query axes and slicer
axes have the following characteristics:

• Query axes specify the edges of a cell set that an MDX SELECT statement returns.

• To explicitly specify a query axis, use the <SELECT query axis clause>, as the code examples here
illustrate.
• The slicer axis filters the data that the MDX SELECT statement returns, restricting the returned data so
that only data that intersects with the specified numbers will be returned.

• To explicitly specify a slicer axis, you use the <SELECT slicer axis clause> in MDX.
• If a member from a hierarchy within the cube is not explicitly included in a query axis, the default
member from that hierarchy is implicitly included in the slicer axis.
You can specify axes by using either a name or an integer. For example, the query in the following code
example uses names to place dates on the column axis, customer geography on the row axis, and sales
amount at the intersections.

SELECT
[Measures].[Sales Amount] On COLUMNS,
NonEmpty([Product Category].[Product Category Key].Members, [Measures].[Sales Amount])
On ROWS
FROM [Adventure Works]

The following code example performs the same query by using integers.

SELECT
[Measures].[Sales Amount] On 0,
NonEmpty([Product Category].[Product Category Key].Members, [Measures].[Sales Amount])
On 1
FROM [Adventure Works]
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-9

You should define a default member before you work with slicer axes. The default member of an attribute
hierarchy is used to evaluate expressions when an attribute hierarchy is not included in a query. To avoid
name resolution problems, define the default member in the cube's MDX script in the following situations:
if the cube refers to a database dimension more than once, if the dimension in the cube has a different
name from the dimension in the database, or if you want to have different default members in different
cubes.

You should be aware that an MDX query cannot skip query axes. That is, a query that includes one or
more query axes must not exclude lower-numbered or intermediate axes. For example, a query cannot
have a ROWS axis without a COLUMNS axis or have COLUMNS and PAGES axes without a ROWS axis.
8-10 Introduction to MDX

Establishing Cube Context

Every MDX query runs within a specified cube context. This context defines the members that are
evaluated by the expressions within the query.

In the SELECT statement, the FROM clause determines the cube context. Although the FROM clause
specifies the cube context as within a single cube, you can still work with data from more than one cube
at a time.
In addition to specifying a complete cube, you can also specify a subcube. Initially, you create the subcube
and then any query against the cube in that session will be limited to the subcube. The following MDX
code example limits the Budget cube to only two accounts for the session.

CREATE SUBCUBE Budget AS SELECT {[Account].[Account].&[4200],


[Account].[Account].&[4300] } ON 0 FROM Budget

Note The subcube has the same name as the cube.

Note The accounts 4200 and 4300 are preceded by an ampersand. The ampersand
signifies that the value is a key rather than a name.

You can also use the LOOKUPCUBE and FILTER functions to refine the cube context. The LOOKUPCUBE
function enables you to retrieve data from outside the cube. For example, the MDX statement in the
following code example retrieves data from the AdventureWorksArchive cube even though the current
context is AdventureWorks.

WITH MEMBER MEASURES.LOOKUPCUBEARCHIVE AS


LOOKUPCUBE("AdventureWorksArchive", "[Measures].[Internet Sales Amount]")
SELECT MEASURES.LOOKUPCUBEARCHIVE ON 0
FROM [Adventure Works]
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-11

Note The LOOKUPCUBE function is likely to cause poor performance, and if you use it
often, you should consider a cube redesign.

The FILTER function filters the results based on a search condition. The following code example filters the
results to only display records that have a Sales Value that is greater than 1000.

SELECT [Measures].[Sales Amount] ON 0,


FILTER([Date].[Date].[Date].MEMBERS, [Measures].[Sales Amount]>1000)
ON 1
FROM [Adventure Works]
8-12 Introduction to MDX

Lesson 2
Adding Calculations to a Cube

In SSAS, calculations include calculated members and named sets. Calculated members and named sets
are combinations of cube data, arithmetic operators, numbers, and functions. In MDX, a calculated
member is a member that is resolved by calculating an MDX expression to return a value, and a named
set is a set of dimension members or expressions that are grouped together for reuse in MDX queries. The
ability to construct and use calculated members and named sets in an MDX query provides a great deal of
manipulation capability for multidimensional data.
After completing this lesson, you will be able to:

• Describe how to add calculations to a cube.

• Explain the concepts of calculated members.


• Describe named sets.

• List useful non-family MDX functions.

• List useful family MDX functions.

• Define subcubes by using the SCOPE statement.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-13

The Calculations Tab of the Cube Designer

To create a calculated member, use the New Calculated Member button on the toolbar of the
Calculations tab of the Cube Designer. This command displays a form to specify several options for the
calculated member:

• Use the Script Organizer pane in form view to display the contents of the cube script in an ordered
format.
• Use the Calculation Tools pane in both form view and script view to display metadata, functions, and
tools that are available to the cube.
• Use the Script Editor pane in script view to edit the entire cube script and in form view to edit script
commands that the cube script contains.

• Use the Calculated Member Form Editor pane in form view to edit calculated members in the cube
script.

• Use the Named Set Form Editor pane in form view to edit named sets in the cube script.

The Calculated Member Builder is a principal interface for creating calculated members by using MDX.
The interface includes several regions:
• The top region contains three boxes that enable you to change the name of the member and the
dimension and location for the new member:
• The default dimension for a calculated member is the measures dimension.

• You have the option of selecting any of the cube dimensions in the Parent dimension list.

Note The parent member does not determine the aggregation of the calculated member,
because calculated members do not aggregate. The parent member merely dictates the
placement of the calculated member in the dimension hierarchy.
8-14 Introduction to MDX

• The second region contains the Value expression box, where you enter an MDX expression. You
type the expression in the Value expression box, double-click the dimension, or drag function
values to the box.

• The third region is the metadata area. On the left is a Data list that includes all of the dimensions
in the cube. In the center is a Functions list that displays all of the MDX functions. On the right
are buttons to help you construct an MDX expression.
• The fourth region displays information about the currently selected item in the Data and
Functions lists.

• The bottom region contains standard OK, Cancel, and Help buttons.

Calculations are solved in the order that is listed in the Script Organizer pane. You can reorder the
calculations by right-clicking any calculation and then clicking Move Up or Move Down on the shortcut
menu. You can also click a calculation and then click Move Up or Move Down on the toolbar.
For best performance with cell calculations, specify only a single member when possible. The Non-empty
behavior option stores the names of measures that are used to resolve NON EMPTY queries in MDX. If
this property is blank, the calculated member must be evaluated repeatedly to determine whether a
member is empty. If this property contains the name of one or more measures, the calculated member is
treated as empty if all of the specified measures are empty. This property is an optimization hint to SSAS
to return only records that are not NULL. Returning only records that are not NULL improves the
performance of MDX queries that use the NON EMPTY operator or the NonEmpty function or that
require the calculation of cell values.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-15

Calculated Members

A calculated member is a member whose value is calculated at run time by using an MDX expression that
you specify when you define the calculated member. A calculated member is available to business
intelligence (BI) applications just like any other member.

Calculated members do not increase the size of the cube because only the definitions are stored in the
cube; values are calculated in memory as required to answer a query.
Although calculated members are typically based on data that already exists in the cube, you can create
complex expressions by combining data with arithmetic operators, numbers, and functions.
There are two ways to create calculated members:

1. To create a calculated member for a single MDX query, you can define that calculated member by
using the WITH keyword.
2. To create a calculated member that is available throughout an MDX session, use the CREATE
MEMBER statement.

You can define a calculated member to have one of two contexts:

1. Query-scoped. A calculated member that is defined as a part of an MDX query and whose scope is
limited to that query.

2. Session-scoped. A calculated member whose scope is wider than the context of the query and whose
scope is the lifetime of the MDX session.

You should be aware that because calculated members perform calculations on cube data, they are
executed at run time. Therefore, extensive use of calculated members can cause query execution times to
increase and processing times to decrease.
8-16 Introduction to MDX

Named Sets

A named set is an MDX expression that returns a set of dimension members. You can define named sets
and save them as part of the cube definition; you can also create named sets in client applications.

Named sets have a number of useful features:

• You can use named sets in MDX queries in client applications and you can also use them to define
sets in subcubes.
• Named sets simplify MDX queries and provide useful aliases for complex, typically used, set
expressions.

Here are two example named sets:


• To create a named set for a single MDX query, you can define that named set by using the WITH
keyword.
• To create a named set that is available throughout an MDX session, use the CREATE SET statement. A
named set that is created by using the CREATE SET statement will not be removed until after the MDX
session closes.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-17

Demonstration: Using Named Sets in a Cube

In this demonstration you will create a named set a browse the cube using this named set.

 Task 1: Define a Core Products named set


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the
D:\10778A\Demofiles\Mod08 folder, run Setup.cmd as Administrator.
2. In the D:\10778A\Demofiles\Mod08 folder, double-click click Adventure Works OLAP.sln to open it
in SQL Server Data Tools.
3. In Solution Explorer, right-click Adventure Works OLAP, and then click Deploy. If prompted, specify
the user name ADVENTUREWORKS\Student and the password Pa$$w0rd.
4. In Solution Explorer, double-click Adventure Works Cube.cube, and in the cube designer, click the
Calculations tab.

5. On the toolbar of the Calculations tab, click New Named Set.

6. In the Name box, change the name of the new named set to [Accessories].

7. On the Metadata tab, in the Calculation Tools pane, expand Product, expand Product Category,
expand Members, and then expand All.

8. Drag Accessories into the Expression box.

9. On the File menu, click Save All.


 
8-18 Introduction to MDX

 Task 2: Browse the cube by using the new named set


1. In SQL Server Data Tools, on the Build menu, click Deploy Adventure Works OLAP. If you see a
warning that the database will be overwritten, click Yes.

2. When deployment has successfully completed, click the Browser tab.


3. In the Metadata pane, expand Measures, expand Reseller Sales, and then drag the Sales Amount –
Reseller Sales measure to the Drag levels or measures here to add to the query area.

4. In the Measure Group pane, expand the Product dimension, and then add the Product Category
hierarchy to the left of Sales Amount.

5. In the Measure Group pane, in the Product Category dimension, drag Accessories onto <Select
dimension>. The data now shows only sales for accessories.
6. Close SQL Server Data Tools.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-19

Useful MDX Functions (Non-Family Functions)

CURRENTMEMBER
The CURRENTMEMBER function returns the current member of a dimension. You typically use this with
another function to return a property of the current member. For example, the MDX expression in the
following code example returns the name of the current member in the Product dimension.

Product.CurrentMember.Name

NAME
As you can see in the preceding code example, the NAME function returns the name of the current
member, but it has other uses. The NAME function can return the name of a dimension, level, or member.
The syntax is exactly the same and depends entirely upon the object that is referenced before the NAME
function.

DIMENSION, HIERARCHY, and LEVEL


The DIMENSION, HIERARCHY, and LEVEL functions return the current dimension, hierarchy, or level. This
is often followed by the NAME function to return the name of the object.

PARALLELPERIOD
The PARALLELPERIOD function returns a member from the previous period with the same relative
expression. Therefore, if you use the parallel period of March 2011 at the Year level and define a lag of 2
to go back two years, it would return March 2009. You can use the DAX DATEADD function to perform a
similar task by using DAX.

For More Information For more information about the DAX language, see Module 11,
“Introduction to DAX.”
8-20 Introduction to MDX

NONEMPTY
NONEMPTY is a useful function because it returns the rows that are not empty from a set, as in the
following code example.

NonEmpty([Product Category].[Product Category Key].Members,[Measures].[Sales Amount])

For More Information For more information about MDX functions, see “Microsoft® SQL
Server® 2008 MDX Step by Step” by Bryan C. Smith et al. (ISBN-10: 0735626189) or the
Multidimensional Expressions (MDX) Reference, at
http://go.microsoft.com/fwlink/?LinkID=246786.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-21

Useful MDX Functions (Family Functions)

Within an OLAP database, relationships can be described between different members within the same
dimension by using terms that are analogous to a family tree. Understanding the relationships that exist is
important. MDX contains a wide range of functions that pertain to the relationships between the
members within a dimension.

Examples include:
• The PARENT function returns the member from one level above the current member, as in the
following code example.

Product.CurrentMember.Parent.Name

In the previous example, the PARENT function of the member San Francisco would return CA.
• The ANCESTOR function returns the member from a specified level above the current member, or
from a specified number of levels above the current member. For example, you could use this to
return the parent, and this code example would return the same value as the previous example.

Ancestor(Product.CurrentMember,1).Name

• The FIRSTCHILD and LASTCHILD functions return the first or last members respectively from the level
below the current member. For example, the first child of CA in the example would be Los Angeles,
and the last child of USA would be WA.
8-22 Introduction to MDX

• The FIRSTSIBLING and LASTSIBLING functions return the first or last members respectively from the
level of the current member. For example, the first sibling of San Diego in the example would be Los
Angeles and the last sibling of Los Angeles would be San Francisco.

For More Information For more information about MDX functions, see “Microsoft® SQL
Server® 2008 MDX Step by Step” by Bryan C. Smith et al. (ISBN-10: 0735626189) or the
Multidimensional Expressions (MDX) Reference, at
http://go.microsoft.com/fwlink/?LinkID=246786.
.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-23

Scoped Assignments

The SCOPE statement limits the scope of specified MDX statements to a specified subcube.

A scoped assignment uses the SCOPE command to define a subcube. You can then apply MDX statements
to this subcube, including the CALCULATE statement. You can use the THIS function to refer to the
subcube.

SCOPE statements will create subcubes that expose "holes" in ragged dimensions regardless of the MDX
Compatibility setting. For example, the statement SCOPE(Customer.State.members) can include the states
in countries or regions that do not contain states, but for which otherwise invisible placeholder members
were inserted.
8-24 Introduction to MDX

Lesson 3
Using MDX to Query a Cube

So far this module has looked at MDX in SSAS, but many MDX statements are used in client applications
to execute queries against the multidimensional cube. This lesson describes how to use MDX in commonly
used client applications.
After completing this lesson, you will be able to:

• Use MDX in SQL Server Management Studio.

• Use MDX in Microsoft Excel.


• Use MDX in SQL Server Reporting Services.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-25

Using MDX in SQL Server Management Studio

To run MDX queries in SQL Server Management Studio, simply connect to the SSAS instance when you
start Management Studio and you can then create a new MDX query.

Management Studio is intended purely for testing purposes and is not intended as a user interface. Users
are likely to consume the results of MDX queries as Reporting Services reports or as Excel spreadsheets.

Management Studio cannot pass parameters. Therefore, if you use SQL Server Profiler to trace queries
against your cube from SQL Server Reporting Services, you must replace the parameters with fixed values.

In the illustration on the slide, you can see a simple example of an MDX query to return the sales values
for each city for sales made in California. You can use it to test the query before you deploy it in another
client application.
8-26 Introduction to MDX

Using MDX in Excel

Microsoft Excel 2010 is one of the most commonly used client applications for SSAS multidimensional
cubes. By using Excel, you can browse the cube in an intuitive way without the need to understand MDX
statements. Excel automatically generates the MDX statements. However, if you want to inspect them, you
can run SQL Server Profiler to trace the MDX statements that are being executed against your cube.

Excel uses .ODC files to store connection string information. If you edit the .ODC file, you can use an MDX
statement as the source. The illustration on the slide shows an .ODC file that uses an MDX statement.
Initially the string only specified the Adventure Works cube, but in this example, it has been filtered to
show appropriate data. This enables you to hide the MDX from the user but customize the MDX
statements, which gives you the benefits of a straightforward application with the functionality of the
MDX language.
Using Excel as your client application has the benefit that users can interact with the data. They can
change which axes dimensions appear on, they can filter the results, and they can use the full functionality
of Excel to modify the format of the output. Most consumers of OLAP data are very familiar with Excel,
and using Excel as a client provides the power of an OLAP solution with a familiar and powerful interface.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-27

Using MDX in SQL Server Reporting Services

When you are using SSAS data in Reporting Services, it is very straightforward to configure. You can
simply specify Microsoft SQL Server Analysis Services as the data type when you are creating a new
data source and then specify your deployed SSAS database as the data source.

Reporting Services uses the same SQL Server Data Tools dialog boxes to build a multidimensional data
source as SSAS. SQL Server Data Tools gives you a very familiar view, and in most instances, you can
simply select the measures and members that you require without using MDX statements. However, you
can also click the Design Mode button and then you will have complete control of the MDX, as the
illustration on the slide shows.
You should be aware that the output from Reporting Services is two-dimensional whereas a cube is three-
dimensional; therefore, the results go through a flattening process. This flattening process results in
multiple-level dimensions having a field for each level of the dimension.

For More Information For more information about Reporting Services, see Module 2,
“Implementing Reports with SQL Server Reporting Services,” Module 3, “Supporting Self-
Service Reporting,” and Module 4, “Managing Report Execution and Delivery.”
8-28 Introduction to MDX

Lab Scenario

You are a BI developer for the Adventure Works Cycles company, and you are creating a custom analysis
application for the Chief Finance Officer (CFO). The application must return sales data for products,
customers, and dates from the Adventure Works Cube, so you have initially decided to experiment with
MDX syntax to query the cube and retrieve business data.

The CFO has also asked you to extend the cube to include measures for profit and gross profit margin, so
you must create calculated members for these and ensure that you can include them in queries from the
custom application you plan to build.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-29

Lab 8: Using MDX

Exercise 1: Querying a Cube by Using MDX


Scenario
You are a BI developer for the Adventure Works Cycles company, and you are creating a custom analysis
application for the Chief Finance Officer (CFO). The application must return sales data for products,
customers, and dates from the Adventure Works Cube, so you have initially decided to experiment with
MDX syntax to query the cube and retrieve business data.
In this exercise, you will write multiple MDX queries to obtain the necessary information for the sales
management team.

The main tasks for this exercise are as follows:

1. Prepare the lab environment.


2. Deploy an OLAP database.

3. Write simple MDX queries.

4. Write an MDX query to return data on rows and columns.

 Task 1: Prepare the lab environment


• Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab08\Starter
folder as Administrator.
8-30 Introduction to MDX

 Task 2: Deploy an OLAP database


• Use SQL Server Data Tools to open the Adventure Works OLAP.sln solution in the
D:\10778A\Labfiles\Lab08\Starter folder. Then deploy the solution, entering the user name
ADVENTUREWORKS\Student and the password Pa$$w0rd if prompted.

• When deployment has completed successfully, close SQL Server Data Tools.

 Task 3: Write simple MDX queries


• In SQL Server Management Studio, connect to the localhost instance of Analysis Services, and then
create and execute a new MDX query in the Adventure Works OLAP database that displays the
Sales Amount – Internet Sales measure for each product category.

• Use the following MDX code:

SELECT
[Measures].[Sales Amount – Internet Sales] On 0,
NonEmpty([Product].[Product Category].[English Product Category Name].Members) On 1
FROM [Adventure Works Cube]

• Create and execute another MDX query that that displays the Internet Sales Count measure for each
English Country Region Name in the Customer Geography hierarchy.
• Use the following MDX code:

SELECT
[Measures].[Internet Sales Count] On 0,
NonEmpty([Customer].[Customer Geography].[ English Country Region Name].Members) On
1
FROM [Adventure Works Cube]

 Task 4: Write an MDX query to return data on rows and columns


• In SQL Server Management Studio, create and execute an MDX query that returns the Sales Amount
measure with calendar years from the Calendar Date hierarchy on columns and cities from the
Customer Geography hierarchy on rows.
• Use the following MDX code:

SELECT
NonEmpty([Order Date].[Calendar Date].[Calendar Year].Members) ON COLUMNS,
[Customer].[Customer Geography].[City].Members ON ROWS
FROM [Adventure Works Cube]
WHERE [Measures].[Sales Amount - Internet Sales]

Results: After this exercise, you should have written MDX queries to return data from the Adventure
Works Cube cube.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-31

Exercise 2: Creating a Calculated Member


Scenario
The CFO has also asked you to extend the cube to include measures for profit and gross profit margin, so
you must create calculated members for these and ensure that you can include them in queries from the
custom application you plan to build.

In this exercise, you will create a calculated member to aggregate sales information and two additional
calculated members that return gross profit margins.

The main tasks for this exercise are as follows:

1. Define a Profit calculated member based on physical measures.

2. Define gross profit margin calculations.

3. Query the new calculated members.

 Task 1: Define a Profit calculated member based on physical measures


• Use SQL Server Data Tools to open the Adventure Works OLAP.sln solution in the
D:\10778A\Labfiles\Lab08\Starter\Adventure Works OLAP folder.

• On the Calculations tab of the cube designer for Adventure Works Cube.cube, create a new
calculated member named [Profit] that subtracts the Total Product Cost – Internet Sales measure
from the Sales Amount – Internet Sales measure.

• Format the calculated member as currency, add the fields used in the expression to the Non-empty
behavior list, and associate the calculated member with the Internet Sales measure group. The
completed calculated member should match the following image.
8-32 Introduction to MDX

 Task 2: Define gross profit margin calculations


• Create a second new calculated member named [Gross Profit Margin] that subtracts the Total
Product Cost – Internet Sales measure from the Sales Amount – Internet Sales measure and then
divides by Sales Amount – Internet Sales to return a percentage.

• Format the new calculated member to display as a percentage, add the Sales Amount – Internet
Sales measure to the Non-empty behavior list, and associate the calculated member with the
Internet Sales measure group . The completed calculated member should match the following
image.

• Deploy the solution, overwriting the existing database and entering the user name
ADVENTUREWORKS\Student and the password Pa$$w0rd if prompted. Then close SQL Server Data
Tools.

 Task 3: Query the new calculated members


• In SQL Server Management Studio, create and execute a new MDX query to return the calculated
measures.

• Use the following MDX code.

SELECT
{[Measures].[Profit], [Measures].[Gross Profit Margin]} ON COLUMNS,
NonEmpty([Product].[Product Category].[English Product Category Name]) ON ROWS
FROM [Adventure Works Cube]

Results: After this exercise, you should have created two calculated members and then queried them.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 8-33

Module Review and Takeaways

Review Questions
1. What do you use MDX queries and expressions for in SQL Server?
2. What are the three panes of the Calculations tab and what purpose does each pane serve?

3. How can you create named sets?


8-34 Introduction to MDX
9-1

Module 9
Customizing Cube Functionality
Contents:
Lesson 1: Working with Key Performance Indicators 9-3

Lesson 2: Working with Actions 9-11


Lesson 3: Working with Perspectives 9-16

Lesson 4: Working with Translations 9-19


Lab 9: Customizing a Cube 9-24
9-2 Customizing Cube Functionality

Module Overview

In this module, you will learn how to customize cube functionality by using several technologies available
to you in Microsoft® SQL Server® 2012 Analysis Services. Cubes function perfectly well without
customization; however customization provides enhanced user interfaces, automation, and translation.
In this module, you will learn about Key Performance Indicators and how they can be used to obtain a
quick and accurate historical summary of business success. You will learn about actions and how they
allow end-users to go beyond traditional analysis to initiate solutions to discovered problems and
deficiencies. You will learn about perspectives and how they allow users to see the cube in a simpler way,
enabling users to focus on the most relevant data to them. Finally you will learn about translations, and
how they can be used to translate various elements of a cube enabling users from all over the world can
view and understand cube and dimension data.

After completing this module, you will be able to:

• Describe Key Performance Indicators.

• Implement Actions.

• Explain Perspectives.

• Describe Translations.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-3

Lesson 1
Working with Key Performance Indicators

In business terminology, a Key Performance Indicator (KPI) is a quantifiable measurement for gauging
business success. A KPI is frequently evaluated over time. For example, the sales department of an
organization may use monthly gross profit as a KPI, but the human resources department of the same
organization may use quarterly employee turnover. Each is an example of a KPI. Business executives
frequently consume KPIs that are grouped together in a business scorecard to obtain a quick and accurate
historical summary of business success.
After completing this lesson, you will be able to:

• Describe KPIs.

• List the elements of a KPI.


• Browse a KPI.
9-4 Customizing Cube Functionality

Introducing KPIs

In Microsoft SQL Server Analysis Services, a Key Performance Indicator (KPI) is a collection of calculations,
which are associated with a measure group in a cube, that are used to evaluate business success. The KPI
measures the values in the cube against a goal. The KPI can also evaluate the values over time to provide
trend information.

To provide at-a-glance company performance to business users, there is an MDX expression that returns a
status between -1 (worst) and +1 (best). The presentation of this data is ultimately up to the client
application. However status and trend indicators can be set to suggest the graphical output. For example,
you have created a company performance dashboard to display KPI data on a SharePoint site. On the
SharePoint site, a status of -1.0 to -0.34 displays a red traffic light, a status of -0.33 to +0.33 displays an
amber traffic light and a status of +0.34 to +1.0 displays a green traffic light.
You must ensure that business rules are followed to assign the status value because an unsuitable MDX
formula could result in a department, or the company as a whole, being incorrectly assigned a successful,
or unsuccessful, status.
One key advantage of KPIs in Analysis Services is that they are server-based and are consumable by
different client applications. If a KPI is client-based it must be recreated for each client application and
potentially the results could differ if the implementations are not identical.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-5

Elements of a KPI

A simple KPI object is composed of a name, a description, the goal, the actual value achieved, a status
value, a trend value, a status indicator, a trend indicator, and a folder where the KPI is viewed.

Value
A value expression is a physical measure such as Sales, a calculated measure such as Profit, or a
calculation that is defined within the KPI by using a Multidimensional Expressions (MDX) expression.

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 defines. For example, the following goal expression for a Profit
measure has a value of 0.6 (or 60%) for Accessories and 0.3 (30%) for all other categories:

Case
When [Product].[Category].CurrentMember Is
[Product].[Category].[Accessories]
Then .60
Else .30
End
9-6 Customizing Cube Functionality

Status
A status expression is an MDX expression that Analysis Services uses to evaluate the current status of the
value expression compared to the goal expression with a result in the range of -1 to +1. -1 is the worst
result, and +1 is the best result. The status expression displays with a graphic to help you easily determine
the status of the value expression compared to the goal expression. For example, the following code
returns a value of 1 if you achieve the goal, a value of 0 if you are at least half way to achieving the goal,
and a value of -1 if you are less than halfway to achieving the goal:

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 an MDX expression that Analysis Services uses to evaluate the current trend of the
value expression compared to the goal expression. The trend expression helps the business user to quickly
determine whether the value expression is getting better or worse relative to the goal expression. You can
associate one of several graphics with the trend expression to help business users be able to quickly
understand the trend. For example, 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:

Case
When KpiValue( "Gross Profit Margin" ) >
(KpiValue( "Gross Profit Margin" ),
ParallelPeriod
( [Date].[Fiscal Time].[Fiscal Year], 1,
[Date].[Fiscal Time].CurrentMember ))
Then 1
When KpiValue( "Gross Profit Margin" ) <
(KpiValue( "Gross Profit Margin" ),
ParallelPeriod
( [Date].[Fiscal Time].[Fiscal Year], 1,
[Date].[Fiscal Time].CurrentMember ))
Then -1
Else 0
End

Additional properties of the KPI include:


• Display Folder. This is the folder in which the KPI will appear if you are browsing the cube.

• Parent KPI. This defines the parent of the current KPI. This causes the browser to display the KPI as a
child and also allows the parent to access the values of the child. This allows you to have KPIs based
on other KPIs. You can also 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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-7

Browsing KPIs

A key advantage of KPIs in Analysis Services is that they are server-based and are consumable by different
client applications. Being server-based enables all of the logic to be built in Analysis Services and stored
with the cube. However, it is possible for client applications to apply the same logic against the cube data
using MDX expressions. You can use MDX functions in client applications to retrieve individual sections of
the KPI, such as the value or goal, for use in MDX expressions, statements, and scripts.

It should be noted that the indicators that are defined in SQL Server Data Tools may or may not be
implemented by client applications. Third party client applications might not display the indicators that
you have defined and you should verify that the KPI displays correctly.
The example in the above illustration uses several MDX functions to return the KPI value, KPI goal, KPI
status, and KPI trend for the channel revenue measure of the Adventure Works database for the
descendants of three members of the Fiscal Year attribute hierarchy.
9-8 Customizing Cube Functionality

Demonstration: Using KPIs

 Task 1: Create a KPI


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the
D:\10778A\Demofiles\Mod09 folder, run Setup.cmd as Administrator.

2. In the D:\10778A\Demofiles\Mod09 folder, double-click Adventure Works OLAP.sln to open the


solution in SQL Server Data Tools.

3. In the Solution Explorer pane, right-click Adventure Works OLAP, and then click Deploy. If
prompted, specify the password Pa$$w0rd and click OK.
4. After deployment is complete, in Solution Explorer right-click Adventure Works Cube.cube, click
Open, and then click the KPIs tab.

5. On the toolbar of the KPIs tab, click New KPI.

6. In the Name box, type Reseller Revenue, and then in the Associated measure group list, click
Reseller Sales.

7. On the Metadata tab in the Calculation Tools pane, expand Measures, expand Reseller Sales, and
then drag the Sales Amount – Reseller Sales measure to the Value Expression box.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-9

8. On the Metadata tab in the Calculation Tools pane, expand Measures, expand Sales Quota, and
then drag the Sales Amount Quota measure to the Goal Expression box.

9. Verify 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 KPI Status Expression.txt in the demo folder):

Case
When
KpiValue("Reseller Revenue")/KpiGoal("Reseller Revenue")>=.95
Then 1
When
KpiValue("Reseller Revenue")/KpiGoal("Reseller Revenue")<.95
And
KpiValue("Reseller Revenue")/KpiGoal("Reseller Revenue")>=.5
Then 0
Else -1
End

10. Verify 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 KPI Trend Expression.txt in the
demo folder):

Case
When IsEmpty
(ParallelPeriod
([Date].[Calendar Date].[Calendar Year],1,
[Date].[Calendar Date].CurrentMember))
Then 0
When (
KpiValue("Reseller Revenue") -
(KpiValue("Reseller Revenue"),
ParallelPeriod
([Date].[Calendar Date].[Calendar Year],1,
[Date].[Calendar Date].CurrentMember))
/
(KpiValue ("Reseller Revenue"),
ParallelPeriod
([Date].[Calendar Date].[Calendar Year],1,
[Date].[Calendar Date].CurrentMember)))
>=.02
Then 1
When(
KpiValue("Reseller Revenue") -
(KpiValue ( "Reseller Revenue" ),
ParallelPeriod
([Date].[Calendar Date].[Calendar Year],1,
[Date].[Calendar Date].CurrentMember))
/
(KpiValue("Reseller Revenue"),
ParallelPeriod
([Date].[Calendar Date].[Calendar Year],1,
[Date].[Calendar Date].CurrentMember)))
<=.02
Then -1
Else 0
End
9-10 Customizing Cube Functionality

 Task 2: Browse a KPI


1. On the File menu, click Save All.

2. In SQL Server Data Tools, on the Build menu of, click Deploy Adventure Works OLAP.

3. When deployment has successfully completed, click Browser View on the toolbar of the KPIs tab,
and then click Reconnect.

4. In the top pane of the KPI browser, click Sales Territory (not Customer – Sales Territory) in the
Dimension list, click Sales Territory Key in the Hierarchy list, and then click Equal in the Operator
list.

5. In the Filter Expression list, expand All, select 1, 2, 3, 4, and 5, and then click OK.

6. Click anywhere in the KPI Browser pane to update the values for the Reseller Revenue KPI.
7. Close SQL Server Data Tools.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-11

Lesson 2
Working with Actions

In Microsoft SQL Server Analysis Services, an action is a stored MDX statement that can be presented to
and employed by client applications. In other words, an action is a client command that is defined and
stored on the server.
After completing this lesson, you will be able to:

• Describe actions.

• List the types of actions.


• Implement actions.
9-12 Customizing Cube Functionality

Introducing Actions

An action is a stored statement that can be presented to and employed by client applications enabling
business users to act upon the outcomes of their analyses. The action is stored in the Analysis Services
database and it is important to verify that the client application supports actions and that the client
application correctly carries out the events of the action.

A simple Action object is composed of: basic information, the target where the action is to occur, a
condition to limit the action scope, and the type.

Basic information includes the name of the action, the target of the action, and an optional condition for
the action.
The target is the actual location in the cube where the action is to occur and is composed of a target type
and a target object.

Target type could be level members, cells, hierarchy, hierarchy members, or others. The target object is a
specific object of the target type. For example, if the target type is hierarchy, then the target object is any
one of the defined hierarchies in the cube.
A condition is a Boolean MDX statement that evaluates to true or false. If the statement is true, the action
is performed, if the statement is false, the action is not performed.

By saving and reusing actions, end users can go beyond traditional analysis, which typically ends with
presentation of data, and initiate solutions to discovered problems and deficiencies, thereby extending
the business intelligence application beyond the cube.

You can exercise flexibility when you create actions: for example, an action can launch an application,
retrieve information from a database, or open a webe-maipage in a browser.

Actions can be configured to be triggered from almost any part of a cube, including dimensions, levels,
members, and cells, or create multiple actions for the same portion of a cube.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-13

Types of Actions

Actions can be of different types and have to be created accordingly. Typically actions pass an attribute of
the current object enabling them to be dynamic. For example, you could create a URL action that displays
the location of a customer on a map. To create this action, you can simply open Bing Maps and search for
any postal code. If you then click Share, Bing will generate a URL containing the postal code. You can
then remove the postal code and concatenate the original URL with
[Customers].CurrentMember.Postalcode. The above illustration demonstrates the example.

The following table lists the types of actions and how they are used.

Action Type Description

Standard - Dataset Returns a dataset to a client application.

Standard - Proprietary Performs an operation by using an interface other than those listed
in this table.

Standard - Rowset Returns a rowset to a client application.

Standard - Statement Runs an OLE DB command.

Standard - URL Displays a dynamic webpage in an Internet browser.

Reporting Submits a parameterized URL-based request to a report server and


returns a report to a client application.

Drillthrough Returns a drillthrough statement as an expression, which the client


executes to return the set of rows that represents the underlying
data from the data source of the selected cells of the cube where
the action occurs. For example, you could use this action on a
measure group for sales orders to drillthrough to details of the
orders that contribute to an aggregated total.
9-14 Customizing Cube Functionality

Building Actions for a Cube

Use the Actions tab of the cube designer to build actions for a cube and specify the following details for
standard actions:

• Name: select a name that identifies the action.

• Action Target: select the object to which the action is attached. For Target type, select from the
following objects:
• Attribute members

• Cells
• Cube

• Dimension members

• Hierarchy

• Hierarchy members

• Level

• Level members
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-15

• Action Content: select the type of action from the following:

Type Description

Dataset Retrieves a dataset.

Proprietary Performs an operation by using an interface other than those listed here.

Rowset Retrieves a rowset.

Statement Runs an OLE DB command.

URL Displays a variable page in an Internet browser.

• Additional Properties: select additional action properties from the following:

Property Description

Invocation Specifies how the action is run. Interactive, the default, specifies that the
action is run when a user accesses an object. The possible settings are:
• Batch
• Interactive
• On Open

Application Describes the application of the action.

Description Describes the action.

Caption Provides a caption that is displayed for the action. If the caption is
generated dynamically by an MDX statement, specify True for Caption is
MDX.

Caption is MDX If the Caption value is generated dynamically by an MDX statement,


specify True.

To create a new drillthrough action, on the Cube menu, click New Drillthrough Action and then specify
the drillthrough columns required by the action.

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 Reporting Services. For example,
AdventureWorks/YearlyInternetSales. For Report format select HTML5, HTML3, Excel, or
PDF based on the client tool your users are most likely to use to access your report.
9-16 Customizing Cube Functionality

Lesson 3
Working with Perspectives

Cubes can be very complex objects for users to explore in Microsoft SQL Server Analysis Services. A single
cube can represent the contents of a complete data warehouse, with multiple measure groups in a cube
representing multiple fact tables, and multiple dimensions based on multiple dimension tables. Such a
cube can be very complex and powerful, but daunting to users who may only need to interact with a
small part of the cube in order to satisfy their business intelligence and reporting requirements.

In Microsoft SQL Server Analysis Services, you can use a perspective to reduce the perceived complexity of
a cube in Analysis Services.

After completing this lesson, you will be able to:

• Describe perspectives.
• Implement perspectives.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-17

Introducing Perspectives

A perspective enables administrators to create views of a cube, helping users to focus on the most
relevant data. Although cubes are much more intuitive to navigate than relational databases, they can
become very large with several measure groups, many measures, and numerous dimensions. Perspectives
do not cause any additional processing overhead. Therefore, you can create perspectives for each view of
the data required by users.

A simple perspective object is composed of: basic information, dimensions, measure groups, calculations,
KPIs, and actions. Each of these properties defines a subset of the cube as follows:
• Basic information includes the name and the default measure of the perspective.
• The dimensions are a subset of the cube dimensions.

• The measure groups are a subset of the cube measure groups.


• The calculations are a subset of the cube calculations.

• The KPIs are a subset of the cube KPIs.

• The actions are a subset of the cube actions.


Objects in a cube that are not visible to the user through a perspective can still be directly referenced and
retrieved using XML for Analysis (XMLA), Multidimensional Expressions (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,
perspectives are used to provide a better user experience while accessing a cube.
9-18 Customizing Cube Functionality

Creating a Perspective

The first column of the Perspectives tab in the cube designer is the Cube Objects column, which lists all
of the objects in the cube.

You can add a perspective to the Perspectives tab by:

• Clicking New Perspective on the Cube menu.

• Clicking the New Perspective button on the toolbar.


• Right-clicking anywhere in the pane and click New Perspective on the shortcut menu.

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.

• Clicking the Delete Perspective button on the toolbar.


• Right-clicking any cell in the perspective you want to delete, and then clicking Delete Perspective on
the shortcut menu.

When you create a perspective, the name is initially Perspective (followed by an ordinal number, starting
with 1, if there is already a perspective named Perspective). You can click the name to edit it.
To hide an object from a perspective, clear the check box in the row that corresponds to the object in the
column for the perspective.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-19

Lesson 4
Working with Translations

Multilanguage support in Microsoft SQL Server Analysis Services is accomplished by using translations. In
this lesson, you will be introduced to the concepts involved in using translations and discuss how to
implement cube translations and dimension translations.
After completing this lesson, you will be able to:

• Describe translations.

• Implement cube translations.


• Implement dimension translations.
9-20 Customizing Cube Functionality

Introducing Translations

A translation is a simple mechanism to change the displayed labels and captions from one language to
another. It is useful to be able to translate various elements of a cube into a different language so that
these users can view and understand the cube's metadata. Translations are available for all objects in
Analysis Services. You can also use a translation 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: language ID number, and translated caption. The language ID
number is an Integer with the language ID. The translated caption is the translated text.
In Microsoft SQL Server Analysis Services, a cube translation is a language-specific representation of the
name of a cube object, such as a caption or a display folder. There is no automatic translation
functionality and you must provide every required label in every required language.
Translations provide server support for client applications that can support multiple languages, however, if
the client application does not support translations, the Default laanguage is displayed.

The collation and language information for the client computer is stored in the form of a locale identifier
(LCID). The following process takes place when a client connects to the cube:

• Upon connection, the client passes its own LCID to the instance of Analysis Services.

• The instance uses the LCID to determine which set of translations to use when providing metadata for
Analysis Services objects to each business user.
• If an Analysis Services object does not contain the specified translation, the default language is used
to deliver the content to the client.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-21

Implementing Cube Translations

Click the New Translation button on the toolbar of the Translations tab in the cube designer to create a
new translation and to remove a translation, click Delete Translation to delete the selected translation.

You can define the following parts of a cube translation:

• Default Language: Sets the names of the cube objects in the default language.

• Object Type: Displays the property that will be translated.


• <Language>: Type the value of the property for the cube object in the selected language.
9-22 Customizing Cube Functionality

Implementing Dimension Translations

Use the Translations tab in the dimension designer to define and manage translations for the dimension.

You can define the following parts of a dimension translation:


• Default Language: Sets the names of the dimension objects in the default language.

• Object Type: Displays the property that will be translated.


• <Language>: Type or select the property value of the dimension object in the selected language.

You can also translate member names 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
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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-23

Lab Scenario

Information workers in the sales department at Adventure Works Cycles currently use the cube you have
created to perform analysis of sales data. Several users have expressed a desire to be able to view
aggregated sales figures in Microsoft Excel®, and then quickly drill-through to see details of specific
orders for a given aggregation – for example, when viewing the sales total for bikes in 2003, the users
want to be able to quickly generate a second Excel worksheet that shows details of the customer, location,
date, and individual product for each bike sale in that year.

Additionally, some sales users are finding the cube too complex for their needs. These users typically only
need to analyze sales amount by customer, and would like to be able to view only the measures and
dimensions required to support this requirement.

Finally, the company employs a number of senior sales managers whose first language is French. These
users would like to be able to view cube data and metadata in French.
9-24 Customizing Cube Functionality

Lab 9: Customizing a Cube

Exercise 1: Implementing an Action


Scenario
Information workers in the sales department at Adventure Works Cycles currently use the cube you have
created to perform analysis of sales data. Several users have expressed a desire to be able to view
aggregated sales figures in Excel, and then quickly drill-through to see details of specific orders for a
given aggregation – for example, when viewing the sales total for bikes in 2003, the users want to be able
to quickly generate a second Excel worksheet that shows details of the customer, location, date, and
individual product for each bike sale in that year.

The main tasks for this exercise are as follows:


1. Prepare the lab environment.

2. Deploy an OLAP database.

3. Create a drillthrough action.


4. Browse a drillthrough action.

 Task 1: Prepare the lab environment


• Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab09\Starter
folder as Administrator.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-25

 Task 2: Deploy an OLAP database


• Use SQL Server Data Tools to open the Adventure Works OLAP.sln solution in the
D:\10778A\Labfiles\Lab09\Starter folder. Then deploy the solution, entering the user name
ADVENTUREWORKS\Student and the password Pa$$w0rd if prompted.

• Process the solution.

 Task 3: Create a drillthrough action


• In SQL Server Data Tools, on the Calculations tab of the cube designer for Adventure Works
Cube.cube, create a new drillthrough action named Internet Sales Details Drillthrough Action.
• Specify Internet Sales in the Measure group members list.
• Specify the following dimensions and return columns.

Dimension Return Columns

Customer English Country Region Name and Full Name

Order Date Simple Date

Product English Product Name

• Specify the caption Drillthrough to order details…


• Verify that the completed action resembles the following image, and then deploy the solution,
entering the user name ADVENTUREWORKS\Student and the password Pa$$w0rd if prompted.
9-26 Customizing Cube Functionality

 Task 4: Browse a drillthrough action


• In SQL Server Data Tools, on the Browser tab of the cube designer for Adventure Works
Cube.cube, click the Analyze in Excel icon to create a Microsoft Excel workbook with a connection
to cube. If a security notice is displayed, click Enable.

• In Excel, use the PivotTable to view Sales Amount – Internet Sales with Order Date.Calendar Date
on columns and Product Category on rows, as shown in the following image.

• In the PivotTable, right-click the sales amount for Bikes in 2003 (cell D4 in the image above), point to
Additional Actions, and click Drillthrough to order details….The order details for bikes in 2003
should be displayed in a new worksheet as shown in the following image.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-27

• When you have viewed the order details returned by the drillthrough action, close Excel without
saving your changes, and keep SQL Server Data Tools open for the next exercise.

Results: After this exercise, you should have defined a drillthrough action.
9-28 Customizing Cube Functionality

Exercise 2: Implementing a Perspective


Scenario
Some sales users are finding the cube too complex for their needs. These users typically only need to
analyze sales amount by customer, and would like to be able to view only the measures and dimensions
required to support this requirement.

The main tasks for this exercise are as follows:


1. Define a Sales Summary perspective.

2. Browse the cube using the Sales Summary perspective.

 Task 1: Define a Sales Summary perspective


• In SQL Server Data Tools, on the Perspectives tab of the cube designer for Adventure Works
Cube.cube, create a new perspective named Sales Summary.

• Include only the following cube objects in the perspective.

Cube Object Object Type

Sales Amount – Internet Sales Measure in the Internet Sales MeasureGroup

Customer CubeDimension

• The completed perspective should resemble the following image.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-29

 Task 2: Browse the cube using the Sales Summary perspective


• Deploy the solution, entering the user name ADVENTUREWORKS\Student and the password
Pa$$w0rd if prompted.

• On the Browser tab of the cube designer for Adventure Works Cube.cube, reconnect to the cube
and if necessary, clear any existing values from the data grid and filter areas.
• In the Cube Selection area above the Metadata pane, select the Sales Summary perspective, and
browse the cube, noting that only the Sales Amount – Internet Sales measure and Customer
dimension are available.

• In the Cube Selection area, select the Adventure Works Cube perspective, and note that all
measures and dimensions defined in the cube are available.

• Keep SQL Server Data Tools open for the next exercise.

Results: After this exercise, you should have defined a perspective and browsed the cube using the new
perspective.
9-30 Customizing Cube Functionality

Exercise 3: Implementing a Translation


Scenario
The company employs a number of senior sales managers whose first language is French. These users
would like to be able to view cube data and metadata in French.

In this exercise you will add the final enhancement to the revenue information cube by specifying
translations for the French speakers in your company.
The main tasks for this exercise are as follows:

1. Specify translations for the Time Dimension metadata.

2. Specify translations for the Adventure Works cube metadata.


3. Browse the cube using the new translations.

 Task 1: Specify translations for the Time Dimension metadata


• Using the dimension designer for the Date dimension, create a French (France) translation.
• For the Caption object of the Date dimension, under the French (France) column, enter Date.

• For the Caption object of the Month Number of Year attribute, under the French (France) column,
enter Mois d'Année.

Tip To type é hold the Alt key and type 130 using the number pad on your keyboard
ensuring NumLock is turned on. If this is not possible type the captions without accents.

• Click the ellipses for the French Mois d'Année attribute and modify the attribute data translation to
use the FrenchMonthName column as shown in the following image.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-31

• Verify that the Translations tab for the Date dimension resembles the following image, and then
save all files in the solution.

 Task 2: Specify translations for the Adventure Works cube metadata


• On the Translations tab of the cube designer for Adventure Works Cube.cube, create a new
French (France) translation with the following caption translations.
• Internet Sales measure group: Ventes d'Internet.

• Sales Amount – Internet Sales measure: Ventes Total.


9-32 Customizing Cube Functionality

• Verify that the Translations tab for the Adventure Works Cube cube resembles the following
image, and then save all files in the solution.

 Task 3: Browse the cube using the new translations


• Deploy the solution, entering the user name ADVENTUREWORKS\Student and the password
Pa$$w0rd if prompted.
• On the Browser tab of the cube designer for Adventure Works Cube.cube, reconnect to the cube
and if necessary, clear any existing values from the data grid and filter areas.

• Select French (France) in the Language list.


• Browse the cube to show the Ventes Total measure in the Ventes d’Internet measure group
aggregated by the Order Date.Mois d’Année hierarchy.

Results: After this exercise, you have specified translations for the time dimension metadata and for the
Adventure Works cube metadata, and browsed the cube using the new translations.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 9-33

Module Review and Takeaways

Review Questions
1. How are KPIs useful to the business?
2. What value do Actions add to the business?

3. What objects can be displayed or hidden in a perspective?


9-34 Customizing Cube Functionality
10-1

Module 10
Implementing a Tabular Data Model with Microsoft
PowerPivot
Contents:
Lesson 1: Introduction to Tabular Data Models and PowerPivot Technologies 10-3
Lesson 2: Creating a Tabular Data Model by Using PowerPivot for Excel 10-13

Lesson 3: Sharing a PowerPivot Workbook and Using PowerPivot Gallery 10-26

Lab 10: Using PowerPivot for Excel 10-32


10-2 Implementing a Tabular Data Model with Microsoft PowerPivot

Module Overview

Microsoft® PowerPivot technologies empower information workers and business intelligence (BI)
professionals by delivering in-depth, up-to-date insights through familiar business tools. PowerPivot for
Microsoft Excel® enables information workers and BI professionals to create powerful, sophisticated
reports that can dynamically group, sort, and recalculate data at the click of a button. PowerPivot for
Microsoft SharePoint® provides a platform for sharing PowerPivot for Excel workbooks with a wider
audience, helping to promote collaboration and enable consistent and accurate decision making through
central governance of key business information. PowerPivot technologies use the same tabular data
model format as the tabular data models that you create in Microsoft SQL Server® 2012 Analysis Services.

This module introduces tabular data models, explains how to install and use the PowerPivot for Excel add-
in, and describes how to share a workbook to PowerPivot Gallery.

After completing this module, you will be able to:

• Describe the key features and benefits of tabular data models and PowerPivot technologies.

• Create a PowerPivot for Excel workbook.

• Share a PowerPivot for Excel workbook to PowerPivot Gallery and use a PowerPivot for Excel
workbook as a data source.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-3

Lesson 1
Introduction to Tabular Data Models and PowerPivot
Technologies

This lesson introduces tabular data models and PowerPivot technologies, describes the options for
creating tabular data models, and provides an overview of installing PowerPivot for Excel and PowerPivot
for SharePoint.

After completing this lesson, you will be able to:

• Describe tabular data models.


• Describe the options for creating tabular data models.

• Describe PowerPivot for Excel and PowerPivot for SharePoint.


• Install PowerPivot for Excel.

• Install PowerPivot for SharePoint in a basic configuration.


10-4 Implementing a Tabular Data Model with Microsoft PowerPivot

What Is a Tabular Data Model?

Tabular data models are in-memory databases that use the xVelocity storage and processing engine. The
xVelocity engine uses column-based storage and sophisticated compression algorithms to deliver very fast
query response times, even with large datasets that contain millions of rows of data. This makes the
xVelocity engine ideal for the kinds of complex queries that data analysis tools and reporting tools
typically generate. Tabular data models provide a quick way for information workers and BI professionals
to develop data models that they can use with data analysis tools such as Microsoft Excel and Power View.

Tabular data models expose data in a relational format, so the developer interacts with tables and
relationships instead of dimensions and cubes. They are quick and easy to create compared to
multidimensional data models, although they lack some of the advanced features that multidimensional
models have. Tabular models are suitable for anything from a personal desktop BI application that has
been developed in Excel to departmental or even larger solutions, depending upon the complexity of the
application.

Tabular models offer two principal advantages:


• The relational model is very widely understood and relatively intuitive, so the barrier to entry for
relational database developers and information workers who want 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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-5

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.

For More Information For more information about DAX, see Module 11 of this course,
Introduction to DAX.
10-6 Implementing a Tabular Data Model with Microsoft PowerPivot

Options for Creating Tabular Data Models

You can create a tabular data model by using the PowerPivot for Excel add-in or by using SQL Server Data
Tools to create a model on a SQL Server 2012 Analysis Services instance that is running in Tabular mode.

Tabular Data Models in PowerPivot for Excel


Importing data into a PowerPivot for Excel workbook automatically creates a tabular data model that is
stored in the workbook. The PowerPivot Window provides a development environment that enables you
to import data and create and manage relationships, perspectives, hierarchies, measures, and calculated
columns. Analysts and information workers use the tabular data models in PowerPivot for Excel
workbooks to create ad-hoc reports and perform complex analysis. Developers can use them to create
models that they can later scale up to SQL Server 2012 Analysis Services models. You can centralize and
share PowerPivot for Excel workbooks by using PowerPivot for SharePoint.

Tabular Data Models in SQL Server 2012 Analysis Services


You can create tabular data models in SQL Server 2012 Analysis Services by using SQL Server Data Tools.
The tabular data model development environment in SQL Server Data Tools has a very similar look and
feel to the PowerPivot window in a PowerPivot for Excel workbook. This makes it easier for PowerPivot for
Excel users who have little experience of multidimensional databases to develop models for large-scale
applications. SQL Server 2012 Analysis Services Tabular Projects support additional features that are not
available in PowerPivot for Excel workbooks, and that enable you to create models that can meet the
demands of departmental or enterprise solutions. These features include:

• DAX-based row-level security. This enables you to implement fine-grained control of data. Security in
tabular databases is role-based. You can apply database-wide permissions to roles that enable read,
process, or administrative access. DAX functions enable you to extend this to lock down data access
to individual rows if required.

• Partitioning. This improves performance by enabling you to divide a table into multiple partitions that
you can process separately.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-7

• DirectQuery mode. This enables your tabular database to respond to queries by using data that is
stored in the underlying data source instead of using the in-memory xVelocity engine.
• Deployment options. These enable you to move the models that you create from the development
environment onto test or production servers.

For More Information For more information about tabular data models in SQL Server
2012 Analysis Services, see Module 12 of this course, Implementing an Analysis Services
Tabular Data Model.
10-8 Implementing a Tabular Data Model with Microsoft PowerPivot

PowerPivot Technologies

PowerPivot for Excel


Excel is a well-established BI tool that information workers use to create workbook-based applications to
support business activities. PowerPivot for Excel extends the functionality of Excel 2010 to provide a
powerful, feature-rich BI application with a familiar, easy-to-use interface. It enables information workers
to quickly access the information that they need, and reduces their dependency on professional BI
developers to create applications for them.

PowerPivot for Excel extends the Excel user interface and adds the PowerPivot ribbon, from which you can
launch the PowerPivot window to create database connections, manage tables, and create DAX measures
and calculated columns. In the workbook in Excel, you can add PivotTable tables, PivotChart charts, and
slicers, which enable you to slice and dice data with just a few clicks. The key features of PowerPivot for
Excel include:

• Fast response times when performing complex analyses, even for very large datasets.

• Minimal memory footprint due to compression.

• Advanced features such as hierarchies, perspectives, and relationship management.

• The ability to create custom measures and calculated columns by using DAX.

• The ability to scale up the workbook to a departmental solution by using the workbook as a template
for a new SQL Server 2012 Analysis Services Tabular project.

New Features in PowerPivot for Excel


The latest version of PowerPivot, released alongside SQL Server 2012, offers a range of new features,
including:
• A diagram view that shows tables and relationships in a schema-like diagram. By using this interface,
users can manage tables, relationships, and hierarchies through simple drag-and-drop operations.

• Hierarchies to enable users to add hierarchically related fields to PivotTable tables with a single click.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-9

• Perspectives to enable the creation of simplified, streamlined views of data.

• Support for multiple relationships between tables.

• The ability to sort one column by the values in another column. This can be useful when, for example,
you want to sort an alphabetic column, such as DayOfWeek, by a numerical column, such as
DayNumberOfWeek, so that it displays correctly in Excel worksheets.

• Many new DAX functions including SWITCH, DISTINCTCOUNT, TOPN, and a set of functions that
support parent-child relationships.

• Reporting properties to enable the workbook to support Power View reports.

PowerPivot for SharePoint


PowerPivot for SharePoint provides a central, managed portal through which analysts can securely share
and collaborate on their PowerPivot for Excel workbooks. It enables users to locate the workbooks that
they need easily, and reduces the wasted effort of users creating duplicate workbooks because they do
not realize that a similar workbook already exists. PowerPivot for SharePoint helps administrators to
establish governance over workbooks, which might be stored on the computers of many different users
throughout an organization. It also makes it easier to provision appropriate resources to optimize
application performance. Key features of PowerPivot for SharePoint include:
• A portal through which information workers can upload PowerPivot for Excel workbooks and SQL
Server Reporting Services reports.
• Server-side processing and rendering in the SharePoint farm so that users can view a workbook in a
browser with levels of performance that are similar to when they view a workbook locally in Excel.

• A thumbnail gallery that enables users to browse and preview applications on the portal.
• Automatic data refresh for workbooks.
• The option to open workbooks in Excel so that users can download and edit workbooks locally.

• Integrated SharePoint security that allows users to define permissions on workbooks.


• Centralized administration through the SharePoint Central Administration website.
• Health checks and monitoring through PowerPivot Management Dashboard.

• Usage data collection so that administrators and developers can identify key applications and data
sources.

• Integration with SQL Server Reporting Services, which enables you to create standard reports and
Power View reports that use PowerPivot for Excel workbooks as data sources. You can also publish
SQL Server Reporting Services reports to PowerPivot Gallery.
10-10 Implementing a Tabular Data Model with Microsoft PowerPivot

Installing PowerPivot for Excel

Installing the PowerPivot for Excel add-in is the quickest way for you to get started with PowerPivot
technologies because you do not need to install SQL Server 2012 Analysis Services to use it. You can
download the PowerPivot for Excel add-in from the Microsoft website. It is available in both 32-bit and
64-bit versions. You should ensure that you download the correct version for your operating system.

Before installing PowerPivot for Excel, you should ensure that you have the following software installed on
your computer:

• Microsoft Excel 2010, including the most recent updates.


• Microsoft .NET Framework 4.

• Microsoft Visual Studio® 2010 Tools for .NET Runtime. You should install this after you install the
.NET Framework 4.
After you install the latest version of PowerPivot for Excel, you can create new workbooks and open
workbooks that you created by using the previous version. When you open workbooks that you created
by using the previous version, you will be given the option to upgrade these workbooks so that you can
use them with the new version. You cannot reverse this upgrade process, so if you want to preserve the
old version, you should make a copy of it before you upgrade it.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-11

Installing PowerPivot for SharePoint

To install PowerPivot for SharePoint, you must first install Microsoft SharePoint Server 2010 and
SharePoint Server 2010 Service Pack 1 (SP1) on a computer that is a member of a domain. You can install
only one instance of PowerPivot for SharePoint on a server.

You install PowerPivot for SharePoint by using SQL Server Setup. During setup, you can choose to install
SQL Server 2012 Analysis Services in Multidimensional mode, Tabular mode, or PowerPivot for SharePoint
mode.

To install in PowerPivot for SharePoint mode, in the Role Setup window, you should select the SQL Server
PowerPivot for SharePoint option. You can optionally add a SQL Server database engine instance at this
point. After you install PowerPivot for SharePoint, you must configure the server. You can use the
PowerPivot Configuration Tool to do this; you can also use the SharePoint Central Administration website
or Windows PowerShell™ to perform the configuration.

For More Information For more information about PowerPivot Configuration in Central
Administration Web, see http://go.microsoft.com/fwlink/?LinkID=246787.

For More Information For more information about PowerPivot Configuration using
PowerShell, see http://go.microsoft.com/fwlink/?LinkID=246788.

The PowerPivot Configuration Tool scans the computer and supplies a list of actions that are required to
configure it. The list will vary, depending on the configuration of the individual server. The PowerPivot
Configuration Tool then performs the actions that are specified in the list and registers the SQL Server
2012 Analysis Services PowerPivot installation on the local server. You can also use the PowerPivot
Configuration Tool to detect configuration errors and repair them.
10-12 Implementing a Tabular Data Model with Microsoft PowerPivot

For More Information For more information about PowerPivot for SharePoint
Installation, see http://go.microsoft.com/fwlink/?LinkID=246789.

Certain configurations of PowerPivot for SharePoint require you to configure Kerberos, particularly when
you need to refresh data in workbooks. For example, if the data connection in a PowerPivot for Excel
workbook that is shared in PowerPivot for SharePoint contains a reference to a SQL Server instance, and
this instance must access another SQL Server instance on a different computer to complete the data
refresh, you must configure identity delegation.

For More Information For more information about how to Configure Kerberos
Authentication for SharePoint 2010 Products, see
http://go.microsoft.com/fwlink/?LinkID=246790.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-13

Lesson 2
Creating a Tabular Data Model by Using PowerPivot for
Excel

PowerPivot for Excel enables information workers and BI developers to create self-service BI solutions that
provide valuable business insights and deliver excellent performance. This lesson explains how you can
create and manage tabular data models in PowerPivot for Excel workbooks.

After completing this lesson, you will be able to:

• Describe how PowerPivot extends the Excel user interface.


• Describe the options for importing data into a PowerPivot for Excel workbook.

• Describe the options for refreshing data in a PowerPivot for Excel workbook.
• Describe how to import data into a PowerPivot for Excel workbook by using linked and non-linked
tables.

• Describe the options for creating, managing, and using table relationships.

• Explain the benefits of adding hierarchies to your data models.

• Describe the options for displaying data in worksheets in a PowerPivot for Excel workbook.

• Describe how to use slicers in a PowerPivot for Excel workbook.


10-14 Implementing a Tabular Data Model with Microsoft PowerPivot

The PowerPivot Ribbon

Installing the PowerPivot for Excel add-in adds a new PowerPivot ribbon to the Excel interface. This ribbon
enables you to perform tasks that are related to the data and tables that you import into PowerPivot, such
as creating linked tables and performing relationship detection. It also enables you to work with the data
in Excel worksheets by adding PivotTable tables and PivotChart charts, and by creating and managing
measures and key performance indicators (KPIs).

From the PowerPivot ribbon, you can also launch the PowerPivot window. The PowerPivot window
provides two views through which you can manage tables and data:
• The table view. Here, you can create calculated columns and measures, rename tables and columns,
hide tables and columns, and perform other similar tasks.

• The diagram view. Here, you can create and manage hierarchies and table relationships.

Creating PowerPivot workbooks is an iterative process. You frequently have to switch between the
PowerPivot window and the Excel worksheet as you make changes to the data model and then test them
in your PivotTable tables and PivotChart charts.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-15

Importing Tables from a Data Source

One of the challenges that information workers face is obtaining access to the data that they need
because that data is often stored on multiple systems and in multiple formats. PowerPivot for Excel
provides a wide range of heterogeneous data sources to help to ensure that you can include all of the
relevant data in your analysis, no matter where it is located.

When you create a connection, both the connection configuration information and the imported data are
stored in the workbook itself. It is not necessary for workbooks to maintain an active connection to their
data sources. This reduces the impact on source data stores and makes workbooks in PowerPivot for Excel
portable, so you can freely share and move workbooks between machines.
The available data sources in PowerPivot for Excel include an instance of the SQL Server database engine,
SQL Server 2012 Analysis Services cubes, Microsoft SQL Azure™, Excel, Microsoft Access®, text files,
PowerPivot for Excel workbooks, SQL Server Reporting Services reports, SharePoint lists, data feeds, and
databases running on Oracle, Teradata, Sybase, Informix, and IBM DB2 database management systems. In
addition to this extensive list, there are also OLE DB and Open Database Connectivity (ODBC) providers
that enable imports from any OLE DB or ODBC source.

When you import from a database, you can filter tables to exclude columns that you do not need for your
analysis. You should always try to ensure that you do not import unnecessary data into the workbook in
PowerPivot for Excel to ensure optimal performance and to 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 names that are easy to understand, so providing a friendly name will make the data easier for the
end user to interpret.
10-16 Implementing a Tabular Data Model with Microsoft PowerPivot

Demonstration: Creating a PowerPivot Workbook

 Task 1: Create a PowerPivot workbook


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the
D:\10778A\Demofiles\Mod10 folder, run Setup.cmd as Administrator.

2. Start Microsoft Excel 2010, and on the ribbon, click the PowerPivot tab.

3. On the ribbon, click PowerPivot Window. Note that the workbook window is still open, and you can
switch between the windows by clicking the Excel icon on the task bar or by clicking the Switch to
Workbook button in the title bar of the PowerPivot window.
4. In the PowerPivot window, on the ribbon, in the Get External Data area, click From Database, and
then click From SQL Server.

5. In the Table Import Wizard dialog box, change the Friendly connection name to Adventure
Works DW; in the Server name box, type localhost; select Use Windows Authentication, and in
the Database name list, click AdventureWorksDW. Then click Next.

6. On the Choose How to Import the Data Page, choose the option to select from a list of tables and
views, and click Next.

7. On the Select Tables and Views page, select the FactResellerSales table and then click Select
Related Tables.

8. Review the tables that were selected, and unselect DimCurrency and DimPromotion. Then select
DimGeography, DimProductSubcategory and DimProductCategory (which were not
automatically selected because they are not directly related to FactInternetSales).
9. Change the Friendly Name for all selected tables to remove the Dim or Fact prefix.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-17

10. Click the rows for the DimProductCategory table, and then click Preview and Filter. Then in the
Preview Selected Table dialog box, uncheck the SpanishProductCategoryName,
FrenchProductCategoryName, and Image column headers and click OK. This removes columns you
do not plan to use in the data model.

11. Click Finish to create the data model, and when the data for all tables is imported, click Close.

12. Click each tab at the bottom of the PowerPivot window to view the tables in the model. Then, on the
ribbon, in the View section, click Diagram View. This shows the relationships between the tables in
the data model.

13. On the ribbon, in the View section, click Data View to return to the tabbed tables, and click the
ProductCategory tab.

14. Double-click the column header for EnglishProductCategoryName and change the name to
Category.
15. Close the PowerPivot window (but not the Excel workbook).

 Task 2: Create a PivotTable from a PowerPivot data model


1. In Excel, on the PowerPivot tab, click the PivotTable drop-down button and click PivotTable.

2. In the Create PivotTable dialog box, select Existing Worksheet, and click OK.
3. In the PowerPivot Field List pane, expand the ResellerSales table and select SalesAmount. The
total sales amount value is added to the PivotTable.

4. Expand the ProductCategory table and select Category. The sales amount is now aggregated by
product category. Note that PowerPivot has automatically used the relationship from ResellerSales
to ProductCategory through the Product and ProductSubcategory tables in order to aggregate
the data.
5. Close Excel without saving the workbook.
10-18 Implementing a Tabular Data Model with Microsoft PowerPivot

Refreshing Data

When you import data from a data source into a PowerPivot for Excel workbook, you are effectively
taking a snapshot of that data at a point in time. The data is stored in the xVelocity store in the workbook,
so it is not necessary to maintain a live connection to your data sources. This approach provides a great
deal of flexibility because it enables you to move your workbook to a new location without having to
reconfigure the data source connection. It also removes the burden of processing data from the data
source system. However, because the data is stored in the PowerPivot for Excel workbook, it will go out of
date when the data in the data source changes. This might not matter much for historic analyses, but it
can be problematic if your report requires the most recent data, for example, if you are analyzing stock
levels at warehouses. You can use the Refresh option in the PowerPivot window to ensure that the data
that the workbook contains remains as up to date as you need it to be to support your business activities.
You can choose to refresh all of the data in the workbook or just the currently selected table. Refreshing
only one table is usually faster and places less of a burden on the source system. This option is often used
when importing from a data warehouse; you can frequently refresh the fact tables, which typically
experience a great deal of change, and less frequently refresh the related dimension tables.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-19

Adding Linked and Non-Linked Tables

You can incorporate data from workbooks in Excel into PowerPivot by using linked tables. A linked table is
a table in PowerPivot that maintains a “live link” to a table in the original worksheet. This means that any
changes that you make to the table in the worksheet are automatically propagated to the table in
PowerPivot when the user opens the PowerPivot window.

You can also import data into a PowerPivot table by using a non-linked table. A non-linked table is a
range of cells in an Excel worksheet that you copy and paste into a PowerPivot tabular data model. Non-
linked tables can be useful if you want to add data to your workbook quickly without setting up a
connection, or if you need to add data that you cannot import by using a data provider. However, unlike
data that you access from a data source or data from a linked table, data that you add by using the copy-
and-paste method is static and you cannot refresh it later.

Creating a Linked Table


To create a linked table from a workbook in Excel, you should follow these steps:

1. Format the data in the Excel worksheet as a table, specifying whether the table has headers. These
headers will become column names in the PowerPivot table.

2. Highlight the table, and then on the PowerPivot tab, click the Create Linked Table option.

You can configure linked tables to refresh automatically or manually. For manual refreshes, you can use
the Update All option to refresh all linked tables or the Update Selected option to update only the
highlighted linked table.

Creating a Non-Linked Table


To create a non-linked table from a workbook in Excel, you should follow these steps:
1. Copy a range of cells from a workbook in Excel.

2. In the PowerPivot window, click the Paste To New Table option to paste it into a new table.
10-20 Implementing a Tabular Data Model with Microsoft PowerPivot

Creating and Managing Table 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. PowerPivot for Excel identifies related tables by
analyzing the foreign key relationships that exist among them. 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 PowerPivot for Excel workbooks.

You create and manage relationships by using the Create Relationship and Manage Relationship
buttons on the Table tab of the PowerPivot window. When you create a relationship, you must specify the
two tables that you want to relate and the common column that contains the key values. Relationships
between tables in workbooks in PowerPivot for Excel are many-to-one; therefore, when you create a
relationship, you must specify the columns and tables for each end of that relationship. You use the upper
Table and Column boxes to supply the table and column that are at the “many” end of the relationship,
and you use the lower Table and Column boxes to specify the table and column that are at the “one” end
of the relationship.
The new version of PowerPivot for Excel supports multiple relationships between tables. Date and fact
tables in data warehouses often have multiple relationships to support different dates such as order date,
due date, and delivery date. PowerPivot for Excel can recognize these relationships when you import the
tables and create the relationships automatically. One relationship is marked as the active relationship
between the tables. When you view multiple relationships in the diagram view of the PowerPivot window,
the active relationship shows as an unbroken line, and the non-active relationships appear as dotted lines.

For More Information For more information about multiple relationships, see the Multiple
Relationships topic in Module 11 of this course, Introduction to DAX.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-21

Hierarchies

A hierarchy is a collection of columns from a single PowerPivot table that are organized as parent and
child nodes. You create hierarchies in PowerPivot for Excel workbooks to simplify the end-user experience.
A PowerPivot for Excel workbook might contain many tables and columns, so users might have to sort
through a large number of these to find the columns that they want to add to their report. By creating a
hierarchy, you place all of the related columns that they need together so that they appear as a single
node in the PowerPivot Field List. The users can then add all of these columns to the report with just
one click. For example, you might have Product Category, Subcategory, and Product Name columns in
a table. These values represent a natural hierarchy by which you might want to organize data, so you can
use them to create a hierarchy.
10-22 Implementing a Tabular Data Model with Microsoft PowerPivot

Demonstration: Creating a Hierarchy

 Task 1: Create a hierarchy


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the
D:\10778A\Demofiles\Mod10 folder, run Setup.cmd as Administrator.

2. In the D:\10778A\Demofiles\Mod10 folder, double-click Demo.xlsx to open it in Microsoft Excel.

3. On the ribbon, click the PowerPivot tab, and then click PowerPivot Window. The PowerPivot
window may open behind the workbook, so minimize the workbook so you can see it.

4. In the PowerPivot window, on the ribbon, in the Get External Data area, click the Refresh drop-
down button and click Refresh All. In the Data Refresh dialog box, when all tables have been
refreshed, click Close.

5. In the PowerPivot window, on the ribbon, in the View area, click Diagram View.
6. In the Sales Territory table, right-click the Sales Territory table header, click Create Hierarchy.,
type Location, and then press Enter.

7. In the Sales Territory table, click Sales Territory Group, drag it onto the Location hierarchy, and
then release it.
8. In the Sales Territory table, click Country, drag it onto the Location hierarchy, and then release it.

9. In the Sales Territory table, click Sales Territory Region, drag it onto the Location hierarchy, and
then release it.
10. Close the PowerPivot window, and return to the workbook and save it, but do not close it. You will
return to it in a later demonstration.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-23

Using PivotTable Tables and PivotChart Charts

You can add PivotTable tables and PivotChart charts to worksheets in PowerPivot for Excel workbooks by
using the PivotTable option on the PowerPivot ribbon. PivotTable tables provide drilldown functionality
that enables you to explore data and access the information that you need with just a few clicks. You can
easily add and remove summary values, row and column labels, and filters by using drag-and-drop
operations in the PowerPivot Field List.

PivotChart charts add visual impact to your applications, enabling you to show key summary information
in a way that is immediately easy to comprehend. There is a range of PivotChart designs to choose from,
including column charts, line charts, and pie charts. You can create them from the PowerPivot ribbon in
the same way as you do when you create PivotTable tables. There are extensive formatting options for
PowerPivot reports that enable you to customize the appearance of the applications that you create,
making it easy to highlight key data or comply with corporate design requirements.
10-24 Implementing a Tabular Data Model with Microsoft PowerPivot

Using Slicers

A slicer is an item that you can add to a worksheet in a PowerPivot for Excel workbook to enable you to
slice and dice data quickly and easily. Slicing data means applying a single filter to the data, for example,
all sales for all countries for the year 2004 only. Here, 2004 is the filter. Dicing means applying multiple
filters, for example, all sales for the country France and the year 2004. Here, 2004 and France are the
filters.

Slicers lay out the filter values as clickable areas in the workbook in PowerPivot for Excel, so you can apply
and remove filters with just a single click. When you use a slicer to apply a filter, the xVelocity engine
calculates the new value and automatically updates all PivotTable tables and PivotChart charts that are
associated with the slicer. You can choose to connect an individual slicer in a worksheet with one, two, or
more PivotTable tables or PivotChart charts.
You can add vertical and horizontal slicers to a worksheet. They function in the same way; the difference is
that vertical slicers are positioned vertically in the workbook and horizontal slicers are positioned
horizontally. When you design an application, you can arrange slicers in relation to the other components
to provide the best visual experience.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-25

Demonstration: Creating a PivotTable Table and a Slicer

 Task 1: Create a PivotTable table


1. In the Demo.xlsx workbook, click the Demo worksheet tab.
2. Click in cell B2. On the ribbon, on the PowerPivot tab, click PivotTable, and then click PivotTable.

3. In the Create PivotTable dialog box, select Existing Worksheet, and then click OK.

4. In the PowerPivot Field List, expand Reseller Sales, and then select Total Profit to add this column
to the Values area.
5. In the PowerPivot Field List, expand Sales Territory, and then select Location.

 Task 2: Create a slicer


1. Expand Date, and then drag Calendar Year to the Slicers Horizontal area.

2. In the slicer, click 2001, and then wait for the data in the PivotTable table to update.

3. Repeat the previous step for 2002, 2003, and 2004.

4. Click the Clear Filter button.

5. Save and close Demo.xlsx.


10-26 Implementing a Tabular Data Model with Microsoft PowerPivot

Lesson 3
Sharing a PowerPivot Workbook and Using PowerPivot
Gallery

PowerPivot for SharePoint enables information workers and BI developers to share the PowerPivot for
Excel workbooks that they create, browse workbooks in a visually rich gallery, and open workbooks in
Windows® Internet Explorer®.

This lesson explains how you can upload PowerPivot for Excel workbooks, browse and customize
PowerPivot Gallery, and use a PowerPivot workbook as a data source.
After completing this lesson, you will be able to:

• Explain the benefits of sharing workbooks to PowerPivot Gallery.

• Browse and customize PowerPivot Gallery.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-27

Sharing PowerPivot for Excel Workbooks

PowerPivot for Excel workbooks can provide valuable business insights that information workers want to
share with their colleagues. However, simply exchanging workbooks by email or some other method can
cause problems because the existence of multiple copies of a report can lead to inconsistencies. For
example, some versions of a report may be refreshed when others are not, or some versions may be
embellished with additional charts or data when other versions remain unchanged. Furthermore,
workbooks that are transferred like this will almost certainly fall outside the governance of the IT
department and will not be backed up regularly, leading to the possibility that reports that influence key
business decisions might easily be lost.

Sharing workbooks to PowerPivot Gallery enables users to distribute important workbooks easily, while
helping to ensure that they remain consistent and are regularly backed up. You can upload a PowerPivot
for Excel workbook by using the Upload Document option in PowerPivot Gallery, or by using the Publish
to SharePoint option in Excel. Users can browse the gallery, and when they find a workbook that they
want to view, they can open it in Internet Explorer simply by clicking it. If they then want to explore the
data further, they can use the Open in Excel button to open the workbook in Excel.

Using a PowerPivot for Excel Workbook as a Data Source


Information workers can connect to workbooks in PowerPivot Gallery to use them as data sources for
Excel workbooks.
10-28 Implementing a Tabular Data Model with Microsoft PowerPivot

PowerPivot for SharePoint exposes the data as a SQL Server 2012 Analysis Services cube. You can connect
to a PowerPivot for Excel workbook in PowerPivot Gallery by creating an Analysis Services Connection
from the Data tab in the Excel workbook. In the Analysis Services Connection dialog box, in the Server
Name field, you must specify the URL of the workbook for the connection to use, as the following code
example shows.

http://MIA-SQLBI/PowerPivot Gallery/Sales Overview.xlsx

After you create the connection, you can create PivotTable tables and PivotChart charts in the Excel
workbook to view the data.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-29

Using PowerPivot Gallery

PowerPivot Gallery provides an intuitive, visually appealing way for users to browse through the available
workbooks in PowerPivot and reports in SQL Server Reporting Services on a SharePoint server.

PowerPivot Gallery is a SharePoint library template that is installed along with the rest of PowerPivot for
SharePoint. It provides a photographic snapshot of compatible files so that users can easily identify those
that might be of interest to them. It also provides information about the creator of the document and the
date and time that it was last modified.

Note PowerPivot Gallery can only provide previews for workbooks in Excel 2010 and
reports in SQL Server Reporting Services that contain PowerPivot data.

Customizing the Gallery


You can customize the gallery by changing the sort order, adding filters, and changing the view that the
gallery uses. There are four gallery views to choose from:

• The Gallery view. Shows a preview to the left with smaller previews for each worksheet.

• The All Documents view. Shows documents in a list format.


• The Theater view. Shows previews in the central area with smaller previews for each worksheet below.

• The Carousel view. Shows previews in the center, and you can move through the thumbnail previews
sequentially, in a carousel fashion.
10-30 Implementing a Tabular Data Model with Microsoft PowerPivot

Demonstration: Sharing a PowerPivot for Excel Workbook to PowerPivot


Gallery

 Task 1: Share a PowerPivot for Excel workbook to PowerPivot Gallery


1. Click Start, and then click Internet Explorer.

2. On the Adventure Works Portal - Home page, in the Libraries list, click PowerPivot Gallery.
3. On the ribbon, click the Documents tab, click the Upload Document drop-down button, and then
click Upload Document.

4. In the PowerPivot Gallery – Upload Document dialog box, click Browse.


5. In the Choose File to Upload box, navigate to D:\10778A\Demofiles\Mod10, click Demo.xlsx, and
then click Open.

6. In the PowerPivot Gallery – Upload Document dialog box, click OK. If the PowerPivot Gallery –
Demo.xlsx dialog box appears, click Save.

7. When the large Demo icon appears in the PowerPivot gallery, click it to open the workbook in Excel
Services in the SharePoint site.
8. Click the 2001 slicer and verify that you can interact with the shared workbook.

9. At the top of the workbook page, in the breadcrumbs trail, click Adventure Works Portal. Then
close Internet Explorer.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-31

Lab Scenario

Some senior business analysts at Adventure Works Cycles want to analyze data for reseller sales in
Microsoft Excel. These experienced employees are experienced users and should be able to create their
own analytical models, without relying on the IT department creating a cube.

You plan to empower these users to use PowerPivot to create and share tabular data models in Excel.
10-32 Implementing a Tabular Data Model with Microsoft PowerPivot

Lab 10: Using PowerPivot for Excel

Exercise 1: Creating a Tabular Data Model by Using PowerPivot for Excel


Scenario
Information workers at Adventure Works currently use reports to view business information. However,
some power users want to be able to obtain a deeper understanding of the data by taking advantage of
the powerful analysis features of Excel 2010. In addition to Excel, you plan to install the PowerPivot for
Excel add-in, which enables these power users to create their own tabular data models for data analysis.
You also plan to install PowerPivot for SharePoint so that they can easily share these models with other
interested users. You want to test the features and functionality of these products before you roll them
out.
The main tasks for this exercise are as follows:

1. Prepare the lab environment.

2. Import data into a PowerPivot for Excel workbook.

3. Rename columns in a PowerPivot for Excel workbook.


4. Import data into a PowerPivot for Excel workbook by using a query.

5. Create a relationship manually.

6. Create a hierarchy.
7. Hide tables from client tools.
 
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-33

 Task 1: Prepare the lab environment


• Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab10\Starter
folder as Administrator.

 Task 2: Import data into a PowerPivot for Excel workbook


• Start Microsoft Excel 2010, and open the PowerPivot Window.

• Import the following tables from the AdventureWorksDW database on the localhost instance of
SQL Server.

Table Friendly Name Columns Removed by Filter

DimDate Date SpanishDayNameOfWeek


FrenchDayNameOfWeek
SpanishMonthName
FrenchMonthName

DimEmployee Employee LoginID


EmailAddress
Phone
EmergencyContactName
EmergencyContactPhone

DimProduct Product SpanishProductName


FrenchProductName
FrenchDescription
ChineseDescription
ArabicDescription
HebrewDescription
ThaiDescription
GermanDescription
JapaneseDescription
TurkishDescription

DimProductCategory Product Category SpanishProductCategoryName


FrenchProductCategoryName
Image

DimProductSubcategory Product Subcategory SpanishProductSubcategoryName


FrenchProductSubcategoryName

DimSalesTerritory Sales Territory

FactResellerSales Reseller Sales

• Save the workbook in the D:\10778A\Labfiles\Lab10\Starter folder as Sales Overview.xlsx.


10-34 Implementing a Tabular Data Model with Microsoft PowerPivot

• The PowerPivot window should resemble the following image.

 Task 3: Rename columns in a PowerPivot for Excel workbook


• Rename the columns in the following tables.

Table Name Existing Column Name New Column Name

Date EnglishDayNameOfWeek Day

Date EnglishMonthName Month

Date CalendarYear Calendar Year

Date FiscalYear Fiscal Year

Employee FirstName First Name

Employee LastName Last Name

Product EnglishProductName Product

Product Category EnglishProductCategoryName Category

Product Subcategory EnglishProductSubcategoryName Subcategory

Sales Territory SalesTerritoryCountry Country

Reseller Sales TotalProductCost Total Product Cost

Reseller Sales SalesAmount Sales Amount


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-35

 Task 4: Import data into a PowerPivot workbook by using a query


• Import data from the DimGeography table in the AdventureWorksDW database on localhost into
the data model by using a query. The query should include all columns other than the following (tip:
You can use the visual query designer in the Table Import Wizard to create the query).

• SpanishCountryRegionName
• FrenchCountryRegionName

• PostalCode

• IpAddressLocator
• After you have imported the data, rename the imported table to Geography.

• The imported table should look similar to this:

 Task 5: Create a relationship manually


• View the diagram for the data model, and drag the SalesTerritoryKey column from the Sales
Territory table to the SalesTerritoryKey column in the Geography table to create a relationship
between these tables as shown here (you may need to rearrange the tables in the diagram).
10-36 Implementing a Tabular Data Model with Microsoft PowerPivot

 Task 6: Create a hierarchy


• In data view, add a new column named Subcategory to the Product table. The column should use
the following DAX formula.

=RELATED('Product Subcategory'[Subcategory])

• Add a second new column named Category to the Product table. This column should use the
following DAX formula.

=RELATED('Product Category'[Category])

Note These DAX formulas create calculated columns in the Product table that use the
RELATED function to bring the data in the Category and Subcategory columns into the
Product table. You will learn more about writing DAX formulas in Module 11 of this course,
Introduction to DAX.

The new columns in the Product table should resemble the following image. The first 200 products
have no subcategory or category, so you will need to scroll down to see the values.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-37

• View the diagram for the data mode, and in the Product table, create a hierarchy named Products
that contains the Category, Subcategory, and Product columns (in that order), as shown here.

 Task 7: Hide tables from client tools


• In data view, right-click the Product Category table tab, and then click Hide from Client Tools.

• Hide the Product Subcategory table in the same way. The PowerPivot window should now look like
this:

• Save the Sales Overview.xslx workbook.

Results: After this exercise, you should have created and saved a PowerPivot workbook.
10-38 Implementing a Tabular Data Model with Microsoft PowerPivot

Exercise 2: Using a Tabular Data Model in Excel


Scenario
You are continuing to explore the capabilities of PowerPivot for Excel before you roll it out to your users.

The main tasks for this exercise are as follows:

1. Create a PivotTable table.

2. Create a measure.

3. Add formatting to a PivotTable table.

4. Create PivotChart charts.

5. Add slicers.

 Task 1: Create a PivotTable table


• In Excel, switch to the empty workbook.

• Add a PowerPivot PivotTable to cell B2 in the Sheet 1 worksheet in Excel.


• Add the Sales Amount and Total Product Cost columns from the Reseller Sales table to the
PivotTable.

• Add the Products hierarchy from the Product table to rows of the PivotTable.
The workbook should resemble the following image.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-39

 Task 2: Create a measure


• In the PowerPivot Field List, right-click Reseller Sales, and then click Add New Measure

• Use the following DAX formula to create a measure named Total Profit in the Reseller Sales table.

=SUM('Reseller Sales'[Sales Amount]) - SUM('Reseller Sales'[Total Product Cost])

• Format the measure as currency.

The measure settings for the Total Profit measure should look like this:

The Total Profit measure is added to the PivotTable.

 Task 3: Add formatting to a PivotTable table


• On the ribbon, in the PivotTable Tools group, click the Design tab, and in the PivotTable Styles
section, select a visual style for the PivotTable.

• On the ribbon, in the Layout group, click Blank Rows, and then select the Insert Blank Line after
Each Item option.

• On the ribbon, click the Home tab.

• In the PivotTable table, select all of the rows in the Total Profit column (do not include the Total
Profit header row). In the Styles area, add conditional formatting. Use the Green–Yellow-Red color
scale.

• Expand the rows in the PivotTable table to view the effects of the formatting options that you
configured.
10-40 Implementing a Tabular Data Model with Microsoft PowerPivot

 Task 4: Create PivotChart charts


• Click in cell G9, and then on the PowerPivot tab, add a PivotChart to the existing worksheet.

• In the PowerPivot Field List pane, drag the following fields to the appropriate chart layout sections to
create the chart.

Table Field Chart Area

Reseller Sales Sales Amount Values

Product Category Axis Fields

Date Calendar Year Legend Fields

• Use the PivotChart tools in Excel to format the chart so that it looks similar to the following image.

• In cell G30, add a second PivotChart that uses the following fields:

Table Field Chart Area

Reseller Sales Sales Amount Values

Sales Territory Country Axis Fields


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-41

• Format the second chart and change its chart type so that it resembles the following image.

 Task 5: Add slicers


• Click the PivotTable table that you created in Task 1.

• Add two horizontal slicers. One that uses the Country column in the Sales Territory table and one
that uses the Calendar Year column in the Date table. The workbooks should resemble the following
image.
10-42 Implementing a Tabular Data Model with Microsoft PowerPivot

• Test the slicers and note that only the data in the PivotTable is affected by them, the PivotChart
values are not filtered. Then clear the filters.

• Right-click the Calendar Year slicer, click PivotTable Connections, select PivotTable2 and
PivotTable3, and then click OK. This associates the slicer with the two PivotChart charts.
• Repeat the last step to connect the Country slicer to just the Sales Amount by Category by Year
PivotChart chart (PivotTable2).

• Test the slicers. The Calendar Year slicer should filter the PivotTable and both PivotCharts, while the
Country slicer should filter only the PivotTable and the Sales Amount by Category by Year
PivotChart.

• Clear the filters, and then save the Sales Overview.xlsx workbook and close it.

Results: After this exercise, you should have created a worksheet that contains two PivotChart charts, a
PivotTable table, and two slicers.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-43

Exercise 3: Sharing a PowerPivot Workbook to PowerPivot Gallery


Scenario
Having tested the PowerPivot for Excel add-in, you now want to test PowerPivot for SharePoint.

The main tasks for this exercise are as follows:

1. Upload a PowerPivot for Excel workbook to PowerPivot Gallery.

2. Open a PowerPivot for Excel workbook from PowerPivot Gallery.

 Task 1: Upload a PowerPivot for Excel workbook to PowerPivot Gallery


• Open Internet Explorer and on the Adventure Works Portal - Home webpage at http://mia-sqlbi,
view the PowerPivot Gallery library.

• Upload the Sales Overview.xlsx workbook from the D:\10778A\Labfiles\Lab10\Starter folder. When
uploaded, the workbook should be displayed as shown here.
10-44 Implementing a Tabular Data Model with Microsoft PowerPivot

 Task 2: Open a PowerPivot for Excel workbook from PowerPivot Gallery


• Click the large icon for the Sales Overview.xlsx workbook in the gallery. It should be opened in Excel
Services as shown here.

• Verify that the slicers still filter the data when used in Excel Services, and then close Internet Explorer.

Results: After this exercise, you should have uploaded a workbook to PowerPivot Gallery and browsed it
by using Internet Explorer and Excel.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 10-45

Exercise 4: Using a PowerPivot Workbook as a Data Source


Scenario
Finally, you want to test how to use a PowerPivot for Excel workbook as a data source for Excel.

The main task for this exercise is as follows:

• Connect to a PowerPivot workbook in PowerPivot Gallery and use it to create a PivotTable table in
Excel.

 Task 1: Connect to a PowerPivot workbook in PowerPivot Gallery and use it to create


a PivotTable table in Excel
• Start Microsoft Excel 2010, and in the new workbook, click the Data tab, on the ribbon, click Get
External Data, click From Other Sources, and then click From Analysis Services.

• In the Data Connection Wizard dialog box, on the Connect to Database Server page, in the Server
name field, type http://localhost/PowerPivot Gallery/Sales Overview.xlsx, select Windows
authentication, and then click Next.
• On the Select Database and Table page, select Model, and click Next, and then finish the Data
Connection wizard.

• Import the data as a PivotTable Report to cell A1 in the existing worksheet.


• In the PivotTable Field List, expand Reseller Sales if necessary, and then select Sum of Sales
Amount.

• Expand Employee if necessary, select Last Name, and then review the data in the PivotTable table.

• Close Microsoft Excel and don’t save any changes. Close Internet Explorer.

Results: After this exercise, you should have created a connection to a PowerPivot workbook in
PowerPivot Gallery and used it to create a PivotTable table in Excel.
10-46 Implementing a Tabular Data Model with Microsoft PowerPivot

Module Review and Takeaways

Review Questions
1. What are the differences between multidimensional data models and tabular data models? Why
might you choose to create one rather than the other?

2. What extra functionality does a SQL Server 2012 Analysis Services tabular data model offer over a
PowerPivot for Excel tabular data model?

3. How can information workers use the PowerPivot workbooks that individuals upload to PowerPivot
Gallery?
11-1

Module 11
Introduction to DAX
Contents:
Lesson 1: DAX Fundamentals 11-3

Lesson 2: Using DAX to Create Calculated Columns and Measures in a


Tabular Data Model 11-15

Lab 11: Creating Calculated Columns and Measures by Using DAX 11-29
11-2 Introduction to DAX

Module Overview

You can extend the Microsoft® PowerPivot for Microsoft Excel® and Microsoft SQL Server® 2012
Analysis Services tabular data models that you create by using the Data Analysis Expressions (DAX)
language. DAX is a highly flexible language that enables you to create measures and calculated columns
that you can use in PivotTable tables and PivotChart charts.

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 these in your tabular data models.

After completing this module, you will be able to:

• Describe the fundamentals of DAX.


• Use DAX to create calculated columns and measures.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-3

Lesson 1
DAX Fundamentals

To use DAX effectively, it is necessary to understand the components of the language and its capabilities.
This lesson explains the fundamentals of DAX and provides an overview of the functionality that it offers.

After completing this lesson, you will be able to:

• Describe DAX and how it is used.


• Describe the different types of DAX functions.

• Describe the syntax for writing DAX formulas.

• Describe aggregations.
• Explain why context is important when writing DAX formulas.

• Describe the basics of DAX queries.


11-4 Introduction to DAX

Overview of DAX

Formula-Based Language
The DAX language consists of a library of functions, operators, and constants that enables you 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 2012, you
can use DAX in tabular data models in SQL Server Analysis Services and also in the tabular data models
that you create in PowerPivot for Excel workbooks. New extensions make it possible to use DAX as a query
language, too.

Similar to Excel Formulas


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 that Excel formulas provide. The similarity between DAX and Excel
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.

New Functions
The latest version of DAX includes new functions that increase both the flexibility and usability of the
language, making it possible to create measures and calculated columns that enable you to solve even
more sophisticated business problems. These new functions include:

• USERELATIONSHIP. Enables you to specify which relationship to use when multiple table relationships
exist.

• LOOKUPVALUE. Enables you to return values based on the values in a different column.
• PATH and PATHITEM. Enable you to implement parent-child relationships.

• SWITCH. Enables you to return different values depending upon the input expression.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-5

• DISTINCTCOUNT. Returns a count of the cells that contain unique values.

• RANK.EQ and RANKX. Enable you to produce data rankings.

• CROSSJOIN and GENERATE. Enable you to perform table joins.

• TOPN. Enables you to display only the top n rows of a set of data, where n is a number that you
choose.
11-6 Introduction to DAX

DAX Functions

DAX provides a range of functions that you can use to build formulas. Although many of these functions
are the same as or similar to the functions that you use to build formulas in Excel, DAX includes many
additional functions that make it possible 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, and you can nest functions
within other functions with up to 64 levels of nesting.

Note You should avoid having too many levels of nesting in your formulas because it
makes them difficult to write and troubleshoot.

DAX includes several categories of functions:

• Text. These functions include CONCATENATE, TRIM, and BLANK. They are based on the Excel string
functions, and enable you to manipulate strings.

• 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 tabular data models in SQL Server Analysis Services.
• Filter and value. These functions include CALCULATE, ALL, FILTER, and RELATED. They enable you 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. They enable you to perform logical tests
on expressions to return information about the state of the tested values, and to use conditional
logic.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-7

• 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.
• Date and time. These functions include DATE, MONTH, and YEAR. They are equivalent to date and
time functions in Excel.

• Time intelligence. These functions include DATEADD, DATESBETWEEN, and FIRSTDATE. They enable
you to work with columns that use the date data type in a more sophisticated way, for example, by
calculating values for one time period with reference to another time period.
11-8 Introduction to DAX

DAX Syntax and Data Types

DAX is syntactically similar to the Excel formula language, so users who are already skilled in this area
should quickly be able to start creating DAX formulas. The following list summarizes basic DAX syntax and
conventions:

• All DAX formulas must start with an equal sign (=), followed by an expression.

• Expressions can contain functions, operators, constants, and references to columns in tables. Object
names that are referenced in expressions, such as table and column names, are case insensitive and
can include spaces. You cannot use leading or trailing spaces, characters that are invalid in the names
of SQL Server Analysis Services objects, or control characters in table, column, or measure names.
Arithmetic, comparison, text concatenation, and logical operators are largely the same as for formulas
in Excel, and they mostly work in the same way.
• DAX functions use tables and columns as inputs. You should use fully qualified names when you
reference columns to avoid ambiguity. A fully qualified name uniquely identifies a column because it
includes the name of the table to which the column belongs. Use brackets around the column names
and single straight quotation marks around table names, for example, 'Date'[Calendar Year]. You
can use unqualified names to refer to columns that are in the same table. For example, the fully
qualified name 'Date'[Calendar Year] can also be written as [Calendar Year].

• When you refer to a measure, for example, when you are writing a measure that references another
measure, you should enclose the measure name in brackets, for example, [Total Profit].

Note PowerPivot for Excel and SQL Server Data Tools support AutoComplete. You should
use AutoComplete to ensure accuracy and compliance with syntactical requirements.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-9

Data Types
DAX uses the following data types:

• I8 (eight-byte integer).
• R8 (eight-byte real number).

• Boolean.

• String.
• Date.

• CY (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.

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.

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 SQL Server, both NULL + 5 and NULL * 5 result in a NULL value.
SQL Server NULL values are implicitly converted to BLANK values when you import data
into a tabular data model.

For More Information For more information about Data Types Supported in PowerPivot
Workbooks, see http://go.microsoft.com/fwlink/?LinkID=246791.
11-10 Introduction to DAX

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?" Answering these kinds of questions requires you to group and aggregate
data in some way. You group data by using values that give meaning and context to the data, such as
Product Category or Sales Region. These values are usually stored in the tables that you import from your
data sources. You can aggregate data by using DAX aggregation functions. The list below contains
commonly used aggregation functions:

• SUM. Adds up all of the values in a numerical column, and provides a single total for that column. For
example, the following code example adds up all values in the Sales Amount column in the Reseller
Sales table.

=SUM('Reseller Sales'[Sales Amount])

• SUMX. Filters and then adds up all of the values in a numerical column, and returns a single total for
that filtered column. For example, the following code example returns the sum total of the Freight
column in the Internet Sales table, but the calculation only includes rows for which the
SalesTerritoryKey value is 5.

=SUMX(FILTER('Internet Sales', 'Internet Sales'[SalesTerritoryKey]=5),[Freight])

• COUNT. Returns a count of the number of rows that are not blank for columns that contain either
numbers or dates. COUNTA is similar, but it returns a count of the number of rows that are not blank
for columns that contain nonnumeric values.

For example, the following code example returns a count of the rows in the Order Date column in
the Reseller Sales table.

=COUNT('Reseller Sales'[Order Date])


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-11

• 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. For example, the following code example returns the number of
rows in the Phone column in the Reseller table, where the value in the Status column is set to
"Active".

=COUNTAX(FILTER('Reseller',[Status]="Active"),[Phone])

The COUNTX function works in the same way as the COUNTAX function, but it only counts numerical
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.

• MIN and MAX. Return the minimum and maximum values in a numerical column. The following code
example returns the maximum value for the Sales Amount column in the Reseller Sales table.

=MAX('Reseller Sales'[Sales Amount])

The MAXA and MINA functions return the maximum and minimum numerical values in a column, but
they also handle nonnumeric logical values such as TRUE and FALSE, which evaluate to 1 and 0
respectively.
• MAXX and MINX. Return the maximum and minimum values in a column in a table that is filtered by
using an expression. For example, the following code example returns the minimum value for the
Freight column in the Internet Sales table for which the corresponding SalesTerritoryKey value is
5.

=MINX(FILTER('Internet Sales', [SalesTerritoryKey] = 5),[Freight])

• AVERAGE. Returns the mean of all values in a numerical column. For example, the following code
example returns the average value in the Total Product Cost column in the Reseller Sales table.

=AVERAGE('Reseller Sales'[Total Product Cost])

The AVERAGEA function does the same thing as AVERAGE, but it also handles nonnumeric data types.
• 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 example sums the Freight and
TaxAmt values for each row in the Internet Sales table and then calculates the average value.

=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, the values in the column 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
a different type of aggregation, such as COUNT, MIN, or AVERAGE, from a list; the DAX formula is
automatically created for you. When you need to create aggregations that are more complex than this,
you can create a measure.
11-12 Introduction to DAX

Context

When you create a DAX measure or calculated column, you define a field that you can use in a
PowerPivot PivotTable or a PivotChart. However, the specific values that appear in any given PivotTable or
PivotChart will depend on the context, such as the columns and rows that you add 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 that represents the total sales amount for all categories, years, and countries for 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 value
that displays changes to reflect the context. This context-aware behavior makes it possible to perform
dynamic analysis of data quickly and easily, without the need 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 that your reports do not aggregate data in the way that you
intended, and are inaccurate and misleading.

Types of Context
There are three types of context to consider:

1. Row context. When you create a calculated column in a table, you specify the column or columns that
it should reference. For example, the formula in the code example below references the First Name
and Last Name columns in the Employee table.

=CONCATENATE([First Name], CONCATENATE(" ", [Last Name]))

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 you are using any
function that evaluates an expression for each row in a table, such as SUMX.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-13

2. Query context. When you add a measure to a PivotTable table, the PowerPivot 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 and the PowerPivot engine must now take account of the new context that
is performing the calculation for each row.

3. Filter context. You can use DAX functions to modify the row context and query context by creating
filters in formulas. The FILTER function enables you to produce a subset of rows on which you can
then perform a calculation. For example, you might filter by specifying a product category and 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 enables you to selectively
override filters by specifying particular columns to retain in the filter context; all other columns are
ignored.
11-14 Introduction to DAX

DAX Queries

The latest version of DAX includes extensions that enable you to write queries that retrieve data. Client
reporting tools, such as Power View, use DAX queries to query tabular data models in SQL Server Analysis
Services. Although it is not likely that you will need to write DAX queries manually, it can be useful to have
a basic understanding of them to help you with troubleshooting.

You can retrieve data from tables by using the EVALUATE keyword, which is functionally equivalent to the
SELECT statement in SQL Server. The following code example returns all of the rows from the Reseller
Sales table.

EVALUATE('Reseller Sales')

Queries can include FILTER to return a reduced result set, in much the same way as a WHERE clause
returns a reduced result set in SQL Server. The following code example returns all of the rows from the
Reseller Sales table where the OrderDateKey value is greater than 20040101.

EVALUATE(FILTER('Reseller Sales', 'Reseller Sales' [OrderDateKey]>20040101))

You can also order result sets. The following code example returns all of the rows from the Reseller Sales
table where the OrderDateKey value is greater than 20040101. The results are ordered by Sales Amount.

EVALUATE(FILTER('Reseller Sales', 'Reseller Sales'[OrderDateKey]>20040101))


ORDER BY 'Reseller Sales'[Sales Amount] ASC

For More Information For more information about DAX Table Queries, see
http://go.microsoft.com/fwlink/?LinkID=246792.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-15

Lesson 2
Using DAX to Create Calculated Columns and Measures in
a Tabular Data Model

You use DAX to create calculated columns and measures, which 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 by using a variety of functions, including time intelligence functions and functions
that manipulate table relationships. This lesson also shows you how to create dynamic measures that can
use conditional logic to perform different calculations based on different inputs.

After completing this lesson, you will be able to:

• Explain how to use calculated columns.


• Explain how to use measures.

• Describe how PowerPivot handles multiple relationships between tables.

• Describe time intelligence.

• Describe dynamic measures.


11-16 Introduction to DAX

Calculated Columns

After you import data into a tabular data model, you can enhance the model by adding calculated
columns to your tables. 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 that are based on measures, or on other calculated
columns. The following code example creates a calculated column in the Employee table. It obtains the
values from the First Name and Last Name columns in the Employee table and concatenates them,
putting a space between the first and last names.

=CONCATENATE('Employee'[First Name], CONCATENATE(" ", 'Employee'[Last Name]))

The following code example uses the RELATED function to retrieve columns from the Sales Territory
table. It concatenates the columns to create a calculated column in the Customer table.

=RELATED('Sales Territory'[Sales Territory Country]) & ", " & RELATED('Sales


Territory'[Sales Territory Region])

Creating Calculated Columns


You can create calculated columns in a tabular data model in the same way as you can in a workbook in
Excel. In the Data View window of a PowerPivot for Excel workbook, select the table that you want to add
the column to, and then click Add Column. You can then provide a name for the column and type the
DAX formula in the formula bar, which will determine the contents of the column. The PowerPivot engine
performs the calculation immediately to populate the column. By default, the engine recalculates columns
automatically if the source data changes.

Note The formula that you use to create a calculated column applies to every row in the
column. You cannot apply the formula to only selected ranges of data as you can in Excel
worksheets.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-17

When creating calculated columns, be aware of the following factors:

• Calculated columns calculate a value for every row in a table, so it can sometimes take a long time to
calculate these values when tables contain a large number of rows.
• By default, calculated columns update when the underlying data changes. This can cause
performance issues if the underlying data changes frequently, so you can change the PowerPivot
workbook to use Manual Calculation mode if required.

• Changing the names of columns that are referenced by a calculated column will cause an error in the
calculated column.

Using Calculated Columns


You can use the calculated columns that you create in PowerPivot for Excel workbooks by adding them to
the Row Labels, Column Labels, Legend Fields, and Axis Fields areas in the PowerPivot Field List.
11-18 Introduction to DAX

Measures

A measure is a named formula that can encapsulate complex business logic. You can add the measures
that you create to PivotTable tables and PivotChart charts in PowerPivot for Excel workbooks to perform
data analysis.

There are two kinds of measure that you can use in a tabular data model:

• Implicit measures. Implicit measures are created automatically in the model by aggregating columns
by using the SUM, COUNT, MIN, MAX, AVG, or DISTINCTCOUNT aggregations. The name of an
implicit measure derives from the column name, with a prefix such as “Sum of” or “Average of,”
depending on the aggregation that is used. For example, an implicit measure that is based on the
Sales Amount column might be called Sum of Sales Amount. Implicit measures appear in the
PowerPivot Field List with the other columns and measures in a table. You cannot use implicit
measures with Power View reports.
• Explicit measures. Explicit measures are the measures that you explicitly create in a tabular data
model. You can create explicit measures that use a range of DAX functions to aggregate data in
creative and sophisticated ways. You can use explicit measures as the basis of key performance
indicators (KPIs), and you can also use them in Power View reports.

Creating Measures
You can create explicit measures in two ways:
1. In a PowerPivot for Excel workbook, in the PowerPivot Field List, use the Add New Measure option.

2. In a tabular data model in SQL Server Analysis Services or PowerPivot for Excel, use the Measure
Grid.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-19

When you create a measure, you can specify the format that a measure should use when you display it in
a PivotTable table or PivotChart chart. Formatting options include numerical, percentage, and currency.
You also associate a new measure with a table; when users view the tables in the PowerPivot Field List,
they see the measures that they contain alongside the columns, and they can select them in the same way
as they select columns.

Using Measures
You can add measures to the Values, Legend Fields, and Axis Fields areas of the PowerPivot Field List.
You can also group data by adding measure values to the Row Labels and Column Labels areas. For
example, you can group the Sales Amount and Total Profit measures inside Calendar Year so that each
Calendar Year value contains a value for both measures.

The exact value that an individual cell displays for a measure depends on the context. Row context, query
context, and filter context can all have a bearing on this.
11-20 Introduction to DAX

Demonstration: Creating and Using Measures and Calculated Columns

 Task 1: Create a calculated column


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the
D:\10778A\Demofiles\Mod11 folder, run Setup.cmd as Administrator.

2. In the D:\10778A\Demofiles\Mod11 folder, double-click the Demo.xlsx file to open it in Excel.

3. In the Demo workbook, on the ribbon, on the PowerPivot tab, click PowerPivot Window. The
PowerPivot window may open behind the workbook, so minimize the workbook so you can see it.

4. In the PowerPivot window, click the Geography tab.

5. In the Geography table, scroll across to the last column, double-click Add Column, type Full
Location Name, and then press Enter.

6. In the formula bar above the Geography table, type the DAX formula in the following code example,
and then press Enter.

=CONCATENATE([State or Province Name], CONCATENATE(", ",[Region Name]))

7. Right-click the State or Province Name column header, and then click Hide from Client Tools.

 Task 2: Create a measure


1. In the PowerPivot window, in the upper-left corner, click the Switch to Workbook button.

2. Click the Add Measure Demo tab, and then click PivotTable1.
3. In the PowerPivot Field list, click Refresh if notified that PowerPivot data was modified.

4. In the PowerPivot Field list, right-click Reseller Sales, and then click Add New Measure.
5. In the Measure Settings dialog box, in the Measure Name (all PivotTables) field, type Total Profit.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-21

6. In the Formula field, type the DAX formula in the following code sample, and then click Check
Formula:

=SUM('Reseller Sales'[Sales Amount]) - SUM('Reseller Sales'[Total Product Cost])

7. In the Category field, click Currency, and then click OK.

 Task 3: Use measures in a PivotTable table and a PivotChart chart


1. When you create the Total Profit measure, it should automatically appear in the PivotTable1 table.
If it does not, in the PowerPivot Field list, expand Reseller Sales, and then select Total Profit.

2. In Reseller Sales, select Sales Amount.


3. Expand Product, drag Category to the Row Labels area, and then release it.

 Task 4: Use measures to create different groupings of data


1. Expand Date, drag Calendar Year to the Column Labels area, and then release it below Values. (This
groups the years inside each of the two measures.)
2. In the Column Labels area, click Calendar Year, and then click Move Up. (This groups the two
measures inside each of the years.)

3. In the Column Labels area, drag Values to the Row Labels area. (This nests the two measures inside
each category.)

4. Leave the Demo workbook open for the next Demonstration.


11-22 Introduction to DAX

Multiple Relationships

The new version of PowerPivot for Excel supports multiple relationships between tables. This is useful if,
for example, Date and Sales tables have multiple relationships to support different dates such as order
date, due date, and delivery date. Multiple relationships appear in the diagram view of the PowerPivot
window, with the active relationship shown as an unbroken line. The nonactive relationships appear as
dotted lines.

Only one relationship can be the active relationship and this relationship will automatically be used when
performing calculations that use data from the two tables. You can use the USERELATIONSHIP function
when you are writing DAX formulas to override this behavior and force PowerPivot to use the relationship
that you specify. For example, if the default relationship between your fact table and your date table is
based on the Order Date column, but you need to slice data by shipping date, you can write a DAX
measure that contains the USERELATIONSHIP function to achieve this.

Note USERELATIONSHIP does not create a relationship. The relationship must already
exist for you to use it.

For example, the following code example calculates the sum of the Sales Amount column based on
shipping date.

=CALCULATE(SUM(Reseller Sales[Sales Amount]), USERELATIONSHIP(‘Reseller


Sales’[ShipDateKey], ‘Date’[DateKey]))

Note You can only use the USERELATIONSHIP function with certain other functions, such
as CALCULATE, which can accept a filter as an argument.

For More Information For more information about the USERELATIONSHIP function, see
http://go.microsoft.com/fwlink/?LinkID=246793.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-23

Demonstration: Using a Specific Relationship in a Measure

 Task 1: Specify the relationship to use in a formula


1. In the Demo workbook, click the PowerPivot tab, and then on the PowerPivot ribbon, click
PowerPivot Window.
2. On the ribbon, in the View group, click the Diagram View button.

3. Use the mouse to point to each of the three lines between the Reseller Sales table and the Date
table, one at a time. The lines represent the relationships between the tables.
4. In the PowerPivot window, in the upper-left corner, click the Switch to Workbook button, click the
Multiple Relationships Demo tab, and then click anywhere in PivotTable1.

5. In the PowerPivot Field list, click Refresh if notified that PowerPivot data was modified.

6. In the PowerPivot Field list, expand Reseller Sales.

7. Right-click Sales With Ship Date, and then click Edit Formula.

8. In the Measure Settings dialog box, review the formula, and then click Cancel.

9. Drag Sales With Ship Date to the Values area in the PowerPivot Field List, and then release it.

10. In the PowerPivot Field List, expand Date, drag Calendar Year to the Row Labels area, and then
release it.
11. Close Demo.xlsx and do not save changes.
11-24 Introduction to DAX

Time Intelligence

Time intelligence functions enable you to compare data from one time period against equivalent data
from a different time period. For example, you might want to compare sales for the first quarter of this
year against sales for the first quarter of last year.

Requirements for Using Time Intelligence


To support time intelligence functionality, you should ensure that your data and tables meet the following
criteria:

• The model should contain a separate table that contains only date information.

• The date table should have a continuous range of dates without any gaps.
• The column in the date table that uses the date data type should use day as the lowest level of
granularity.

Unlike in the previous version of PowerPivot for Excel, the relationships between your fact table and your
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 that contain integer values. This is
useful because it is likely that the databases that you use as sources for PowerPivot analysis will contain
fact and date tables that are related by columns that use the 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 enable the PowerPivot engine 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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-25

Time Intelligence Functions


DAX includes an extensive set of functions to support time intelligence analysis, including DATEADD,
DATESBETWEEN, and DATESYTD. You can use these functions in measures to perform complex, date-
based comparisons. For example, the following code example calculates the sum of Sales Amount for the
previous year.

CALCULATE([Sum of Sales Amount], DATEADD(‘Date’[FullDateAlternateKey], -1, YEAR))

For More Information For more information about PowerPivot: DAX: Time Intelligence
Functions, see http://go.microsoft.com/fwlink/?LinkID=246794.
11-26 Introduction to DAX

Dynamic Measures

DAX includes functions that enable conditional logic, context examination, and other advanced ways of
manipulating data. You can use these functions to create dynamic measures. A dynamic measure is a
measure that responds flexibly to varying criteria; for example, a dynamic measure might use different
calculations for a given cell depending on which of a series of possible values are defined in the rows and
columns for that cell. Dynamic measures can be useful if, for example, you need to create a PivotTable
table that contains row labels or column labels that are not contained in any of the tables in the tabular
data model. For example, the following code example creates a measure that uses a different calculation
for each of three different input values. Each of the input values, Current Year, Previous Year, and YOY
Growth, is intended to be used as a row label in a PivotTable table.

IF([Check Single Values)], SWITCH(VALUES(‘Time Period’[Period]), “Current Year”, [Sum Of


Sales Amount], “Previous Year”, [Previous Year], “YOY Growth” , IF(NOT(ISBLANK([Previous
Year])), [Sum of Sales Amount] – [Previous Year], BLANK())), BLANK())

This code example references a linked table called Time Period, which contains the input values for the
dynamic measure. This table has a single column called Period. This column contains just three rows, with
the values Current Year, Previous Year, and YOY Growth. Using the SWITCH function forces the
PowerPivot engine to evaluate each row in the Period column and return a different value for each one:

• For the Current Year row, it returns the value that the Sum of Sales Amount measure calculates.

• For the Previous Year row, it returns the value that the Previous Year measure calculates.
• For the YOY Growth row, it returns the value that is calculated by subtracting Previous Year from
Sum of Sales Amount.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-27

The code example also references another measure called Check Single Values, which uses the
HASONEVALUE function to check that for each cell in the PivotTable, only one input value exists for each
row. This is necessary because the code example above can only evaluate single values.

Note The code example above references other measures to perform specific tasks. It is
best practice to create simpler measures that you can reuse in this way because it makes
writing measures easier and simplifies troubleshooting.
11-28 Introduction to DAX

Lab Scenario

As a senior business analyst at Adventure Works Cycles, you want to perform some detailed analysis of the
data in tabular data model. Specifically, you want to:

 View the full name of each employee and aggregate sales data based on the reporting hierarchy
of sales employees and managers

 View the sales contribution of each sales employee and manager as a percentage of the total
sales achieved

 View year on year sales growth as a percentage

 View sales values for the current year and previous year, and show the year on year growth as a
monetary value

To accomplish this, you will need to use DAX expressions to create calculated columns in the data model,
add custom measures that can be used as PivotTable fields, use time intelligence support in tabular data
models to apply temporal calculations to date fields, and create dynamic measures that calculate values
based on conditional logic.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-29

Lab 11: Creating Calculated Columns and Measures by


Using DAX

Exercise 1: Creating Calculated Columns


Scenario
Your users are now using PowerPivot and tabular databases to browse data. However, some users have
requested that you extend their tabular data models to enable them to explore sales by employee and
related manager. To do this, you will use DAX to create calculated columns and a new hierarchy.

The main tasks for this exercise are as follows:


1. Prepare the lab environment.

2. Create a calculated column by using concatenation.

3. Create calculated columns to support parent-child relationships.

4. Create a hierarchy that uses calculated columns.

5. Create a PivotTable table that contains the Employees hierarchy.

 Task 1: Prepare the lab environment


• Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.
• Run the Setup Windows® Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab11\Starter
folder as Administrator.
11-30 Introduction to DAX

 Task 2: Create a calculated column by using concatenation


• In the D:\10778A\Labfiles\Lab11\Starter folder, open the Sales Overview.xlsx file.

• Open the PowerPivot window, and in the Employee table, add a calculated column called Full Name
that uses the CONCATENATE function to concatenate the First Name and Last Name columns with a
space between them.
• You can find the complete formula for this calculated column in the Module_11_Formulas.txt file in
the D:\10778A\Labfiles\Lab11\Starter folder.

• The new column should look like this.

 Task 3: Create calculated columns to support parent-child relationships


• In the Employee table, add a new column named Path with the following DAX formula:

=PATH([EmployeeKey], [ParentEmployeeKey])

• You can find the complete formulas for the calculated columns in this task in the
Module_11_Formulas.txt file in the D:\10778A\Labfiles\Lab11\Starter folder.

• The Path calculated column should contain a set of employee keys for each row that defines the
employee’s position in the managerial hierarchy.

• In the Employee table, add a new column called Employee Level 1.

• In the formula bar above the Employee table, type the DAX formula in the following code sample,
and then press Enter.

=LOOKUPVALUE('Employee'[Full Name], 'Employee'[EmployeeKey], PATHITEM([Path], 1))


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-31

• The Employee Level 1 column should contain the full employee name that maps to the first
employee key for each row in the Path column.

• Repeat the steps above to create the following columns


• Employee Level 2: The full name that maps to the second employee key for each row in the
Path column.

• Employee Level 3: The full name that maps to the third employee key for each row in the Path
column.

• Employee Level 4: The full name that maps to the fourth employee key for each row in the Path
column.
The new columns should resemble this.

• Right-click each of the five calculated columns that you created in this task in turn, and click Hide
from Client Tools.
11-32 Introduction to DAX

 Task 4: Create a hierarchy that uses calculated columns


• View the diagram for the data model, and add a hierarchy named Employees to the Employee table.
The hierarchy should include the Employee Level 1, Employee Level 2, Employee Level 3, and
Employee Level 4 columns as shown in the following image.

The hierarchy will display employees in order of seniority, with the most senior employees from the
Employee Level 1 column at the top.

 Task 5: Create a PivotTable table that contains the Employees hierarchy


• Switch to the Excel workbook and rename Sheet 2 to Employee Sales.
• Add a PivotTable table to cell B1 in the Employee Sales worksheet.

• Use the PivotTable to view the Sales Amount value from the Reseller Sales table by the Employees
hierarchy from the Employee table, as shown here.

• Right-click the PivotTable and click Show/Hide Fields to hide the Employee Level 1 and Employee
Level 2 fields so that you can focus on the department heads and their subordinates.

Results: After this exercise, you should have a data model with a hierarchy based on DAX expressions.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-33

Exercise 2: Creating Measures


Scenario
Some users have requested that you extend their tabular data models to enable them to view the
percentage that each employee contributes to overall sales. To do this, you will use DAX to create the
required measures.

The main tasks for this exercise are as follows:


1. Create a measure that calculates total sales for all employees.

2. Create a measure that calculates percentage of sales per employee.

3. Add conditional formatting to the PivotTable table.

 Task 1: Create a measure that calculates total sales for all employees
• In the Employee Sales worksheet you used in the previous exercise, add a new measure to the
Reseller Sales table in the PowerPivot Fields List pane. The new measure should be named Total
Sales for All Employees and should be based on the following formula and formatted as currency.

=CALCULATE([Sum of Sales Amount], ALL('Employee'))

• You can find the complete formula for this measure in the Module_11_Formulas.txt file in the
D:\10778A\Labfiles\Lab11\Starter folder.
The measure settings for the new measure should look like this.

• The CALCULATE function calculates the Sum of Sales Amount measure, and the ALL function
overrides the context of the Employee table, so that the measure delivers a single total regardless of
context. Remove this field from the PivotTable—you will reference it in another measure.
11-34 Introduction to DAX

 Task 2: Create a measure that calculates percentage of sales per employee


• In the Reseller Sales table, create another new measure named Percentage of Sales based on the
following DAX formula and formatted as a percentage.

=[Sum of Sales Amount]/[Total Sales for All Employees]

• You can find the complete formula for this measure in the Module_11_Formulas.txt file in the
D:\10778A\Labfiles\Lab11\Starter folder.

The measure settings for the new measure should look like this.

• The formula uses the Sum of Sales Amount and Total Sales for All Employees measures to
calculate the percentage of sales that each employee contributed, as shown here.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-35

 Task 3: Add conditional formatting to the PivotTable table


• In the Employees Sales worksheet, in the PivotTable table, expand all employees.

• Select all of the rows in the Percentage of Sales column, but do not include the column header or
the Grand Total row value.
• Click the Home tab. Add conditional formatting to the Percentage of Sales column. Use the Blue
Data Bar formatting option as shown here.

• Save the Sales Overview.xlsx workbook when you have finished, and keep it open for the next
exercise.

Results: After this exercise, you should have created two measures.
11-36 Introduction to DAX

Exercise 3: Using Time Intelligence


Scenario
Some users have requested that you extend their tabular data models to enable them to view sales by
comparing them with the previous year. To do this, you will use a DAX time intelligence function to create
the required measures.

The main tasks for this exercise are as follows:


1. Create a measure that uses a time intelligence function.

2. Create a measure that uses conditional logic.

 Task 1: Create a measure that uses a time intelligence function


• In the Sales Overview.xlsx workbook, switch to the PowerPivot window, and if necessary, switch to
Data View.

• View the Date table, and in the ribbon, on the Design tab, mark the Date table as Date Table, using
the FullDateAlternateKey column as the unique identifier. This enables PowerPivot to apply
temporal calculations to data in this table.

• Switch back to the workbook and insert a PowerPivot PivotTable in a new worksheet, and then
rename the worksheet Year on Year Growth.

• Add Calendar Year from the Date table to the Row Labels area and Sales Amount from the
Reseller Sales table to the Values area so that the PivotTable resembles the following image.

• Add a new measure to the Reseller Sales table. The new measure should be named Previous Year
and should be based on the following formula and formatted as currency.

=CALCULATE([Sum of Sales Amount], DATEADD('Date'[FullDateAlternateKey], -1, YEAR))

• You can find the complete formula for this measure in the Module_11_Formulas.txt file in the
D:\10778A\Labfiles\Lab11\Starter folder.

• The Previous Year measure uses the CALCULATE function with the Sum of Sales Amount measure,
and the DATEADD function with the ‘Date’[FullDateAlternateKey] column to calculate sales amount
for one year earlier than the current year. Remove this field from the PivotTable—you will reference it
in another measure.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-37

 Task 2: Create a measure that uses conditional logic


• In the Reseller Sales table, create another new measure named Year on Year Growth based on the
following DAX formula and formatted as a percentage.

=IF([Previous Year], ([Sum of Sales Amount] – [Previous Year])/[Previous Year],


BLANK())

• You can find the complete formula for this measure in the Module_11_Formulas.txt file in the
D:\10778A\Labfiles\Lab11\Starter folder.

The Year on Year Growth formula uses the IF function to calculate year-on-year growth. The
Previous Year measure tests whether a previous year value exists, and calculates year-on-year
growth by using the Sum of Sales Amount and Previous Year measures. The measure returns a
BLANK value if there is no previous year value (which will always be the case for the first year in the
list), as shown here.

• Save the Sales Overview.xlsx workbook when you have finished, and keep it open for the next
exercise.

Results: After this exercise, you should have created a measure that uses a time intelligence function to
calculate sales for the previous period, and a measure that uses conditional logic to calculate the growth
in sales from the previous period to the current period.
11-38 Introduction to DAX

Exercise 4: Creating a Dynamic Measure


Scenario
Some users have requested that you extend their tabular data models to enable them to view a PivotTable
table that displays appropriate values for each of these rows: Current Year, Previous Year, and YOY
Growth. To do this, you will use DAX to create a dynamic measure.

The main tasks for this exercise are as follows:


1. Create a linked table.

2. Create a measure that checks whether inputs have a single value.

3. Create a measure that dynamically calculates values.

 Task 1: Create a linked table


• In the Sales Overview.xlsx workbook, click the Time Period worksheet tab.

• Select cells A1 to A4, and on the PowerPivot tab, click Create Linked Table. Select the My table
has headers option.

• In the PowerPivot window, rename the new table Time Period as shown here.

 Task 2: Create a measure that checks whether inputs have a single value
• Switch back to the workbook and insert a PowerPivot PivotTable in a new worksheet, and then
rename the worksheet Dynamic Time.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-39

• Add the Period column from the Time Period table to the Row Labels area and Calendar Year
from the Date table to the Column Labels area so that the PivotTable resembles the following
image.

• In the Reseller Sales table, create another new measure named Check Single Values based on the
following DAX formula as a TRUE/FALSE value.

=IF(HASONEVALUE('Time Period'[Period]) && HASONEVALUE('Date'[Calendar Year]), TRUE(),


FALSE())

• You can find the complete formula for this measure in the Module_11_Formulas.txt file in the
D:\10778A\Labfiles\Lab11\Starter folder.

• The Check Single Values measure uses the HASONEVALUE function to evaluate whether the ‘Time
Period’[Period] and ‘Date’[Calendar Year] inputs each contain one value for a given cell in the
PivotTable table. The IF function returns TRUE if they both return single values and FALSE if they do
not. Remove this field from the PivotTable—you will reference it in another measure

 Task 3: Create a measure that dynamically calculates values


• In the Reseller Sales table, create another new measure named Sales Over Time based on the
following DAX formula and formatted as currency.

=IF([Check Single Values], SWITCH(VALUES('Time Period'[Period]), "Current Year", [Sum


of Sales Amount], "Previous Year", [Previous Year], "YOY Growth",
IF(NOT(ISBLANK([Previous Year])), [Sum of Sales Amount] - [Previous Year], BLANK())),
BLANK())

• You can find the complete formula for this measure in the Module_11_Formulas.txt file in the
D:\10778A\Labfiles\Lab11\Starter folder.
The Sales Over Time measure uses the SWITCH function to provide different calculations for each of
the values in the Period column (Current Year, Previous Year, and YOY Growth):

• For the Current Year value, it uses the Sum of Sales Amount measure.
• For the Previous Year value, it uses the Previous Year measure.

• For the YOY Growth value, it subtracts the Previous Year measure from the Sum of Sales
Amount measure and uses the ISBLANK function to check for an empty Previous Year measure.
11-40 Introduction to DAX

The completed PivotTable should look like this.

• Save the Sales Overview.xlsx workbook and close Excel.

Results: After this exercise, you should have created a dynamic measure
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 11-41

Module Review and Takeaways

Review Questions
1. Do you or your colleagues use Excel formulas? What limitations have you encountered? What
features of DAX might help you to overcome these limitations?

2. Do you have any table relationships for which the ability of DAX to support multiple relationships
might be useful?

3. Will time intelligence functionality be useful to you? What kinds of analyses might you want to
perform?
11-42 Introduction to DAX
12-1

Module 12
Implementing an Analysis Services Tabular Data Model
Contents:
Lesson 1: Introduction to Analysis Services Tabular Data Model Projects 12-3

Lesson 2: Developing an Analysis Services Tabular Data Model in SQL Server


Data Tools 12-13

Lab 12: Working with an Analysis Services Tabular Data Model 12-27
12-2 Implementing an Analysis Services Tabular Data Model

Module Overview

With Microsoft® SQL Server® 2012, you can install 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 Analysis Services tabular data models and explains how to develop a tabular data
model by using the SQL Server Data Tools. After completing this module, you will be able to:

• Describe Analysis Services tabular data model Projects.

• Implement an Analysis Services tabular data model by Using SQL Server Data Tools.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-3

Lesson 1
Introduction to Analysis Services Tabular Data Model
Projects

This lesson describes Analysis Services tabular data models and explains how you can use SQL Server Data
Tools to create a tabular data model.

After completing this lesson, you will be able to:

• Describe Analysis Services tabular data models.

• Describe the options for creating an Analysis Services tabular data model.
• Describe the benefits of using SQL Server Data Tools to Develop an Analysis Services tabular data
model.
• Describe the purpose of the Workspace Database.
12-4 Implementing an Analysis Services Tabular Data Model

What Is an Analysis Services Tabular Data Model?

An Analysis Services tabular data model is a database that is stored on an Analysis Services instance
running in Tabular mode. When you install a SQL Server 2012 Analysis Services instance, you can choose
to install it in Multidimensional mode, PowerPivot for Microsoft SharePoint® mode, or Tabular mode. If
you want to create tabular databases, you must install at least one Analysis Services instance that runs in
Tabular mode.

Note You can switch the mode of an Analysis Services instance after installation, but only
if you have not yet created a database on that instance.

For more information on how to Determine the Server Mode of an Analysis Services
Instance, see http://go.microsoft.com/fwlink/?LinkID=246795.

By default, a tabular data model database uses the xVelocity in-memory engine. xVelocity provides highly
compressed, in-memory, column-based storage that is able to perform very fast calculations even when
working with millions of rows. You can optionally configure a Tabular database to use DirectQuery mode,
which passes queries directly through to the underlying data source instead of using the in-memory
storage engine. DirectQuery is one of several key features that are only available in Analysis Services
tabular data models are not in PowerPivot for Excel workbooks. The other key features of Analysis Services
tabular data models are:

• Row-level security, which enables you to implement security at a much more granular level.
• Partitions, which enable you to manage large tables more efficiently.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-5

Tabular data models are generally easy to create because their relational 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 get applications into production more quickly, and making it possible for companies to take
advantage of a wider pool of talent to develop Analysis Services solutions because relational models are
generally more widely understood than their multidimensional equivalents. In-house relational database
developers should be able to quickly adapt to creating tabular data models with minimal training, for
example.

You can create tabular data models by using SQL Server Data Tools, a comprehensive business
intelligence development environment that is an extension of Visual Studio 2010. You can use SQL Server
Management Studio to manage tabular data model databases after you deploy them.
12-6 Implementing an Analysis Services Tabular Data Model

Options for Creating an Analysis Services Tabular Data Model Project

You can create a tabular data model project by using the templates that are provided in SQL Server Data
Tools. 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 workbook that you specify and uses this to populate the
new model.
• Import from Server (Tabular). This template creates a new tabular data model from an existing
Analysis Services tabular data model. It extracts the data and metadata from the database that you
specify and uses this to populate the new model.

Before you create a tabular data model project, you must ensure that there is an instance of Analysis
Services running in tabular mode that is available for the project to use. The Analysis Services instance that
you use 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 when offline. However, a
network instance offers the advantage of easier collaboration if several developers are involved in the
development effort, particularly if the project is integrated with Team Foundation Server (TFS).

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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-7

Using SQL Server Data Tools to Develop an Analysis Services Tabular Data
Model

SQL Server Data Tools is a comprehensive development environment for all of your BI projects, including
SQL Server Reporting Services projects, SQL Server Analysis Services Multidimensional projects and SQL
Server Analysis Services Tabular projects. It supports source control if used with Team Foundation Server
or other third-party source control plug-ins, debugging tools, build and deployment options, and a range
of other features that together enable you to manage the full project development life cycle.
When you create a tabular data model by using SQL Server Data Tools, the Tabular Model Designer opens
automatically. The Tabular Model Designer is the development environment for tabular data model
projects, and it looks and feels very similar to the PowerPivot Window in a PowerPivot for Excel
workbook. The designer consists of several windows, including:
• Solution Explorer. This window displays the project and its contents. By default, the contents are the
References container 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.

• Designer Window. This window displays a visual representation of the model. It offers two different
views of the model:
• 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 on 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.

• 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.
12-8 Implementing an Analysis Services Tabular Data Model

• Error List. This window displays errors and other messages that relate to the model.

• Output Window. This window displays status information relating to builds and deployments.

In addition to these windows, the Tabular Model Designer also contains extra menu items on the toolbar,
including the Model, Table, and Column items. From the Model menu, you can launch the Data Import
Wizard, which imports data and metadata into your model and creates all of the metadata structures that
underpin a tabular data model.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-9

The Workspace Database

Creating a tabular data model project by using one of the templates in SQL Server Data Tools
automatically adds a new database to the Analysis Services Tabular instance that is configured as the
workspace server. Every tabular data model project has its own workspace database that is used
exclusively by that project. Workspace databases use a naming convention that combines the project
name, the name of the user who created the project, and a system generated globally unique identifier
(GUID) in the following format:

<project name>_<user name>_<GUID>

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 in the development phase. 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 on the designated Analysis Services instance; this
database is a renamed copy of the workspace database.

Local and Remote Workspace Databases


The workspace database should ideally be located on the same computer where the developer creates the
model because this is likely to result in the best performance. You can use a remote Analysis Services
instance to host the workspace database, but this configuration has the following limitations:

• You cannot create tabular data model projects by using the Import from PowerPivot template.

• You cannot use the Backup to disk option in the Data Backup property.

• You may experience slower performance because of the latency that using a remote server can
introduce.
12-10 Implementing an Analysis Services Tabular Data Model

Configuring the Workspace Database


You can use the Properties window of the Model.bim file in SQL Server Data Tools to configure the
workspace database. You can set the Workspace Server value to change the Analysis Services instance
that hosts the workspace database.

Note The default host for new workspace databases is defined in the Default workspace
server setting on the Data Modeling page in the Analysis Services settings in the
Options dialog box, which you can access from the Tools menu on the menu bar.

The Workspace Retention settings define 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 open the project again. 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 the workspace database from disk and memory completely. If you choose this
last option, the workspace database is recreated every time you open the project.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-11

Demonstration: Creating a Tabular Data Model Project

 Task 1: Create a tabular data model project


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the
D:\10778A\Demofiles\Mod12 folder, run Setup.cmd as Administrator.
2. Click Start, click All Programs, click Microsoft SQL Server 2012, and then click SQL Server SQL
Server Data Tools.

3. On the Start Page tab, click New Project.

4. In the New Project dialog box, in the Installed Templates pane, expand Business Intelligence, click
Analysis Services, and then click Import from PowerPivot.

5. In the Name box, type Sales, and then click Browse.


6. Click Browse, navigate to the D:\10778A\Demofiles\Mod12 folder, and then click Select Folder.

7. In the New Project dialog box, click OK. If the Workspace and Deployment Server Configuration
dialog box is displayed, in the Default Server list, select localhost\SQL2, and then click OK (this
dialog box is only displayed the first time you create a tabular model project).

8. In the Open dialog box, navigate to the D:\10778A\Demofiles\Mod12 folder, click Sales, and then
click Open. If a message notifies you that data cannot be imported, click yes to import the metadata.
9. Wait until the creation of the Sales project completes. Note that the data model in the project
includes a tab for each table in the model.

10. On the Tools menu, click Options, and in the Options dialog box, expand Analysis Services and
click Data Modeling. Note the name of the default workspace server used to host the data model
during development. Then click Cancel.
 
12-12 Implementing an Analysis Services Tabular Data Model

 Task 2: Configure a connection in a tabular data model project


1. On the Model menu, click Existing Connections, and then in the Existing Connections dialog box,
with the SqlServer MIA-SQLBI AdventureWorksDW connection selected, click Edit.

2. In the Edit Connection dialog box, click Impersonation. Then select Specific Windows user name
and password, enter ADVENTUREWORKS\ServiceAcct and Pa$$w0rd, and click OK.

3. In the Edit Connection dialog box, click Save. Then in the Existing Connections dialog box, with the
SqlServer MIA-SQLBI AdventureWorksDW connection selected, click Process to import the data.

4. When processing is complete, in the Data Processing dialog box click Close, and then in the
Existing Connections dialog box, Close. The model is now populated with data.

 Task 3: Edit a model in SQL Server Data Tools


1. In the Designer Window, click the Reseller Sales tab.

2. In the Measure Grid, click any empty cell, in the formula bar, type the expression in the code box
below, and then press Enter.

Profit:=SUM('Reseller Sales'[SalesAmount]) - SUM('Reseller Sales'[TotalProductCost])

3. Note that the profit measure is calculated, and then on the File menu, click Save All.

4. Minimize SQL Server Data Tools. You will return to the project in a later demonstration.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-13

Lesson 2
Developing an Analysis Services Tabular Data Model in
SQL Server Data Tools

The extensions to SQL Server Data Tools in SQL Server 2012 provide a comprehensive set of features and
functionality that make it easy for developers to create, deploy and update Analysis Services tabular data
models. You can use SQL Server Data Tools to perform all of the tasks that you perform when you create a
tabular data model by using PowerPivot for Excel, and also to add features such as partitions and row-
level security that are only available in Analysis Services projects.

This lesson describes how to develop an Analysis Services tabular data model by using SQL Server Data
Tools. It also describes the advanced features that extend the functionality of Analysis Services tabular
data models beyond the models that you create by using PowerPivot for Excel.

After completing this lesson, you will be able to:

• Create perspectives in a tabular data model.

• Create partitions in a tabular data model.


• Implement DirectQuery mode in a tabular data model.

• Implement Security in a tabular data model.

• Deploy a tabular data model.


12-14 Implementing an Analysis Services Tabular Data Model

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 experience for the end user
by creating perspectives that display only a subset of the tables, columns, and measures in a model. For
example, the tables that you import data into a tabular data model from a database might contain many
different types of data, such as human resources data, sales data, product data, promotions data, 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 that explicitly excludes these tables.
When users connect to the model by using this perspective, they will not see the excluded tables in their
client application.

Creating Perspectives
You can create a perspective in an Analysis Services tabular data model by using the Perspectives dialog
box in SQL Server Data Tools. You can open this dialog box by clicking the Model menu, and then
clicking Perspectives. You can also create perspectives in PowerPivot for Excel workbooks.

Note To create a perspective in a PowerPivot for Excel workbook, you must open the
PowerPivot Window, switch to Advanced Mode, and then click the Advanced tab.
When you create a perspective, you must provide a name for the perspective and specify the tables,
measures, and columns to include in the perspective. When users connect to the model, they will be able
to select the perspective that they want to use, so you should ensure that the names that you give to
perspectives are descriptive and easy to understand. You can also create a perspective by copying an
existing perspective, which can speed up the process when you need to create a new perspective that is
very similar to an existing one.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-15

Perspectives and Security


You cannot use perspectives to secure tabular data models. You cannot define permissions on a
perspective, so any user who has the right to view the tabular data model will be able to use any
perspective that is defined in the model. Additionally, if a user does not have permissions to view certain
tables, they cannot circumvent this by accessing the tables by using a perspective. If you need to secure
your tabular data models, you should create roles and define permissions for the required objects.

For More Information on security in tabular data models, see the Tabular Data Model
Security topic in this module.
12-16 Implementing an Analysis Services Tabular Data Model

Partitions

Partitions provide a way for you to manage large tables more efficiently. Partitions enable you to logically
divide a table up into units so that you can load or reload data into units individually. For example,
imagine that you have a large table called Sales in your tabular data model, which contains sales data.
The source table for Sales is a fact table in a data warehouse that is updated daily and as a result, the data
in Sales quickly goes out of date. You can refresh the data in Sales, but this is time consuming because
this operation reloads all of the rows from the source table. To help keep Sales synchronized with the
source table, you could create partitions that divide the table up, perhaps by using the by year or month
value in the column that contains the order date as the key. You now only need to regularly refresh the
partition that contains the most recent data, refreshing the other partitions only if 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.

Creating Partitions
Every table that you import into a tabular data model has a single partition associated with it by default,
which enables you to refresh each table separately from the other tables. You can create a new partition
in a table in a tabular data model during the development stage by using the following steps:

1. In the Tabular Model Designer in SQL Server Data Tools, click the Table menu, and then click
Partitions.

2. In Partition Manager, select the table for which you want to create a partition, and then click New.

Note You can also create a partition by copying an existing partition.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-17

3. Use the Table Preview pane to select the rows to include in the partition, or use the Query Editor
pane to select the rows to include in the partition by defining 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 you have deployed to an Analysis Services instance, you can create and
manage partitions by using SQL Server Management Studio.

Using Partitions in the Data Modeling Phase


When you are creating a tabular data model that uses a source database that contains large tables, you
should consider implementing partitions to enable you to work with a reduced sample data set. Using a
sample data set during development is more efficient because it reduces data load times and enables
better query performance. You can create, delete, edit, and merge partitions in the workspace database as
required. When you deploy the model, you can import all of the data and employ a different partitioning
design that is appropriate to the deployed database.

Processing Partitions
Processing populates the tables and partitions in a tabular data model by importing data from the source
database. You can choose to process individual tables or partitions, or all of the tables and partitions in a
model together. Depending on the processing option that you choose, processing also rebuilds
relationships and hierarchies and recalculates calculated columns and measures. The following processing
options are available:
• Process Default. This option detects the current state of a partition and performs the necessary
actions to ensure that the partition is in a fully-processed state. When you first create a partition, this
option loads the partition and creates all hierarchies, relationships, measures, and calculated columns.
• Process Full. This option fully processes a partition; it removes existing data and repopulates
partitions, and then recreates hierarchies, relationships, measures, and calculated columns.

• Process Data. This option only processes data, and does not recreate hierarchies, relationships,
measures, and calculated columns.
• Process Clear. This option deletes data from a partition.

• Process Add. This option updates partitions by only adding new data.

You can process partitions in SQL Server Data Tools by clicking the Refresh Partitions button on the
toolbar, and then clicking Refresh Partitions.

You can process partitions in SQL Server Management Studio by using the Process Partitions dialog box,
which you can access by right-clicking the table that you need to update, clicking Partitions, and then
clicking Process.
12-18 Implementing an Analysis Services Tabular Data Model

DirectQuery Mode

The xVelocity engine provides in-memory storage and processing of data for very fast query processing,
and it is appropriate for most Analysis Services tabular data models. 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 have very large data sets that take a long time to load into memory, and
which might fail to load if there is insufficient memory available. Using DirectQuery is suitable in this
situation because it removes the need to load data into memory.
• For tabular data models that need to contain up-to-date information and for which frequent
processing is impractical. DirectQuery is suitable in this situation because it accesses 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 the performance that
their hardware delivers and while still providing access to data through a tabular data model. In this
situation, you should perform thorough testing to determine whether you can achieve the best
performance by relying on the data warehouse hardware or by using the xVelocity engine.

Designing Tabular Data Models for Use with DirectQuery


When you design tabular data models for which you intend to enable DirectQuery mode, there are
several points you should consider:

• DirectQuery only supports a single data source, and this data source must be a SQL Server relational
database.

• You cannot use linked tables or nonlinked tables in the model.

• You cannot use calculated columns in the model.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-19

• You cannot use certain DAX functions, such as time intelligence functions, in the model. Additionally,
some functions, such as certain statistical functions, might behave differently in DirectQuery mode.

• You cannot use row-level security in the model.


• Only client applications that support DAX queries can connect to the model. Client applications that
use MDX to query the model will not be able to connect to it.

Enabling DirectQuery Mode


You can enable DirectQuery for a database in SQL Server Management Studio by configuring the
DirectQueryMode setting in the properties of the database. You can enable DirectQuery in SQL Server
Data Tools by configuring the DirectQueryMode setting in the properties of the Model.bim file.
12-20 Implementing an Analysis Services Tabular Data Model

Tabular Data Model Security

You can configure security in a tabular data model by creating database roles and then applying
permissions and filters to them. You should use roles to gather together Windows® user accounts and
groups that have the same data access requirements, and then apply the permissions to the role. You can
create and manage roles in a tabular data model in the development phase by using the Role Manager
dialog box in SQL Server Data Tools, which you can access by clicking Model on the taskbar and then
clicking Roles. You can add members to roles in a tabular data model that you have deployed by using
SQL Server Management Studio, but you cannot create roles by using this tool.

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:
• Read. This permission gives role members read access to the database.

• Read and Refresh. This permission gives role members read access to the database and also allows
them to refresh data.

• Refresh. This permission gives role members the ability to refresh data in the database.

• Administrator. This permission gives role members administrative rights for the database.

• None. This permission prevents role members from accessing the database.

Row-Level Security
You can create DAX expressions that filter the rows that members of a role 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.

Region[Country]="France"
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-21

The rows that contain the value France evaluate to TRUE, so they are visible to the members of the role.
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 Refresh database permissions.
Roles that have the None or Refresh permissions cannot view any data, therefore 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.
12-22 Implementing an Analysis Services Tabular Data Model

Deploying a Tabular Data Model

When you have completed the development phase for a tabular data model, you can deploy it to an
Analysis Services instance running in Tabular mode to enable information workers and data analysts to
connect to it by using client tools such as Excel and Power View. Deploying a tabular data model, copies
the data and metadata in the workspace database and uses it to create a new database. The new database
will have the name of the project by default. You can deploy to the same server that you used to develop
the model, but more often you will deploy to a different Analysis Services instance, such as a test or
production server.

You can control the deployment process by using the Deployment Options and Deployment Server
settings in the properties of the project in SQL Server Data Tools.

Deployment Options
• Processing Option. Use this setting to define how the new database is processed. There are three
options:

• Default. When you select this option, Analysis Services detects the state of the database and
processes the data and metadata accordingly.

• Full. When you select this option, Analysis Services processes all data and metadata.

• Do Not Process. When you select this option, Analysis Services deploys only the metadata.

• Transactional Deployment. By default, 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.

• Query Mode. Use this option to select DirectQuery mode or InMemory mode for data storage.

• Impersonation Settings. Use this option to specify the credentials to use when connecting to the
data sources for the tabular data model.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-23

Deployment Server
• Server. Use this option to specify the name of the deployment server.

• Edition. Use this option to specify the edition of the Analysis Services instance on the deployment
server.
• Database. Use this option to specify the name of the database on the deployment server.

• Cube Name. Use this option to specify the name that client tools see when they connect to the
model.

Client Connections
Clients can connect to a tabular data model in Analysis Services directly by using tools such as Excel, but
you can make it easier for clients to connect by creating a BI Semantic Model Connection in the
PowerPivot Gallery. A BI Semantic Model Connection enables users to connect to a tabular database in
Analysis Services or a PowerPivot workbook by using Excel or Power View with just a click. There is no
need for users to create connections manually.

Note Before you can create a BI Semantic Model Connection in a SharePoint document
library, the document library must be configured to support the BI Semantic Model
Connection content type. You can enable content types in the Library Settings page for
any document library where you want users to be able to publish connections to tabular
data models.
12-24 Implementing an Analysis Services Tabular Data Model

Demonstration: Deploying a Tabular Data Model

 Task 1: Deploy a Tabular Data Model project


1. Ensure that you have completed the previous demonstration in this module, and maximize SQL
Server Data Tools with the Sales project open.

2. On the Build menu, click Deploy Sales. If prompted, enter the user name
ADVENTUREWORKS\ServiceAcct and the password Pa$$w0rd and click OK.

3. In the Deploy dialog box, when deployment is complete, click Close. Then close SQL Server Data
Tools.

 Task 2: Add the BI Semantic Model Connection content type


1. Start Internet Explorer and browse to the SharePoint site at http://mia-sqlbi. Then on the Home
page, under Library, click PowerPivot Gallery.
2. On the SharePoint ribbon, in the Library Tools section, click Library.

3. In the Settings area, click Library Settings.

4. Under the General Settings area, if a Content Types section exists, review the content types enabled
for this document library. If no Content Types section exists or the BI Semantic Model Connection
is not listed, perform the following steps to enable management of content types and add it.

a. In General Settings, click Advanced settings.


b. In Content Types, in the Allow management of content types? section, click Yes, and then
click OK.

c. On the Document Library Settings page, in the Content Types section, click Add from
existing site content types.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-25

d. In the Select site content types from: list, click Business Intelligence.

e. In the Available Site Content Types list, click BI Semantic Model Connection, click Add, and
then click OK.

 Task 3: Create a BI Semantic Model Connection


1. On the Document Library Settings page, under Libraries, click PowerPivot Gallery.

2. On the SharePoint ribbon, in the Library Tools section, click Documents. Then in the New
Document drop-down list, click BI Semantic Model Connection.
3. In the New BI Semantic Model Connection page, in the File Name box, type Sales; in the
Description box, type Sales data model; in the Workbook URL or Server Name box, type
localhost\SQL2; in the Database (if connecting to a server) box, type Sales; and click OK. After a
few moments, the Sales connection is shown in the PowerPivot Gallery document library.

4. On PowerPivot Gallery page, click the Open New Excel Workbook icon for the Sales BI semantic
model connection.
5. When prompted, click Open. Then, when the download has completed, click Open again.

6. In Excel, in the Microsoft Excel Security Notice dialog box, click Enable.

7. In the PivotTable Field List pane, select Profit. Then in the Date table, select Calendar Year. Note
that the PivotTable shows profit by year.

8. Close Excel without saving any changes. Then close Internet Explorer.
12-26 Implementing an Analysis Services Tabular Data Model

Lab Scenario

Some business analysts have been creating PowerPivot workbooks, and you have determined that one of
these workbooks is being used extensively by multiple users. You have therefore decided to bring this
workbook under centralized control and manage it as a SQL Server Analysis tabular database.

You will initially create the tabular model database from the PowerPivot workbook, and then you will
enhance it with enterprise-features such as:
• Perspectives to simplify the model for users who require only a subset of the tables.

• Partitions to reduce the time taken to process tables.

• A BI Semantic Model Connection in SharePoint so that users can easily create Excel workbooks
containing PivotTables based on the tabular data model.

• DirectQuery storage to optimize query performance as the volume of data grows.

• Roles and permissions to restrict the data that users can view.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-27

Lab 12: Working with an Analysis Services Tabular Data


Model

Exercise 1: Creating an Analysis Services Tabular Data Model Project from a


PowerPivot Workbook
Scenario
You have identified a heavily used PowerPivot for Excel workbook that you want to manage as a tabular
data model in Analysis Services.

The main tasks for this exercise are as follows:

1. Prepare the lab environment.


2. Review the Reseller Sales Analysis PowerPivot workbook.

3. Create a tabular data model project by using SQL Server Data Tools.

4. Set the impersonation account for the data connection.


5. Explore the workspace database.

 Task 1: Prepare the lab environment


• Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.
• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab12\Starter
folder as Administrator.
12-28 Implementing an Analysis Services Tabular Data Model

 Task 2: Review the Reseller Sales Analysis PowerPivot workbook


• In the D:\10778A\Labfiles\Lab12\Starter folder, open the Reseller Sales Analysis.xlsx Excel
workbook.

• You will use the PowerPivot data model in this workbook to create an Analysis Services tabular data
model. Review the PowerPivot data model in the workbook and note that it contains no linked tables
(which would be incompatible with DirectQuery mode if this option was required later).

• When you have reviewed the workbook, close it without saving any changes.

 Task 3: Create a tabular data model project by using SQL Server Data Tools
• Start SQL Server Data Tools and use the Import from PowerPivot project template to create a
project named Reseller Sales in the D:\10778A\Labfiles\Lab12\Starter folder.

• If prompted, confirm that the workspace and deployment server is localhost\SQL2.


• Import the metadata from the Reseller Sales Analysis workbook in the
D:\10778A\Labfiles\Lab12\Starter folder. The current impersonation settings in the workbook will not
allow you to import the data.

 Task 4: Set the impersonation account for the data connection


• In the model that has been created, edit the existing SqlServer MIA-SQLBI AdventureWorksDW
data connection and configure the impersonation settings to use the
ADVENTUREWORKS\ServiceAcct Windows user name with the password Pa$$w0rd.
• Process the connection to import the data from the data source. After you have processed the
connection, model should resemble the following image.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-29

 Task 5: Explore the workspace database


• Use SQL Server Management Studio to explore the workspace database for the project that you
created in Task 3. This should be in the localhost\SQL2 instance of Analysis Services and should have
a name that begins Reseller Sales_Student as shown here.

Results: After this exercise, you should have created a tabular data model project.
12-30 Implementing an Analysis Services Tabular Data Model

Exercise 2: Implementing a Perspective


Scenario
Users will need to be able to use the Reseller Sales tabular data model to view a number of measures,
including the sum of sales and product cost. Some users will need to aggregate the measures by all
dimensions, but others will not need to aggregate the data by employee-related dimensions or view
employee-related measures. To reduce the complexity of the model for these users, you plan to create a
perspective that does not include employee-related tables.

The main tasks for this exercise are as follows:


1. Create measure calculations.

2. Create a perspective.

3. Test a perspective.

 Task 1: Create measure calculations


• In the Reseller Sales project, in the Reseller Sales table, create measure calculations that sum the
SalesAmount and TotalProductCost columns.

• The easiest way to do this is to use the AutoSum feature. Click the column header of each column for
which you want to create a calculated measure, and then on the Column menu, point to AutoSum,
and click Sum.

• After you have added the calculated measures, process all of the tables in the model. The model
should resemble the following image:
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-31

 Task 2: Create a perspective


• Add a new perspective named No Employee Data to the model.

• In the No Employee Data perspective, include all of the tables other than Employee and Sales
Quota. The perspective should resemble the following image.

 Task 3: Test a perspective


• Use the Analyze in Excel feature in the model designer to view the (Default) perspective in Microsoft
Excel as the current Windows user; and in the Excel PivotTable, view the sum of SalesAmount by
employee email address as shown in the following image.
12-32 Implementing an Analysis Services Tabular Data Model

• Close the Excel workbook, and then use the Analyze in Excel feature in the model designer to view
the No Employee Data perspective in Microsoft Excel as the current Windows user; and in the Excel
PivotTable, note that the Employee and Sales Quota tables are not available in this perspective.
Instead view the sum of SalesAmount by product category as shown in the following image.

Results: After this exercise, you should have created a perspective that does not include employee data.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-33

Exercise 3: Implementing Partitions


Scenario
The data in the Reseller Sales table changes often, so you need to update the Reseller Sales tabular data
model frequently to ensure that it remains up-to-date. To avoid reprocessing all of the data in the
Reseller Sales table every time you update, you intend to create partitions.

The main tasks for this exercise are as follows:


1. Create partitions.

2. View the partitions in the workspace database.

 Task 1: Create partitions


• In SQL Server Data Tools, create four new partitions named 2001, 2002, 2003, and 2004 in the
Reseller Sales table.

• For each partition, use the Query Editor to modify the Transact-SQL statement so that it includes a
WHERE clause that filters the data in the partition to include only the data for orders that were placed
the appropriate year. For example, in the 2001 partition, use the following WHERE clause.

WHERE DATEPART(YEAR, OrderDate)=2001

• Process the partitions to populate them, and check Partition Manager to view the processed
partitions.
• Delete the original ResellerSales partition, which you no longer need. When you have finished, the
Partition Manager dialog box should resemble the following image:
12-34 Implementing an Analysis Services Tabular Data Model

 Task 2: View partitions in the workspace database


• Use SQL Server Management Studio to examine the partitions in the workspace database as shown
here.

Results: After this exercise, you should have created and populated four partitions.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-35

Exercise 4: Deploying an Analysis Services Tabular Data Model


Scenario
The tabular data model is now ready for use, so you must deploy it to a server.

The main tasks for this exercise are as follows:

1. Deploy the Reseller Sales project.

2. View the deployed tabular database.

 Task 1: Deploy the Reseller Sales project


• Ensure that the project is configured to use the deployment server localhost\SQL2.

• Deploy the project, entering the user name ADVENTUREWORKS\ServiceAcct and password
Pa$$w0rd if prompted.

 Task 2: View the deployed tabular database


• Use SQL Server Management Studio to explore the deployed Reseller Sales database in the
localhost\SQL2 instance of Analysis Services, as shown here.

• View the physical files for the deployed database in the C:\Program Files\Microsoft SQL
Server\MSAS11.SQL2\OLAP\Data\Reseller Sales.0.db folder.

Results: After this exercise, you should have deployed the Reseller Sales project.
12-36 Implementing an Analysis Services Tabular Data Model

Exercise 5: Enabling Access to a Tabular Data Model


Scenario
You want to provide access to the Reseller Sales tabular data model, so that users can easily create an
Excel workbook based on it. To do this, you plan to create a BI Semantic Model Connection in the
PowerPivot Gallery document library of the company’s internal SharePoint site.

The main tasks for this exercise are as follows:


1. Enable the BI Semantic Model Connection content type

2. Create a BI Semantic Model Connection.

3. Use a BI Semantic Model Connection.

 Task 1: Enable the BI Semantic Model Connection content type


• In the Adventure Works Portal SharePoint site at http://mia-sqlbi, view the PowerPivot Gallery
document library.
• View the library settings for this document library, and if the BI Semantic Model Connection
content type is not enabled for this document library, perform the following steps to add it.

• In General Settings, click Advanced settings.

• In Content Types, in the Allow management of content types? section, click Yes, and then
click OK.

• On the Document Library Settings page, in the Content Types section, click Add from
existing site content types.
• In the Select site content types from: list, click Business Intelligence.

• In the Available Site Content Types list, click BI Semantic Model Connection, click Add, and
then click OK.

 Task 2: Create a BI Semantic Model Connection


• In PowerPivot Gallery, create a BI Semantic Model Connection that connects to the Reseller Sales
tabular data model that you deployed in Exercise 4.
• Name the connection Reseller Sales Connection.

• The tabular data model should have been deployed to the localhost\SQL2 server in a database
named Reseller Sales.

 Task 3: Use a BI Semantic Model Connection


• In PowerPivot Gallery, view the Reseller Sales Connection BI semantic mode connection, and
then create a new Excel workbook from it, enabling data access from Excel when prompted.

• When prompted, select the Model in the data model (not the No Employee Data perspective)

• In the new Excel document, use the PivotTable to view the sum of SalesAmount by
SalesTerritoryRegion.

Results: After this exercise, you should have created a BI Semantic Model Connection.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-37

Exercise 6: Configuring DirectQuery Storage Mode


Scenario
You want to test the Reseller Sales data model with the DirectQuery storage mode so that you can switch
to it if necessary as your data sets grow larger.

The main tasks for this exercise are as follows:


1. Create a SQL Server Profiler trace.

2. Test InMemory storage mode.

3. Enable DirectQuery storage mode.


4. Test DirectQuery storage mode

 Task 1: Create a SQL Server Profiler trace


• Start the SQL Server Profiler performance tool, and create a new trace for the localhost\SQL2
Analysis Services instance.
• Name the trace BI Queries, and configure it to record the following events (you will need to select
the Show all events checkbox):

• Query Begin

• Query End.
• Direct Query Begin

• Direct Query End

• VertiPaq SE Query Begin


• VertiPaq SE Query End

• Start the trace.

 Task 2: Test InMemory storage mode


• On the PowerPivot Gallery page in the http://mia-sqlbi SharePoint site, click the Create Power
View Report button for the the Reseller Sales Connection that you created in Exercise 5 as shown
here (note: you will explore Power View in more detail in the next module. In this exercise, you will
simply use it to generate some query activity).
12-38 Implementing an Analysis Services Tabular Data Model

• Expand the Reseller Sales table and elect the Sales Amount field in to view the total sales amount in
the Power View report. Then minimize Internet Explorer.

• Switch to SQL Server Profiler and review the entries in the SQL Server Profiler trace. Note that the
EventClass entries include Query Begin, VertiPaq SE Query Begin, VertiPaq SE Query End, and
Query End as shown here.

 Task 3: Enable Direct Query storage mode


• In SQL Server Management Studio, edit the properties of the Reseller Sales database in the
localhost\SQL2 instance of Analysis Services.

• On the Database page of the Properties dialog box, in the General section, in the
DirectQueryMode list, enable DirectQuery as shown here.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-39

 Task 4: Test Direct Query storage mode


• Maximize Internet Explorer and in the list of fields, expand Product Category and click Category so
that he report now shows sales by product category. Then close Internet Explorer, leaving the Power
View page.

• Switch to SQL Server Profiler and review the entries in the trace. Note that the EventClass entries now
include Query Begin, Direct Query Begin, Direct Query End, and Query End, as shown here.

• Stop the trace and close SQL Server Profiler when you are finished.

Results: After this exercise, you should have enable DirectQuery storage mode.
12-40 Implementing an Analysis Services Tabular Data Model

Exercise 7: Implementing Security in a Tabular Data Model


Scenario
To ensure that users can only view the data in the database that is relevant to them, you intend to set
row-level permissions that restrict access to sales data for specific regions only. Before you set row-level
permissions, you must disable DirectQuery storage mode.

The main tasks for this exercise are as follows:


1. Disable DirectQuery storage mode.

2. Create roles and apply database permissions.

3. Apply row-level permissions.


4. Test row-level permissions.

 Task 1: Disable Direct Query storage mode


• In SQL Server Management Studio, change storage mode for the Reseller Sales database in the
localhost\SQL2 Analysis Services instance back to InMemory.

 Task 2: Create roles and apply database permissions


• In SQL Server Data Tools, add six new roles named France, Germany, United Kingdom, United
States, Canada, and Australia to the model.
• Grant the Read permission to each role. The Role Manager dialog box should resemble the
following image.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 12-41

 Task 3: Apply row-level permissions to roles


• In the Role Manager dialog box, specify DAX filter expressions as row filters for the Sales Territory
table so that each role can only view data where the SalesTerritoryCountry field matches
appropriate country. For example, use the following expression for the Germany role.

=[SalesTerritoryCountry]="Germany"

The Role Manager dialog box should resemble the following image.

 Task 4: Test row-level permissions


• Use the Analyze in Excel feature in the model designer to view the (Default) perspective in Microsoft
Excel as France role.

• In Excel, expand the Reseller Sales table and select the Sum of Sales Amount field. Then expand the
Sales Territory table and select the SalesTerritoryCountry field. Note that France is the only
country that is displayed as shown here.

• Close Excel without saving any changes, and then close SQL Server Data Tools and any other
applications you have opened during this lab

Results: After this exercise, you should have created six roles and set and tested row-level permissions.
12-42 Implementing an Analysis Services Tabular Data Model

Module Review and Takeaways

Review Questions
1. Why might you choose to create an Analysis Services tabular data model? Why might you choose to
create an Analysis Services Multidimensional Model?

2. How might you use partitions to manage the data that you have in your databases?

3. What are the advantages of using DirectQuery mode? What features of tabular data models are not
supported in DirectQuery mode?
13-1

Module 13
Creating Data Visualizations with Power View
Contents:
Lesson 1: Introduction to Power View 13-3

Lesson 2: Visualizing Data with Power View 13-10


Lab 13: Creating Interactive Reports with Power View 13-25
13-2 Creating Data Visualizations with Power View

Module Overview

Microsoft® SQL Server® 2012 introduces Power View, a data exploration tool based on Microsoft
SharePoint® that provides a way for information workers to interactively create data visualizations that
help them to better understand the data that they are working with. This module introduces Power View
and describes how you can use it to create a range of different types of reports quickly and easily.

After completing this module, you will be able to:


• Describe the Power View and its place in the BI ecosystem.

• Create data visualizations by using Power View.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-3

Lesson 1
Introduction to Power View

Power View is an easy-to-use data visualization and exploration tool that enables you to produce ad hoc
reports that deliver information in a range of visually interesting ways. Along with PowerPivot for
Microsoft Excel®, it promotes self-service business intelligence (BI), enabling data workers to quickly and
easily find the information that they require without depending on BI developers to create reports and
data visualizations for them.

This lesson describes the Power View tool, which is a new feature in SQL Server 2012. It explains how you
can create tabular data models to support Power View reports, the different kinds of visualizations that
you can use, and how to add interactive elements to Power View reports.

After completing this lesson, you will be able to:

• Explain what Power View is and how it fits into to the Microsoft BI tools ecosystem.
• Modify tabular data models to support Power View reports.
13-4 Creating Data Visualizations with Power View

What Is Power View?

Power View is a Microsoft Silverlight® application that is built on SQL Server 2012 Reporting Services and
PowerPivot for SharePoint 2010. Installing SQL Server 2012 Reporting Services in SharePoint Integrated
mode installs the Reporting Services Add-in for SharePoint, which contains the content types, data
sources, and entry points that enable Power View functionality. The add-in also contains the Power View
Silverlight application itself. Power View reports use the tabular data models in PowerPivot for Excel
workbooks or in Analysis Services tabular databases as a data sources. You can access these tabular data
models to create Power View reports by using the PowerPivot Gallery webpage, which is hosted in
PowerPivot for SharePoint 2010.

Note There is no separate download or installation required for Power View.

Using Power View to Explore Data


The Power View application enables you to interactively explore data and to create reports that have a
strong visual impact. You can create Power View reports by choosing from a range of charts and tables,
which are called visualizations. Visualizations include bar charts, column charts, line charts, scatter charts,
cards, tiles, tables, and matrixes, which you can use to display data in a wide variety of ways. You can
include images and animations to enhance the appearance of a report and make it easier to understand,
and add interactive elements that enable you to update a report with a single click. For example, you can
create tiled images that represent different categories of products. When you click on one of these
images, the report updates to display the data for that category.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-5

Power View reports are very easy to create, and the user interface (UI) is very simple and intuitive. When
you select a field or a measure to add to a visualization, the application automatically uses it in the chart
in the most appropriate way. For example, when you select a field, Power View might add it to the X axis,
use it as a measure value, or use it as a chart series. This behavior speeds up the time it takes to build
meaningful reports, and makes it easier for inexperienced users to get started with data exploration.
Modifying reports is also very easy, you can drag visualizations to move and resize them, and replace
fields and measures in existing visualizations with just two or three clicks. Power View will automatically
display the recalculated values based on the modifications that you make.

Where Does Power View Fit into the BI Tools Ecosystem?


Power View is intended for use as a self-service data exploration tool. It complements the functionality of
other Microsoft reporting and data analysis tools, such as Report Builder 2.0, Report Builder 3.0, SQL
Server Data Tools, Performance Point Services, and PowerPivot for Excel. Power View does not provide
include a lot of the functionality that these tools offer, such as:

• A professional design environment that enables you to precisely control report layout.

• Reusable report parts.

• The ability to embed reports in applications.


• Support for creating complex calculations.

• Forecasting and write-back functionality.

Furthermore, Power View creates Report Definition Language X (RDLX) reports, unlike Report Builder and
SQL Server Data Tools, which generate Report Definition Language (RDL) reports. Consequently, you
cannot enhance Power View reports by using SQL Server Data Tools or Report Designer, and you cannot
import RDL reports into Power View.
13-6 Creating Data Visualizations with Power View

Considerations for Creating Tabular Data Models to Support Power View


Reports

Power View reports use tabular data models as data sources. You can create a tabular data model by
using the PowerPivot for Excel Add-in or by using SQL Server Data Tools to create and deploy a model to
SQL Server 2012 Analysis Services. When you create a tabular data model that you will use to support
Power View reporting, you can make specific modifications to the model that can significantly improve
the end user experience. These include:
• Implement custom summary values. When you create a Power View report, it automatically generates
summary values for any columns in the tabular data model that contain decimal values or currency
values. However, it does not generate summary values for columns that contain integer values. If
there are any specific integer-valued columns for which you require summary values, or if you want to
change the way currency columns or decimal columns summarize, you can use the Summarize By
property. You can choose from the following summary options: Sum, Max, Min, Average, Count,
Distinct Count, Default, and Do Not Summarize.
• Sorting columns. You can use the sort order options to sort data in ascending or descending order.
You can also use the Sort by Column option to sort the values in one column by using the sort order
of the values in a different column in the same table. For example, a column that contains days of the
week will sort alphabetically, which is not the sort order that you normally use for days. To sort the
days according to their position in the week, you can set the column to sort according to a different
column that uses numerical values to identify week days.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-7

Tabular Data Model Reporting Properties


The tabular data modeling environments in PowerPivot for Excel and SQL Server Data Tools both include
properties that affect the rendering of data in a Power View report. You access these properties differently
in each of these tools. To access the properties in PowerPivot for Excel, you must enable the Advanced
View. To do this, follow the steps below:

1. Switch to the PowerPivot Window.


2. On the ribbon, click the unlabeled tab to the left of the Home tab, and select Switch to Advanced
View.

3. Click the column for which you want to set properties, click the Advanced tab, and use the Default
Field Set, Table Behavior, and Image URL settings to define the required values.

You can access these same properties in SQL Server Data Tools as follows:

1. In SQL Server Data Tools, select the tabular data model .bim file, and then ensure that the Grid view is
selected.
2. Select the column that you want to set a property for, and use the Properties window to define the
required values.
The reporting properties that you can configure are described below:
• Image URL. Power View reports can include images that are retrieved from URLs or from a binary
column in a database. If you want to use URLs to retrieve images for Power View reports, you should
add a URL for each row in the relevant table, and then use the Image URL property to define a
column as an image column so that Power View displays the images correctly. If you do not define
the column in this way, Power View reports will display the actual URLs in the column instead of the
images that they link to.
• Default Image. Use this property to specify that the image in the column will display at the front of a
card visualizations, or in the navigation strip of a tile report layout. For example, in a table of
employees, the default image could be a column that contains photos of each employee.

• Default Label. Use this property to define the column name as the header that will appear in in the
navigation strip of a tile report layout. For example, in a table of employees, the default label could
be the column that contains employee names.
• Default Field Set. Use this property to define a list of columns and measures to automatically include
in Power View visualizations when you add the table that contains the columns and measures to a
report. For example, in a table of employees, the default field set could include job title, department,
and telephone number columns.

• Row Identifier. Use this property to define a column in a table that contains unique values. he table
identifier column.

• Keep Unique Rows. Use this property to ensure that each row in a table column is treated as unique
even if the column contains duplicate values. For example, in a table of employees, you might set this
property to avoid problems when employees have the same names.
13-8 Creating Data Visualizations with Power View

Demonstration: Modifying a Tabular Data Model to Support Power View


Reports

 Task 1: Configure column properties


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the
D:\10778A\Demofiles\Mod13 folder, run Setup.cmd as Administrator.
2. In the D:\10778A\Demofiles\Mod13 folder, open the Sales Demo.sln solution.

3. In Solution Explorer, double-click Model.bim. Then click the Customer tab and note that the tables
in the model contain no data.
4. On the Model menu, click Process, and then click Process All. If prompted for impersonation
credentials, specify the user name ADVENTUREWORKS\ServiceAcct and the password Pa$$w0rd,
and then click OK. Wait until processing completes, and then in the Data Processing dialog box, click
Close.

5. On the Date tab, click the Month column and press F4. Then, in the Properties window, in the Sort
by Column drop-down list, select MonthNumberOfYear.
6. On the Product Category tab, click the Product Category column. Then, in the Properties window,
click Default Label, and then in the drop down list, click True.

 Task: 2 Create custom summaries


1. On the Reseller Sales tab, click the Order Quantity column. Then in the Properties window, click
Summarize By, and then in the drop down list, change the value to Sum.

2. On the Internet Sales tab, click the Order Quantity column. Then in the Properties window, click
Summarize By, and then in the drop down list, change the value to Sum.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-9

 Task 3: Deploy the tabular data model project


1. On the File menu, click Save All

2. In Solution Explorer, right click Sales Demo and then click Deploy.

3. When deployment has completed, in the Deploy dialog box, click Close.

4. Close SQL Server Data Tools.


13-10 Creating Data Visualizations with Power View

Lesson 2
Visualizing Data with Power View

Power View enables you to create a wide variety of data visualizations, featuring items such as charts, tiles,
and play axes. You can combine these items together to create intuitive and visually stimulating reports
that can help users to easily understand the key points.
This lesson describes how to create Power View visualizations, and demonstrates how combine them to
create compelling reports.

After completing this lesson, you will be able to:


• Describe the Power View user interface
• Create a basic Power View report.

• Enhance a Power View report with additional visualizations, including series, filters, and small
multiples.

• Describe how to use tiles and play axes to add interactive elements.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-11

The Power View User Interface

You can open the Power View design environment by clicking the Create Power View Report button
next to an item in PowerPivot Gallery. Power View opens in Windows® Internet Explorer® window. The
user interface is consistent with the interface that you see in Microsoft Office products, such as Microsoft
PowerPoint® and Excel, with a ribbon at the top that you can use to access the main controls. The design
area that you use to create reports is called the View. You can add items to the View from the Fields
Section in the Field List.

Fields Section
The Fields Section contains the tables, columns, and measures that are defined in the underlying tabular
data model. You can click a table header to add the table to the View; or drag the table header and drop
it in the View. Adding a table to the View automatically adds any of the table’s columns for which the
Table Detail property is set in the data model. You can add a column or a measure to the View by
clicking the check box next to the column or measure name or by dragging the column or measure to the
View. You can also add columns and measures by dragging them to the Layout Section in the Field List,
and dropping them into the appropriate box.

Layout Section
The Layout Section contains the Tiles Field in the top section and the Chart Fields list, Table Fields list,
or the Matrix Fields list in the bottom section. The type of list that displays depends on the type of
visualization that you select. The Chart Fields list, Table Fields list, and the Matrix Fields list contain
boxes that define the function of a column or a measure in a visualization. Which boxes are displayed
depends on the type of list. For example, when you select a Bar chart visualization, the Chart Fields list
displays in the Layout Section, and the Value, Axis, Series, Vertical Multiples, and Horizontal
Multiples boxes display in the Chart Fields list.
13-12 Creating Data Visualizations with Power View

Working with Charts and Tables


After you have added tables. columns, or measures to the View, you can use the Visualizations gallery on
the Design tab in the Table Tools group on the ribbon to select the visualization that you want to use for
your data. You can also add the Filter area to the display, and then add columns that you want to filter by
to the Filter area.

You can resize charts, matrices, and tables in the View by dragging the corner of the visualization until it
is the required size, and you can reposition visualizations by dragging them to a new location. The
Popout options expands an individual visualization so that it fills the entire area of the View, which can
be useful when you are working with visualizations that contain many small or hard-to-view items.

Note Unlike when you build reports by using Report Builder or SQL Server Data Tools,
with Power View, you do not have to preview the report separately from the design
interface; the design interface and the reporting viewing area are the same thing.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-13

Creating a Basic Report

Connect to a Tabular Data Model in PowerPivot Gallery


You can create a Power View report by connecting to a tabular data model in one of the following ways:
• Connect to a PowerPivot for Excel workbook that is hosted in PowerPivot Gallery.

• Use a BI Semantic Model connection in PowerPivot Gallery to connect a tabular database that is
hosted in SQL Server Analysis Services.
For each PowerPivot Workbook and BI Semantic Model connection in PowerPivot Gallery, there is a
Create Power View Report button, which you can click to open a new Power View report. You can than
add tables, columns, and measures as described in the previous topic. When you add a table, column, or
measure to the View area, Power View automatically displays this as a table visualization and populates
the table with data by querying the underlying tabular data model.

Note Power View only retrieves the data for a visualization as it is needed. For example, in
a table visualization, Power View will retrieve only the data that it can display in the table at
the current time. If you later scroll down the table, it will then retrieve the data required to
populate the table. This places less of a burden on the data source and enables Power View
to populate tables more quickly.

Visualizations Gallery
You can add more columns to a visualization, either from the same table or a related table in the Fields
Section of the Field List. However, if you want to add columns from other tables, the tabular data model
must already contain relationships to support this. You cannot create table relationships in Power View.
13-14 Creating Data Visualizations with Power View

You can change the visualization by clicking one of the items in the Visualizations area on the Design
tab of the ribbon. The existing visualization in the View will update automatically to the new visualization;
you do not have to add the columns or measures again.

Note To convert a table to a chart visualization, the table must contain at least one
measure.

The visualizations in the Visualizations gallery include:

• Bar. Use this to create a bar chart.

• Column. Use this to create a column chart.


• Line. Use this to create a line chart.

• Scatter. Use this to create a scatter chart. You can add a play axis to a scatter chart to show changes
in data over time.

• Card. Use this to create a scorecard-like visualization. The Default Image and Default Label
properties in the supporting tabular data model can automatically add images and a header for each
card.
• Tiles. Use this to present data interactively. You can click on tile images to change the context for the
data in the charts and tables in the tile container.

• Table. Use this to create a table.


• Matrix. Use this to create a matrix. A matrix has row and column groups, and displays totals and
subtotals for these groups.

You can add multiple charts, tables, and matrices to the View area to create sophisticated and intuitive
reports that use different types of visualizations to deliver maximum impact.

Views
You can create reports that have multiple pages by using views. A view is a separate page in a Power View
report. Although all of the views in a Power View report are based on the same tabular data model, each
view has its own visualizations and filters. You can copy and paste visualizations between different views
and create a new view by copying an existing view, which makes it quick and easy to develop multi-view
reports.

Saving, Exporting, and Printing Reports


You can save the reports that you create to PowerPivot Gallery. When you save a Power View report, you
can choose whether or not to save previews of the views in the report for display in PowerPivot Gallery.
You might decide not to save previews for reasons of confidentiality. For example, if a report contains
sensitive information that should only be visible to users who have permission to open the report, you can
hide the previews when you save the report. When you open a saved Power View report from PowerPivot
Gallery, you can view the report in Power View reading mode, or in edit mode.

Note You use SharePoint permissions to control access to Power View reports.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-15

You can also export Power View reports to PowerPoint. When you export a report to PowerPoint, each
view in the report is saved as a separate slide. You can interact with the slides in the PowerPoint deck in
the same way as you can when viewing a report in Power View reading mode, for example, you can use
the filters and click the visualizations that the report author added to the report. You cannot edit or create
new visualizations or filters in a PowerPoint slide, however.

You can print Power View reports that you open from PowerPivot Gallery in both reading and editing
modes. When you choose to print a report, it prints whatever is displayed on the screen at that time.
Power View reports always print in landscape orientation, regardless of the settings in the Print dialog
box.
13-16 Creating Data Visualizations with Power View

Enhancing a Report

You can enhance Power View reports by adding columns and measures to the fields in the Layout
Section of the Field List and by creating filters.

Series
When you are working with Column, Bar, or Line chart visualizations, you can add columns to the Series
box in the Chart Fields area of the Layout Section to create a series on the chart that adds extra
information. A series is a useful way of adding context to a set of data by breaking it down by other
categories. For example, if you have a bar chart that displays sales by country, you can add a Calendar
Year series to it. The series displays each of the years in the Calendar Year column next to a color-coded
rectangle, and each bar on the chart is divided up into color-coded areas that represent the years in the
series. You can click the individual items in a series to highlight the items in the chart. For example, you
could click the year 2002 to shows sales for this year only.

Filters
You can add filters to Power View reports to limit the data that is displayed. When you add a column to
the Filters Area, you can select the values in that column to use as filters. For example, you can add the
Product Category column to the Filters Area and select the category values, such as Dairy Produce,
Meat, or Fruit and Vegetables, that you want to use as filters.

To add a filter, follow the steps below:


1. On the ribbon, click the Home tab.

2. In the Filters group, click Filters Area.

3. Drag a column from the Fields Section and release it in the Filters Area.
4. Check the boxes next to the values that you want to filter by.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-17

You can also add slicers to Power View reports to enable users to adjust filter settings dynamically. Power
View slicers, like the slicers that you create in PowerPivot for Excel reports, are clickable areas in a report
that apply or remove filters.

To create a slicer, follow the steps below:


1. Add a column from a table to the View area.

2. On the Design tab, click Slicer.

Small Multiples
You can use small multiples with Column, Bar, or Line chart visualizations. When you add a column to
the Vertical Multiples or Horizontal Multiples boxes in the Chart Fields area of a chart, Power View
creates multiple copies of the chart, one for each of the values in the column and displays them in the
View. For example, if you have a bar chart that displays sales by country, you can add the Calendar Year
column to the Vertical Multiples box to create one chart for each calendar year.
13-18 Creating Data Visualizations with Power View

Demonstration: Creating a Power View Report

 Task 1: Create a BI Semantic Model Connection


1. Ensure that you have completed the previous demonstration in this module.
2. Start Internet Explorer and browse to the SharePoint site at http://mia-sqlbi. Then, on the Adventure
Works Portal - Home page, under Libraries, click PowerPivot Gallery.

3. On the SharePoint ribbon, in the Library Tools section, click Library.


4. In the Settings area, click Library Settings.
5. Under the General Settings area, if a Content Types section exists, review the content types enabled
for this document library. If no Content Types section exists or the BI Semantic Model Connection
is not listed, perform the following steps to enable management of content types and add it.
a. In General Settings, click Advanced settings.

b. In Content Types, in the Allow management of content types? section, click Yes, and then
click OK.

c. On the Document Library Settings page, in the Content Types section, click Add from
existing site content types.
d. In the Select site content types from: list, click Business Intelligence.

e. In the Available Site Content Types list, click BI Semantic Model Connection, click Add, and
then click OK.

6. On the Document Library Settings page, under Libraries, click PowerPivot Gallery.

7. On the SharePoint ribbon, in the Library Tools section, click Documents. Then in the New
Document drop-down list, click BI Semantic Model Connection.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-19

8. In the New BI Semantic Model Connection page, in the File Name box, type Sales Demo; in the
Description box, type Sales data model; in the Workbook URL or Server Name box, type
localhost\SQL2; in the Database (if connecting to a server) box, type Sales Demo; and click OK.
After a few moments, the Sales Demo connection is shown in the PowerPivot Gallery document
library.

 Task 2: Create a Power View report


1. On the PowerPivot Gallery page, to the right of Sales Demo, click the Create Power View Report
icon.

2. In the Power View window, in the fields pane, expand Internet Sales, and then select Internet Sales
Total.
3. On the ribbon, in the Table Tools group, on the Design tab, in the Visualizations area, click
Column.

4. Drag the lower-right corner of the chart and resize it to fill the available space.

5. In the fields pane, expand Date, and then select Calendar Year to add this column to the Axis Fields
field in the Layout Section.

6. Select Month to add this column to the Series field in the Layout Section.

7. In the chart, in the Month legend, click April. Note that the chart display changes to highlight the
month of April. Click April again to display all months.

8. In the fields pane, expand Geography, and then check Country Region to add this column to the
Vertical Multiples field in the Layout Section.
9. Click in a blank space in the main view area. Then, on the ribbon, on the Home tab, in the Filters
group, click Filters Area.

10. In the fields pane, expand Product Category, drag Product Category to the filters pane, and then
check the Bikes and Clothing check boxes. The report is filtered to show sales for only bikes and
clothing.

 Task 3: Add a view to a report


1. In the ribbon on the Home tab, in the Views group, in the New View drop-down list, click New
View.

2. In the fields pane, under Internet Sales, select Internet Profit; under Date, select Calendar Year,
expand Sales Territory, and select Country; and then in the Visualizations Gallery, click Line.

3. Resize the chart to fill the available space.

 Task 4: Save and export a report


1. On the File menu, click Save As, in the Save As dialog box, in the File name field, type Internet
Review, and then click Save.
2. On the File, click Export to PowerPoint, and when prompted, click Save. in the Save As dialog box,
browse to D:\10778A\Demofiles\Mod13, in the File name field, type Internet Review Presentation,
and then click Save.
13-20 Creating Data Visualizations with Power View

3. Minimize Internet Explorer, and in the D:\10778A\Demofiles\Mod13 folder, double-click Internet


Review Presentation.pptx to view the exported presentation.

4. View the presentation as a slide show (if notified about a problem with the graphics adapter, click
OK), and then close PowerPoint without saving any changes.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-21

Adding Interactive Elements to a Report

You can add interactive elements to your reports to make it easier to examine data from different
perspectives.

Tiles
A tile visualization has two parts: a tile container that contains charts and tables, and a navigation strip
that contains items that you can click to filter the data in the tile container. You create a tile visualization
by selecting a table or matrix in the View and then clicking Tile in the Visualizations gallery. When you
create a tile visualization, you must decide which column to add to the Tile by box in the Tiles Field in
the Layout Section. The values in this column will appear as clickable areas of the navigation strip. Power
View selects a column to add to the Tile by box automatically when you create the tile visualization, but
you can change this if required. In the tile container area, you can add other charts, tables, and matrices
that will all update as you click the items in the navigation strip.

Scatter Charts, Bubble Charts, and the Play Axis


You can create a scatter chart when you need to display large amounts of related data together in a single
chart. Scatter charts show the relationship between two measure values, one on the X axis and one on the
Y axis. When you create a scatter chart, you need to specify the values for the X and Y axes. You can also
add a measure to represent the size of each coordinate on the chart, making the scatter chart into a
bubble chart. For example, you could create a scatter chart that has a measure that calculates revenue on
the X axis, a measure that calculates manufacturing costs on the Y axis and use a measure that calculates
profit that controls the size of the coordinates on the chart. You can add a column to the Details box in
the Chart Fields area in the Layout Section of the Field List to provide context by creating multiple
coordinates on the chart. For example, in the chart described above, you could add product categories to
the Details box to obtain a separate coordinate for each category that displays the relationship between
revenue, manufacturing cost, and profit.
13-22 Creating Data Visualizations with Power View

You can also add a play axis to scatter and bubble charts by adding a column that contains time data to
the Play Axis box in the Chart Fields area. When you click the play button on a play axis, the coordinates
move, grow, and shrink, indicating how these values changed over the time period defined on the play
axis. You can pause a play axis at any point and click on an individual coordinate to view its history over
time.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-23

Demonstration: Using a Play Axis in a Report

 Task 1: Create a scatter chart with a play axis


1. Ensure that you have completed the previous demonstration.
2. In Internet Explorer, in the SharePoint site at http://mia-sqlbi, view the PowerPivot Gallery
document library, and to the right of Sales Demo, click the Create Power View Report icon.

3. In the fields pane, expand Reseller Sales, and click Reseller Sales Total.
4. Drag the lower-right corner of the table and resize it to fill the available space, and then on the
ribbon, in the Visualizations gallery, click Scatter.

5. In the fields pane, under Reseller Sales, click Total Product Cost to add this field to the Y Value box
in the Layout Section.
6. In the Fields Section, in Reseller Sales, click Reseller Profit to add this field to the Size box in the
Layout Section.

7. In the fields pane, expand Product Subcategory, and click Product Subcategory to add this field to
the Details box in the Layout Section.

8. In the fields pane, expand Date, and drag Calendar Year to the Play Axis box in the Layout Section.
9. On the ribbon, on the Home tab, click Filters Area. Then, in the fields pane, under Product
Category, drag Product Category to the filters pane, and then check only the Bikes check box.

10. Click the scatter chart, and on the ribbon, in the Chart Tools area, click the Layout tab. Then, in the
Labels area, click Data Labels, and then click Right.
11. In the chart, on the Calendar Year play axis, click the Play button. The chart shows a time lapse that
demonstrates how the total cost and sales amount for bikes have both grown over the four year
period.

12. Close Internet Explorer. When prompted, click Leave this page.
13-24 Creating Data Visualizations with Power View

Lab Scenario

Business analysts at Adventure Works Cycles have been using a tabular data model in an Analysis Services
database to analyze sales. The analysts would like to be able to create interactive visualizations for the
reseller sales data by using Power View.

You will prepare the data model so that it is optimized for use in Power View. Then you will perform the
role of business analyst by initially creating a simple Power View report that shows Internet sales by year
and month for each country.

You will then create a more complex report that shows a number of visualizations relating to reseller sales
in an interactive report that includes a tile for each product category.
To visualize how the relationship between sales, cost and profit for bikes has changed over time by
creating a report that contains a scatter chart with a play axis, before finally exporting the report as a
PowerPoint presentation.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-25

Lab 13: Creating Interactive Reports with Power View

Exercise 1: Configuring a Tabular Data Model for Power View


Scenario
You have created a tabular data model, which you intend to use to support Power View reports. You will
modify the model, deploy it, and then enable client access from PowerPivot Gallery.
The main tasks for this exercise are as follows:

1. Prepare the lab environment.


2. Define reporting properties.
3. Deploy the project.

4. Create a BI Semantic Model Connection.

 Task 1: Prepare the lab environment


• Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab13\Starter
folder as Administrator.
13-26 Creating Data Visualizations with Power View

 Task 2: Define reporting properties


• In the D:\10778A\Labfiles\Mod13\Starter folder, open the Reseller and Internet Sales.sln tabular
data model project

• In the Model.bim data model designer, set the following properties for the specified columns.

Table Column Property Value

Product Category Product Category Default Label True

Reseller Sales Order Quantity Summarize By Sum

Internet Sales Order Quantity Summarize By Sum

Date Month Sort by Column MonthNumberOfYear

 Task 3: Deploy the project


• Deploy the Reseller and Internet Sales project. If you are prompted for impersonation credentials,
specify the user name ADVENTUREWORKS\ServiceAcct and the password Pa$$w0rd.

 Task 4: Create a BI Semantic Model Connection


• In the Adventure Works Portal SharePoint site at http://mia-sqlbi, view the PowerPivot Gallery
document library.
• View the library settings for this document library, and if the BI Semantic Model Connection
content type is not enabled for this document library, perform the following steps to add it.

• In General Settings, click Advanced settings.


• In Content Types, in the Allow management of content types? section, click Yes, and then
click OK.

• On the Document Library Settings page, in the Content Types section, click Add from
existing site content types.

• In the Select site content types from: list, click Business Intelligence.

• In the Available Site Content Types list, click BI Semantic Model Connection, click Add, and
then click OK.

• In the PowerPivot Gallery document library, create a BI Semantic Model Connection that connects
to the Reseller and Internet Sales tabular data model that you deployed.

• Name the connection Reseller and Internet Sales.

• The tabular data model should have been deployed to the localhost\SQL2 server in a database
named Reseller and Internet Sales.

Results: After this exercise, you should have deployed the Reseller and Internet Sales tabular data
model, and created a BI Semantic Model connection that connects to it.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-27

Exercise 2: Creating a Simple Power View Report


Scenario
You want to visualize Internet sales data in the tabular data model by creating a Power View report.

The main tasks for this exercise are as follows:

1. Create a Power View report.

2. Add a Card visualization.

3. Add a filter.

 Task 1: Create a Power View report


• Use the Reseller and Internet Sales BI Semantic Model Connection to create a report that shows
Internet Sales Total as a column chart with Calendar Year on the axis and Month as a series as
shown in the following image:

• Modify the report to include vertical multiples that show a chart for each country in the Country
Region column in the Geography table as shown here.
13-28 Creating Data Visualizations with Power View

 Task 2: Add a Card visualization


• Resize the chart to create a blank space on the right of the View area.

• Add a card visualization that displays Internet Sales Total for each category, with the default label
for each category. The report should look like the report in following image:

 Task 3: Add a filter


• Add a filter that filters by Product Category.
• Test the filter by selecting only the Bikes and Clothing categories.

Results: After this exercise, you should have created a Power View report with a column chart, small
multiples, a card visualization, and a filter.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-29

Exercise 3: Using Interactive Visualizations


Scenario
You want to create an interactive report that enables viewers to see reseller sales by calendar year and
country with details about the sales volume and profitability for each product category.

The main tasks for this exercise are as follows:


1. Create a new view.

2. Create a report that contains tiles.

 Task 1: Create a new view


• Create a new view and add the title Reseller Sales by Calendar Year and Country.

• Hide the filters area.

 Task 2: Add tiles


• Add the Product Category field from the Product Category table to the report, and then select the
Tiles visualization.
• Resize the tile visualization, and then modify the Product Category table under the blue line to show:

• Reseller Sales Total from the Reseller Sales table in the Values section.

• Calendar Year from the Date table in the Axis section.


• Country from the Sales Territory table in the Series section.

The report should resemble the following image:


13-30 Creating Data Visualizations with Power View

• To the right of the bar chart, create a Card visualization that contains the Reseller Sales Total,
Reseller Profit, and Order Quantity fields.

• Under the bar chart, add a column chart that shows Reseller Sales Total by employee Last Name.
Include a series that shows Calendar Year.
The completed report should resemble the following image.

• Click each of the product category names in the navigation strip. Note that the visualizations update
to show data for the relevant category.

Results: After this exercise, you should have created a report that contains a tile visualization.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-31

Exercise 4: Creating a Scatter Chart and a Play Axis


Scenario
You want to explore how the relationship between sales, cost and profit for bikes has changed over time
by creating a report that contains a scatter chart with a play axis.

The main tasks for this exercise are as follows:


1. Create a new view.

2. Create a report that contains a scatter chart visualization.

 Task 1: Create a new view


• Create a new view titled Reseller Profit Over Time.

 Task 2: Create a scatter chart


• Add Reseller Sales Total to the canvas and select the Scatter Chart visualization. Then resize the
visualization to fill the available space.

• In the Field List, add the following fields from the Fields Section to the relevant box in the Layout
Section:

Field Name Add to Layout Section Box:

Total Product Cost Y Value

Reseller Profit Size

Product Subcategory Details

Calendar Year Play Axis

• Add a filter to the report that filters by Product Category. Use the filter to display only the Bikes
category. The report should resemble the following image.
13-32 Creating Data Visualizations with Power View

• Use the play axis to view the changes in sales data for the Bikes category over time.

• Note that for Mountain Bikes and Road Bikes, Reseller Sales Total and Total Product Cost both
increase over time, before the Total Product Cost for Road Bikes starts to fall in 2003. When
Touring Bikes were first introduced, the Total Product Cost was high relative to the ResellerSales
Total value, but the Reseller Sales Total value rapidly increased over time, while the Total Product
Cost remained quite static over the same period.

Results: After this exercise, you should have created a report that contains a scatter chart with a play axis.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 13-33

Exercise 5: Exporting a Power View Report to Excel


Scenario
You have created a number of visualizations that you would like to present to the company executives. To
accomplish this, you plan to export the Power View report as a PowerPoint presentation.

The main tasks for this exercise are as follows:


1. Save the report.

2. View the presentation.

 Task 1: Create a new view


• Save the Power View report you have created in this lab as Sales Report.

• Export the report to PowerPoint, saving the presentation as Sales Report.pptx in the
D:\10778A\Labfiles\Lab13\Starter folder. Then, close Internet Explorer

 Task 2: View the presentation


• Open the Sales Report.pptx presentation you exported in Microsoft PowerPoint 2010.
• View the presentation as a slide show from the beginning. If a message warns you about a graphics
card issue, click OK.

• Click to interact with each slide, and note that the interactive elements of Power View are available in
the PowerPoint presentation. To advance to the next slide, click outside of the main visualization
border, or right-click outside of the main visualization and click Next, or click the navigation buttons
at the bottom left of the slide as shown here.
13-34 Creating Data Visualizations with Power View

Module Review and Takeaways

Review Questions
1. What is the purpose of the Power View tool? How does if fit in with other reporting and analysis
tools?

2. Why is it important to carefully design your tabular data models if you intend to use them to support
Power View reporting?

3. Can you think of any data sets in your workplace that you might explore by using Power View?
14-1

Module 14
Performing Predictive Analysis with Data Mining
Contents:
Lesson 1: Overview of Data Mining 14-3

Lesson 2: Creating a Data Mining Solution 14-13


Lesson 3 Validating a Data Mining Model 14-19

Lesson 4: Consuming Data Mining Data 14-26


Lab 14: Using Data Mining to Support a Marketing Campaign 14-34
14-2 Performing Predictive Analysis with Data Mining

Module Overview

Data mining enables you to use the data that you own to gain insights that can help you to make
intelligent decisions about your business. Microsoft® SQL Server® 2012 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 will happen in the future. This module introduces data mining,
describes how to create a data mining solution, how to validate data mining models, how to use the Data
Mining Add-ins for Microsoft Excel®, and how to incorporate data mining results into Reporting Services
reports.

After completing this module, you will be able to:


• Describe the key data mining concepts and use the Data Mining Add-ins for Excel.
• Create a data mining solution.

• Validate data mining models.


• Use data mining data in a report.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-3

Lesson 1
Overview of Data Mining

Data mining is a special kind 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,
and the algorithms used to build prediction models. The lesson also introduces the Data Mining Add-ins
for Excel, which you can use to perform desktop data mining analysis.

After completing this lesson, you will be able to:


• Describe the purpose of data mining.
• Describe the components of an Analysis Services data mining solution.

• Describe the different types of data mining algorithms that you can use in Analysis Services data
mining solutions.

• Use the Data Mining Add-ins for Excel to perform table analysis.
14-4 Performing Predictive Analysis with Data Mining

What Is the Purpose of Data Mining?

Revealing Hidden Patterns and Trends


Exploration of the data in a data warehouse has the potential to reveal patterns and trends that can be
useful to organizations in many ways, such as enabling them to predict customer behavior, or to provide
customers with product recommendations in real time when they are shopping online. However, the size
and complexity of data in large data warehouses can make it very difficult to derive useful information
from raw data by using standard data analysis tools and techniques. Data mining is the statistical analysis
of large volumes of data that it would be very difficult to analyze manually. By using data mining, business
users can overcome the problems associated with analyzing large and complex data sets to access useful
and actionable information.

Data Mining Algorithms


Data mining involves using algorithms to search through data to extract patterns and trends. For example,
a retail organization might want to discover if customers in large urban areas are more likely to buy goods
that are in a high price range, compared to customers who live in more rural locations. The organization
could use data mining to determine whether there are any correlations between location and price, and
to obtain additional information such as the strength of these correlations, or how multiple correlated
factors affect outcomes when they are considered together. There are various different data mining
algorithms that you can use, depending on the type of questions that you want to discover the answers
to.

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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-5

Data Mining Scenarios


• Forecasting. Companies can use data mining to analyze sales patterns to determine 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 targeting the campaign at those individuals.
• Recommendations. Companies can provide product recommendations to customers as they shop
online by analyzing customer purchasing histories and previous sales of products, and then using this
information to make purchasing suggestions.

• Risk assessment. Insurance companies can assess the likelihood of a claim being fraudulent by using
data mining algorithms that use the outcomes of previous claims to create a weighting for each
factor that affects the claim. Credit ratings agencies can use financial data and customer history data
to predict which customers are most likely to default on a loan.
14-6 Performing Predictive Analysis with Data Mining

Components of an Analysis Services Data Mining Solution

To create a data mining solution in SQL Server 2012 Analysis Services, you must install Analysis Services in
Multidimensional and Data Mining mode. Tabular mode and PowerPivot for Microsoft SharePoint® mode
do not support data mining. You then need to create a data mining structure, a case table, and a data
mining model.

Data Mining Structure


The data mining structure is the central component of a data mining solution. It performs several
functions, including:
• Contains the data source view from which the data to be mined is derived. The data source view is
based on a data source that connects to either a relational database or an Analysis Services
multidimensional database.
• Defines the case table and the mining structure columns. The mining structure columns define the
data type and content type for the columns.

• Specifies a training set. A portion of the data is used to train data mining models and a portion for
testing.

• Defines as a percentage the proportion of the data to use in the testing set.

• Contains one or more data mining models that use the same data source view and case table.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-7

Case Table
The case table stores the source data for the data mining models. When you specify the case table, you
define the data type and content type for each column. Content types include discrete, continuous, and
cyclical.

• Discrete. Discrete content types are values that are not part of a sequence. Discrete columns contain
data that has a finite number of values with no continuum between the values. Examples of discrete
data include number of children, phone number, or gender. Discrete values can be numeric or
nonnumeric.

• Continuous. Continuous content types represent sequences of numeric data on a scale. Examples of
continuous data include temperature or weight.

• Cyclical. Cyclical content types 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 More Information For more information about Content Types (Data Mining), see
http://go.microsoft.com/fwlink/?LinkID=246796.

Data Mining Model


Each data mining model uses a data mining algorithm, which you specify when you create the model. The
mining model uses the algorithm to analyze data from the data mining structure. When you create a data
mining model, you define the columns from the data mining structure to use in the model, and specify a
usage value for each column. Columns from the data mining structure for which you do not specify a
usage value are not included in the model. The available usage values are:
• Key. Key indicates that the column is a key column that contains unique values that identify each row
uniquely.

• Predictable. Predictable indicates the column for which you want to predict values in the mining
mode.

• Input. Input indicates that the model should use this column to help to predict the values for the
predictable column.

For example, if you want to predict the amount of money that each customer is likely to spend on a
supermarket website, you could use the CustomerID column as the key column, the CustomerSpend
column as the predictable column, and the various other columns that contain data such as address, age,
and number of children as input columns.
14-8 Performing Predictive Analysis with Data Mining

Analysis Services Data Mining Algorithms

Data mining algorithms provide the rules for the analysis of data. SQL Server 2012 Analysis Services
provides nine algorithms that you can use to create data mining models, and you can also add further
third-party plugin algorithms if necessary.

Data mining algorithms that are in wide use fall into the following broad categories:

• Classification algorithms. Classification algorithms predict one or more discreet variables based on
other attributes. Microsoft Decision Trees is an example that might be used to predict whether a
customer will purchase a particular product. Microsoft Neural Network and Microsoft Naïve Bayes are
also classification algorithms. The right algorithm for your purposes depends on a number of factors,
such as the volume of data or the specific types of column being analyzed. For example, the Naïve
Bayes algorithm can use discrete columns (such as City) to classify data doesn’t support continuous
columns that may be grouped into ranges (such as Age). If you need to classify data into groups
based on ranges of continuous values, the Decision Trees algorithm may be a better choice.

• Regression algorithms. Regression algorithms 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 seasonal
sales for the upcoming year for a retail store. Microsoft Linear Regression and Microsoft Logistic
Regression are also regression algorithms that can predict continuous variables.

• Segmentation or clustering algorithms. Segmentation or clustering algorithms divide data into groups
or clusters of items that have similar properties. Microsoft Clustering is an example that might be
used to divide customers into groups with similar purchasing habits or preferences.

• Association algorithms. Association algorithms find correlation between different attributes in a data
set. The Microsoft Association algorithm is an example that might be used to describe which items
are likely to appear together in a transaction, such as products that might be purchased together.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-9

• 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 click-through
paths or order of placing items in a cart.

For More Information For more information about Data Mining Algorithms (Analysis
Services -Data Mining), see http://go.microsoft.com/fwlink/?LinkID=246797.

For More Information For more information about Plugin Algorithms, see
http://go.microsoft.com/fwlink/?LinkID=246798.
14-10 Performing Predictive Analysis with Data Mining

Data Mining Add-ins for Excel

The Data Mining Add-ins for Excel are packaged in a free, downloadable extensions to Excel that make it
possible to perform a wide range of data mining analyses by using the familiar Microsoft Office interface.
There are two add-ins in the package:

• Data Mining Client for Excel. The Data Mining Client for Excel add-in enables you to prepare data
mining data, build and validate models, and manage data mining models. You can also use the Data
Mining Client for Excel to browse and query data mining models. You can use data in the Excel
worksheet or external data that is stored in an Analysis Services database.
• Table Analysis Tools for Excel. The Table Tools for Excel add-in enables you to perform table analyses,
such as analyzing key influencers, identifying exceptions in data sets, and shopping basket analysis.
The table analysis tools are designed so that they can be used by individuals who do not have an
understanding of the principals of data mining or Analysis Services.
The table analysis tools include:

• Analyze Key Influencers. The Analyze Key Influencers tool enables you to identify the factor that most
strongly influences a particular outcome. For example, if you want to identify the characteristics that
make customers most likely to purchase a specific product, you can use the Analyze Key Influencers
tool to correlate information such as customer location, age, and number of children with a column
that records whether the customer purchased the product in question.

• Detect Categories. The Detect Categories tool enables you to find columns that strongly correlate to
create new categories. For example, the tool might discover a correlation between the 45-55 age
group and the >$75,000 income bracket. You can then use this information to create a category that
you can use in a marketing campaign.

• Fill From Example. The Fill From Example tool uses sample values to provide missing values for the
rows in a column. Missing values can impair the usefulness of other data mining tools.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-11

• Forecast. The Forecast tool extrapolates future values from existing trends in time series data to create
predictions. For example, you can use the Forecast tool to predict sales figures for the coming year.

• Highlight Exceptions. The Highlight Exceptions tool identifies rows that do not match the patterns
found in the majority of rows in the data set. You can then analyze these rows further, or exclude
them from the data set.

• Scenario Analysis. The Scenario Analysis tool enables you to evaluate the effects of proposed
scenarios. The Goal Seek scenario enables you to identify the factors that you need to change to meet
a desired goal. The What-If scenario enables you to assess the effects of a change before you actually
implement that change. For example, you could predict the effects on sales of as an increase in
product prices.

• Prediction Calculator. The Prediction Calculator tool accepts a target value for a specific column, and
then correlates the values in other columns with that value to identify the most common patterns.
The tool presents the results in the form of a scorecard.

• Shopping Basket Analysis. The Shopping Basket Analysis tool enables you to perform cross-selling
analysis. For example, you can use the tool to identify products that frequently sell together, and use
this to generate recommendations to customers who are browsing your website.
14-12 Performing Predictive Analysis with Data Mining

Demonstration: Performing Table Analysis in Excel

 Task 1: Create a connection to Analysis Services


1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd. Then in the
D:\10778A\Demofiles\Mod14 folder, run Setup.cmd as Administrator.

2. In the D:\10778A\Demofiles\Mod14 folder, double-click Table Analysis.xlsx to open it in Excel.

3. On the ribbon, in the Table Tools group, click the Analyze tab, and then click <No Connection>.
4. In the Analysis Services Connections dialog box, click New, in the Connect to Analysis Services
dialog box, in the Server name field, type (local), in the Catalog name drop-down list, click
DMAddinsDB, and then click OK.
5. In the Analysis Services Connections dialog box, click Close.

 Task 2: Use the Excel table analysis tools


1. On the ribbon, click Analyze Key Influencers.

2. In the SQL Server Data Mining - Analyze Key Influencers dialog box, in the Column Selection
drop-down list, click Purchased Bike, and then click Run.

3. In the SQL Server Data Mining – Discrimination based on key influencers dialog box, in the
Compare Value 1 drop-down list, click Yes, and then in the to Value 2 drop-down list, click No.

4. Click Add Report, and then click Close.

5. Review the Key Influencers Report for ‘Purchased Bike’ report. Note the values that most strongly
correlate with a customer purchasing a bike.

6. Close Excel, and do not save changes to Table Analysis.xlsx.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-13

Lesson 2
Creating a Data Mining Solution

When you create a data mining solution in Analysis Services, you first create a model that describes your
business problem, and then you train the model by running your data through algorithms that generates
a mathematical model of the data. 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 that you can use to investigate that data
in various different ways.
This lesson describes how to create a data mining structure and a data mining model. The lesson also
describes how to edit data models and use the Data Mining Add-ins for Excel to create a data mining
model. Finally, the lesson introduces the Data Mining Extensions (DMX) language, which you can use to
work with data mining in Analysis Services.

After completing this lesson, you will be able to:

• Create a data mining structure and a data mining model.

• Edit a data mining structure and model.


14-14 Performing Predictive Analysis with Data Mining

Creating Data Mining Solutions

In SQL Server Data Tools, you can use the Data Mining Wizard to create new data mining structures and
models. You can then use the Data Mining Designer in SQL Server Data Tools to configure the structure.
You can also use the Data Mining Client for Excel add-in to create, and edit data mining structures and
models.

Data Mining Wizard


You can use the Data Mining Wizard to define the data mining structure and optionally, to create the first
data mining model for the structure. The Data Mining Wizard starts automatically when you create a new
data mining structure. When you run the Data Mining Wizard, you can configure the data source view,
the case table, the Key, Input and Predictable columns for the training data, the column data types and
content types, and the proportion of the data to use for the testing set. If you choose to create a data
mining model at the same time as you create a data mining structure, you must also specify the mining
technique for the model to use.

Data Mining Designer


You can use the Data Mining Designer to configure the data mining structure and data mining model that
you created with the Data Mining Wizard. For example, you can use the Data Mining Designer to add new
data mining models, train, browse, and compare models, and to create predictions based on data mining
models.

Data Mining Client for Excel


You can use the Data Mining Client for Excel add-in to create data mining structures and models. You can
also use the add-in to edit models and structures that you created by using SQL Server Data Tools. The
add-in includes dedicated wizards for creating the more commonly used data mining models, which make
the process much simpler for inexperienced users.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-15

Demonstration: Using the Data Mining Wizard

 Task 1: Create a data mining project in SQL Server Data Tools


1. Ensure that you have completed the previous demonstration.
2. Click Start, click All Programs, click Microsoft SQL Server 2012, and then click SQL Server Data
Tools.

3. In SQL Server Data Tools, on the File menu, click New, and click Project.
4. In the New Project dialog box, click Analysis Services Multidimensional and Data Mining Project,
in the Name field, type, Mine AW, in the Location field, browse to D:\10778A\Demofiles\Mod14,
and then click OK.

5. In Solution Explorer, right-click Data Sources, and then click New Data Source.

6. In the Data Source Wizard, on the Welcome to the Data Source Wizard page, click Next, and then
on the Select How to Define the Connection page, click New.
7. In the Connection Manager dialog box, in the Server name field, type localhost, in the Select or
enter a database name drop-down list, click AdventureWorksDW, and then click OK.

8. In the Data Source Wizard, on the Select How to Define the Connection page, click Next, on the
Impersonation Information page, click Use a specific Windows user name and password, in the
User name field, type ADVENTUREWORKS\Student, in the Password field, type Pa$$w0rd, click
Next, and then on the Completing the wizard page, click Finish.
9. In Solution Explorer, right-click Data Source Views, and then click New Data Source View.

10. In the Data Source View Wizard, on the Welcome to the Data Source View Wizard page, click
Next, on the Select a Data Source page, ensure that Adventure Works DW is selected, and then
click Next.
14-16 Performing Predictive Analysis with Data Mining

11. 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.

12. On the Completing the Wizard page, in the Name field, type AW DW View, and then click Finish.

 Task 2: Create a data mining structure and a data mining model


1. In Solution Explorer, right-click Mining Structures, click New Mining Structure, and then in the
Data Mining Wizard, on the Welcome to the Data Mining Wizard page, click Next.

2. On the Select the Definition Method page, ensure that From existing relational database or data
warehouse is selected, and then click Next.

3. On the Create the Data Mining Structure page, ensure that the Create mining structure with
mining model radio button is selected, in the Which data mining technique do you want to use?
drop-down list, ensure that Microsoft Decision Trees is selected, and then click Next.

4. On the Select a Data Source View page, select AW DW View and click Next.
5. On the Specify Table Types page, in the vTargetMail row, select the check box in the Case column,
and then click Next.

6. On the Specify the Training Data page, in the Mining Model Structure table, select the following
columns:
• BikeBuyer: Predictable

• CustomerKey: Key
• All other columns: Input
7. 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.

8. On the Create Testing Set page, note that the Percentage of data for testing value is 30%, and
then click Next.
9. On the Completing the Wizard page, in the Mining structure name field, type Purchase
Prediction, in the Mining model name field type Purchase Decision Tree, and then click Finish.

10. On the Build menu, click Deploy Mine AW.


11. Close SQL Server Data Tools
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-17

Editing Data Mining Structures and Models

Data Mining Designer


You can use the Data Mining Designer in SQL Server Data Tools to edit data mining structures, add and
edit data mining models, test the accuracy of data models, and to view model data.

To add models to an existing data mining structure, use the following procedure:

• In SQL Server Data Tools, on the Mining Models tab, click the Create a related mining model
button, or right-click an existing mining model, and then click New Mining Model.

• In the New Mining Model dialog box, enter a model name and select an algorithm for the new
model.

Data Mining Client for Excel


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. The Manage
Mining Structures And Models dialog box, enables you to rename, delete, clear, process, export, and
import structures and models.
14-18 Performing Predictive Analysis with Data Mining

Demonstration: Modifying a Data Mining Structure

 Task 1: Connect to a data mining model


1. Ensure that you have completed the previous demonstrations in this module.
2. Click Start, click All Programs, click Microsoft Office, and then click Microsoft Excel 2010.

3. On the ribbon, on the Data Mining tab, in the Connection area, click DMAddinsDM ((local)), and
then in the Analysis Services Connections dialog box, click New.
4. In the Connect to Analysis Services dialog box, in the Server name field, type (local), in the
Catalog name drop-down list, select Mine AW, and then click OK.

5. In the Analysis Services Connections dialog box, click Close.

 Task 2: Add a model to a data mining structure


1. On the ribbon, in the Data Modeling area, click Advanced, and then click Add Model to Structure.
2. In the Add Model To Structure Wizard, on the Getting Started with the Add Model to Structure
Wizard page, click Next, on the Select Structure or Model page, ensure that the Purchase
Prediction structure is selected, and then click Next.

3. On the Select Mining Algorithm page, in the Algorithm drop-down list, click Microsoft Naive
Bayes, and then click Next.

4. On the Select Columns page, in the Bike Buyer row, in the Usage column, click Predict Only, in the
Name Style row, in the Usage column, click Do not use, and then click Next.

5. On the Finish page, clear the Browse Model checkbox and click Finish.

6. On the ribbon, in the Management section, click Manage Models to verify that the model has been
added to the data mining structure, and then click Close.

7. Close Excel without saving the workbook.


10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-19

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 that you 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, describes the criteria for validating
models, and introduces the tools for model validation that are provided in SQL Server Data Tools and the
Data Mining Client for Excel add-in.

After completing this lesson, you will be able to:

• Explain the need for model validation.

• Describe the main validation criteria.

• Describe the tools that you can use to validate data mining models.
14-20 Performing Predictive Analysis with Data Mining

Overview of Data Mining Validation

Data mining algorithms use statistical models to predict the outcome of defined scenarios. However, if
you use multiple algorithms to analyze a single data set, the results that the algorithms produces will not
be identical. This is because each algorithm uses different techniques to analyze data. Consequently, when
you analyze data by using different algorithms, you need to test the results to discover which algorithm is
the most accurate for the given scenario. This process is known as validation.

When you create a data model, you use a set of data called the training set to build the model. You also
define a proportion of the data to use to test the model. This is known as the testing set. To test the
validity of a data mining model, you create prediction queries to use against the testing set, and then use
validation tools to compare the results of the mining model to this data. You can view the results of
validation tests in accuracy charts, which compare predicted values with actual values.
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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-21

Criteria for Validating Data Mining Models

To assess the validity of a data mining model, there are three principal criteria to consider; accuracy,
reliability, and usefulness.

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, so it is important to assess
the accuracy of a model so that you know how much you can trust the results that it produces. If you are
aware in advance that the data contains a certain percentage of inaccurate data, you can decide to accept
a degree of inaccuracy in the models that you create. Data that qualifies as highly accurate data is not
necessarily reliable or useful. For example, you might test a model that predicts future sales performance
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 that was used in the model is incorrect, the
data that the model produces is neither reliable nor useful.

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 it might not be useful because it doesn’t explain why that
correlation exists.
14-22 Performing Predictive Analysis with Data Mining

Tools for Validating Data Mining Models

SQL Server Data Tools, the Data Mining Add-In for Excel, and SQL Server Management Studio include
tools for validating data mining models.

SQL Server Data Tools


You can use the Mining Accuracy Chart tab in the Data Mining Designer in SQL Server Data Tools to
create charts and reports that enable you to assess the validity of your data models.
• Lift chart. A lift chart is a graphical representation of the difference between the results produced by a
data mining model and the results that random guessing would generate. The difference between
these two sets of results is called the lift. You can compare multiple models simultaneously by using a
lift chart, which enables you to easily identify the best model. For example, if you are creating a
mailing campaign, you can create a lift chart to identify the model that best predicts the customers
who are most likely to respond to the campaign. Typically, a lift chart is best when used with
continuous data values.

• Profit chart. A profit chart 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 your mailing campaign, you could specify to use 5000 customer rows, the
total cost of the campaign, the cost per customer, and the revenue per customer. These values are
used to calculate the profitability of the campaign.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-23

• Classification matrix. A classification matrix uses testing data to count and display the number of true
positives 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 that contains two values, 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 accuracy
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
partition as the training set. The other partitions are used to validate the results of this analysis. The
process is then repeated several times, each time using a different partition as the training set.

Data Mining Client for Excel


The Data Mining Client for Excel enables you to validate data mining models by using a set of wizards,
which you can access from the Accuracy and Validation area of the Data Mining tab on the ribbon. The
Accuracy Chart Wizard enables you to create a lift chart, the Classification Matrix Wizard enables you to
create a classification matrix, the Profit Chart Wizard enables you to create a profit chart, and the Cross-
Validation wizard enables you to perform cross validation.

SQL Server Management Studio


You can use SQL Server Management Studio to connect to an Analysis Services database that contains a
data mining structure, and perform the following validation tasks for models in the structure:

• Create a lift or profit chart.

• Create a classification matrix.


• Create a cross-validation report.
14-24 Performing Predictive Analysis with Data Mining

Demonstration: Validating Data Mining Models

 Task 1: Create a lift chart


1. Ensure that you have completed the previous demonstrations in this module.
2. Start SQL Server Management Studio, and when prompted, connect to the localhost instance of
Analysis Services by using Windows authentication.

3. In Object Explorer, expand Databases, expand Mine AW, and expand Mining Structures. Then
right-click the Purchase Prediction mining structure and click View Lift Chart.
4. 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.
5. 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 predications against the
number of cases in the overall sample. As the number of cases increases, the ideal model maintains an
accuracy of 100%, but the models you have created tend to become less accurate the more cases
there are.

6. Review the scores in the Mining Legend tab to see which of your models is the most accurate for this
test data.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-25

 Task 2: Create a profit chart


1. In the Chart type drop-down list, select Profit Chart.

2. In the Profit Chart Settings dialog box, enter the following values to reflect a marketing campaign
you are planning, and then click OK:
• Population: 20000 (this is the number of potential customers you plan to contact)

• Fixed cost: 1000 (this is the fixed cost of you marketing campaign)

• Individual cost: 3 (this is the cost associated with contacting each customer)
• 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 tab to evaluate which mining model is likely to generate
the most profitable marketing campaign based on the test data.

 Task 3: Create a classification matrix


1. Click the Classification Matrix tab.

2. Review the matrix, noting that for each model it shows the number of times the model predicted a
Bike Buyer value of 0 or 1 on rows, with columns for the actual value of the Bike Buyer column in
the test data.

 Task 4: Create a cross validation report


1. Click the Cross Validation tab.
2. Enter the following values, and click Get Results.

• Fold Count: 5 (this is the number of partitions used to group the data for analysis)

• Max Cases: 5 (this is the number of cases to be analyzed)


• Target Attribute: Bike Buyer (this is the predictable column to be evaluated)

• Target State: 1 (this is the desired value for the target attribute)

• 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:

• Classifications for true positives, false positives, true negatives, and false negatives.

• The likely lift gained by using the model.


4. Minimize SQL Server Management Studio—you will use it in the next demonstration.

For More Information For more information about Cross-Validation Formulas, see
http://go.microsoft.com/fwlink/?LinkID=246799.
14-26 Performing Predictive Analysis with Data Mining

Lesson 4
Consuming Data Mining Data

In order for data analysts and business analysts to utilize the results produced by data mining models, the
results need to be displayed in useful and comprehensible ways.

This lesson describes the options for viewing data mining results and describes how you can use
Reporting Services reports to render data mining results in a user-friendly format.

After completing this lesson, you will be able to:

• Describe the tools for viewing data mining results.


• Explain the purpose of DMX.

• Explain the benefits of using Reporting Services to display data mining results.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-27

Viewing Data Mining Results

Mining Model Viewer


You can view the results of data mining analyses in SQL Server Data Tools, by using the Mining Model
Viewer in the Data Mining Designer. The viewing options that are available vary depending on the type of
model you want to view, for example, you can use the Microsoft Tree Viewer to browse a decision tree
model. The Microsoft Tree Viewer includes the Decision Tree and the Dependency Network tabs to enable
you to view the results in different graphical formats.

In the Mining Model Viewer, you can refresh data model views and, depending on the viewer that you
use, you can 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. You can
browse a model by clicking Browse in the Model Usage area of the ribbon and then specifying the model
that you want to view. As with the Mining Model Viewer, the way the results are displayed varies
depending on the type of model.
14-28 Performing Predictive Analysis with Data Mining

Introduction to DMX

Analysis Services includes the DMX query language, which you can use to work with data mining models.
DMX is an extension of Transact Structured Query Language (Transact-SQL). You can use DMX to create
the structure of new data mining models, to train these models, and to browse, manage, and use them to
generate predictions.

To help you to build DMX prediction queries, SQL Server Management Studio includes a query builder
tool and DMX templates that 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.
You can use the result of any DMX query as the basis of a report. By taking advantage of the
parameterization and formatting features that are available in Reporting Services, you can deliver data
mining results in a format that it easy to consume.
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.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-29

The following code example creates a new mining model that uses the Microsoft Naive Bayes algorithm.
The Bike Buyer column is defined as the predictable attribute.

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 mining models, browse mining models, and to create predictions against
mining models. 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 of the values
in the Age column.

SELECT DISTINCT [Age] AS [Midpoint Age],


RangeMin([Age]) AS [Minimum Age],
RangeMax([Age]) AS [Maximum Age]
FROM [TM Decision Tree]

For More Information For more information view the Data Mining Extensions (DMX)
Reference, see http://go.microsoft.com/fwlink/?LinkID=246800.
14-30 Performing Predictive Analysis with Data Mining

Demonstration: Querying Data Mining Models

 Task 1: Browse a data mining model


1. Ensure that you have completed the previous demonstrations in this module.
2. Maximize SQL Server Management Studio, and in Object Explorer, right-click the Purchase
Prediction data mining structure and click Browse.

3. In the Mining Model drop-down list, ensure that Purchase - 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.

4. 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 0 or 1.
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 other column
value 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 drop-down list, select 1, and in the Value 2 drop-down list, select 0. Then note
how values for each other column favor a Bike Buyer value of 1 or 0.

7. 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.

 Task 2: Query a data mining model


1. In Object Explorer, right-click the Purchase Prediction mining structure and click Build Prediction
Query.

2. In Query Designer, in the Mining Model pane, click Select Model, in the Select Mining Model
dialog box, expand Purchase Prediction, click Purchase - Bayes, and then click OK.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-31

3. In the Select Input Table(s) pane, click Select Case Table, in the Select Table dialog box, click
ProspectiveBuyer (dbo), and then click OK.

4. Under the Mining Model pane, in the Source column, click ProspectiveBuyer table, and then in the
Field column, click EmailAddress.
5. Under the row you just added, in the Source column, click Purchase – Bayes mining model, in the
Field column, click Bike Buyer, and in the Criteria/Argument column, type =1.

6. 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, and then drag the Bike
Buyer column from the Purchase – Bayes model in the Mining Model pane to the
Criteria/Argument column so that it contain the value [Purchase - Bayes].[Bike Buyer].

7. On the Mining Model menu, click Query to view the DMX code that has been generated.

8. 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 the prediction is accurate.

9. Close SQL Server Management Studio without saving any changes.


14-32 Performing Predictive Analysis with Data Mining

Using Data Mining Data in Reporting Services Reports

You have seen how DMX queries can be used to generate predictive information from a data mining
model. To provide a way of viewing data mining results that is easier for business users to consume, you
can create a Reporting Services report that uses DMX to query the data mining mode and provide
predictive information. Reporting Services reports offer a wide range of display and formatting options
that enable you to display results in the most intuitive way, and you can incorporate the results of
multiple models into a single report for convenience.

Data Mining models store data in an Analysis Services database. To connect to an Analysis Services
database to create a data mining report, you create an Analysis Services connection in a Reporting
Services project in SQL Server Data Tools. You can then use Query Builder to create the query that
retrieves the data to use in the report.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-33

Lab Scenario

The marketing department at Adventure Works Cycles is planning a direct mail campaign.

In order to maximize the effectiveness of the campaign, you have been asked to create a report that uses
data mining techniques to identify the subset of potential customers who are most likely to purchase a
bike.
14-34 Performing Predictive Analysis with Data Mining

Lab 14: Using Data Mining to Support a Marketing


Campaign

Exercise 1: Using Table Analysis Tools


Scenario
Marketing managers at Adventure Works want to create a mailing list that targets the individuals in their
data warehouse who are most likely to make a bike purchase. The first thing that you will is use the Data
Mining Add-in for Excel to identify the key factors that correlate with previous purchases of bikes by using
data from the data warehouse.

The main tasks for this exercise are as follows:


1. Prepare the lab environment.

2. Create a connection to Analysis Services.

3. Use the Data Mining Add-in for Excel table analysis tools.

 Task 1: Prepare the lab environment


• Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to MIA-
SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

• Run the Setup Windows Command Script file (Setup.cmd) in the D:\10778A\Labfiles\Lab14\Starter
folder as Administrator.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-35

 Task 2: Use the Data Mining add-in for Excel to create a connection to Analysis
Services
• In the D:\10778A\Labfiles\Lab14\Starter folder, open the Customer Data For Data Mining.xlsx
workbook with Microsoft Excel.

• On the ribbon, in the Table Tools group, click the Analyze tab, create a new connection the
DMAddinsDB catalog on the localhost server.

 Task 3: Use the Data Mining add-in for Excel table analysis tools
• Use the Analyze Key Influencers tool to identify the key influencers on purchasing a bike.

• Use the Purchased Bike column as the column to analyze for key factors.
• Include a discrimination report that compares the value Yes to the value No.

The report should resemble the following image:

• Review the report, and then close the Excel, saving your changes.

Results: After this exercise, you should have created a Key Influencers report in Excel.
14-36 Performing Predictive Analysis with Data Mining

Exercise 2: Creating a Data Mining Model


Scenario
Now that you have an idea of the key influencers on bike purchasing, you want to create a data mining
model that will enable you to identify the individuals who are most likely to make a bike purchase. You
will use SQL Server Data Tools to create the model, and then deploy the model to Analysis Services.

The main tasks for this exercise are as follows:


1. Create a data mining project.

2. Create a data mining structure and a data mining model.

3. Deploy the data mining model.

 Task 1: Create a data mining project


• Start SQL Server Data Tools, and create an Analysis Services multidimensional and data mining project
named AW Data Mining. Save the project in the D:\10778A\Labfiles\Lab14\Starter folder.
• Create a data source named Adventure Works DW that connects to the AdventureWorksDW
database on the localhost Analysis Services instance. Use the credentials for the
ADVENTUREWORKS\Student user account with the password Pa$$w0rd to connect.
• 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.

 Task 2: Create a data mining structure and a data mining model


• Use the Data Mining Wizard to create a data mining structure that uses the Microsoft Decision
Trees algorithm.
• Specify the vTargetMail view from the Adventure Works DW DM View data view as the case table.

• Configure the columns in the case table as follows:


• BikeBuyer: Predictable
• CustomerKey: Key

• All other columns: Input

• Have the wizard detect the content types 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 be
Discrete.

• Create a testing set with 30% of the data.


• Name the data mining structure Purchase Prediction, and name the data mining model Purchase
Decision Tree.

 Task 3: Deploy the data mining model


• Deploy the model to the localhost Analysis Services instance.

Results: After this exercise, you should have created a data mining structure and a data mining model.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-37

Exercise 3: Using the Data Mining Add-in for Excel to Modify the Data
Mining Structure
Scenario
You want to create a second model in the Purchase Prediction data mining structure that uses the Naive
Bayes algorithm. You will use the Data Mining Add-in for Excel to create the new model and review it.

The main tasks for this exercise are as follows:

1. Connect to the AW Data Mining model.

2. Add a model to the data mining structure.

3. Review the data mining model.

 Task 1: Connect to the AW Data Mining model


• Start Excel, and on the Data Mining tab of the ribbon, create a new connection to the AW Data
Mining database on the localhost Analysis Services instance.

 Task 2: Add a model to the data mining structure


• On the Data Mining tab of the ribbon, use the advanced data modeling support to add a model to
the structure.
• Add the new model to the Purchase Prediction structure.

• Use the Microsoft Naive Bayes algorithm.

• Specify Bike Buyer as a Predict Only column and Customer Key column as a Key column, and
do not use the Age, Birth Date, Date First Purchase, Geography Key, or Name Style columns.
All remaining columns should be specified as Input columns.

• Name the model Purchase – Bayes, and select the options to process and browse it.
• On the Finish page, click Finish.

 Task 3: Review the data mining model


• Review the data mining model by viewing the Dependency Network, Attribute Profiles, Attribute
Characteristics, and Attribute Discrimination tabs of the model browser.
• Close the browser but keep Excel open for the next exercise.

Note In the Bike Buyer column, the value 1 indicates that the customer is a bike buyer,
and the value 0 indicates that the customer is not a bike buyer. When reviewing the Naive
Bayes data mining model, you will need to enter the correct values for the Bike Buyer
column on the Attribute Characteristics tab, and the Attribute Discrimination tab.

Results: After this exercise, you should have created a Naive Bayes data mining model.
14-38 Performing Predictive Analysis with Data Mining

Exercise 4: Validating Data Mining Models


Scenario
Now that you have created the data mining models, you want to validate them to see which is the most
accurate for your data. You will use the Data Mining Add-in for Excel to validate the models.

The main tasks for this exercise are as follows:


1. Use the Accuracy Chart wizard.

2. Use the Classification Matrix wizard.

3. Use the Profit Chart wizard.

 Task 1: Use the Accuracy Chart wizard


• Use the Data Mining tools in Excel to view an accuracy chart for the Purchase Prediction data
mining structure. The chart should show accuracy for predicting a Bike Buyer value of 1 from the test
data in the mining structure.
• Review the accuracy chart to determine the relative accuracies of each model when used to predict
bike buyers in a given population of prospective customers.

 Task 2: Use the Classification Matrix wizard


• Use the Data Mining tools in Excel to view a classification matrix for the Purchase Prediction data
mining structure. The matrix should show percentages of correct and incorrect predictions of a Bike
Buyer value from the test data in the mining structure.

• Review the classification matrix to determine how often the mining models correctly predicted a
value of 1 or 0 for the Bike Buyer column when compared to the test data.

 Task 3: Use the Profit Chart wizard


• Use the Data Mining tools in Excel to view a profit chart for the Purchase Prediction data mining
structure. The chart should show the estimated profit generated by each model when predicting a
Bike Buyer value of 1 for a target population of 5000 with a fixed cost of 500.00, and individual cost
of 1.00, and a revenue per individual of 150.00 when using the test data in the mining structure.

• Review the profit chart to determine predicted profitability for each model.
• Save the workbook as DM Validation.xlsx.

Results: After this exercise, you should have validated the data mining models by using the Data Mining
Add-in for Excel.
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-39

Exercise 5: Using a Data Mining Model in a Report


Scenario
Now that you have validated the data mining models, you want to create a report that contains the list of
potential bike purchasers listed from most likely to purchase to least likely. You will create a Reporting
Services report that uses data from the AW Data Mining database and then format the report.

The main tasks for this exercise are as follows:


• Create a report.

 Task 1: Create a report


• Use SQL Server Data Tools to create a new project by using the Report Server Project Wizard.

• Name the project Promotion Targeting.


• Create a new data source for the AW Data Mining database in the localhost instance of
Microsoft SQL Server Analysis Services.

• 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.

Source Field Alias Criteria/Argument

ProspectiveBuyer FirstName

ProspectiveBuyer LastName

ProspectiveBuyer Address Line 1

ProspectiveBuyer City

Purchase – Bayes Bike Buyer =1

Prediction Function PredictProbability Purchase Probability [Purchase - Bayes].[Bike Buyer]

• Create a tabular report with all fields in the details section and format it using any style, and
name it Potential Bike Buyers.
• Sort the report from Z to A by the Purchase Probability column and change the format of the
Purchase Probability column to percentage.

• Review the Potential Bike Buyers report. It should resemble the following image.

Results: After this exercise, you should have created a report that predicts bike purchasers.
14-40 Performing Predictive Analysis with Data Mining

Module Review and Takeaways

Review Questions
1. What is the purpose of data mining?
2. What are the major components of an Analysis Services data mining solution?

3. What are the main criteria for validating data mining models?
10778A: Implementing Data Models and Reports with Microsoft® SQL Server® 2012 14-41

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.
14-42 Performing Predictive Analysis with Data Mining
L1-1

Module 1: Introduction to Business Intelligence and Data


Modeling
Lab 1: Reporting and Analyzing Data
Exercise 1: Exploring a Reporting Services Report
 Task 1: Prepare the lab environment
1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab01, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab01\Starter folder.

4. Right-click the Setup Windows® Command Script file (Setup.cmd), and then click Run as
administrator.

5. Click Yes when prompted to confirm that you want to run the command file, and then wait for the
script to finish.

 Task 2: Publish and view a Reporting Services report


1. Start Internet Explorer® and browse to the http://mia-sqlbi SharePoint site.

1. In the Libraries section of the Quick Launch pane on the left of the site, click Reports.
2. On the Documents tab of the ribbon, click New Document and then click Report Builder Report. If
prompted to install Report Builder, click Run and wait for the application to be downloaded and
installed.

3. In the Getting Started window, click Open. Then browse to the


D:\10778A\Labfiles\Lab01\Starter\AWReports folder and open the Sales_Report.rdl report.

4. Click the round button at the top left of the Report Builder window, and click Save As. Then click the
Recent Sites and Servers shortcut, double-click http://mia-sqlbi/, double-click Reports, and click
Save.

5. Close Report Builder, and in Internet Explorer, in the Libraries section of the Quick Launch area, click
Reports to refresh the view.
6. Click the Sales_Report report, and note that it shows a chart of sales for 2004.

7. At the top of the report page, click the Next Page button and note that this page shows sales details
for January. Each subsequent page shows sales for the remaining months of the year.
8. In the Year parameter list, uncheck 2004, check 2001, and then click Apply. Note that the report
now shows sales for 2001.

9. On the Actions menu bar, click Export, and then click Excel. When prompted, click Open and then
when the file has downloaded, click Open again to open the report in Excel®.

10. In Excel, click Enable Editing, and view the worksheets in the workbook. Then close Excel without
saving any changes and close Internet Explorer.
L1-2 Module 1: Introduction to Business Intelligence and Data Modeling

Exercise 2: Exploring a PowerPivot Workbook


 Task 1: Open and review a PowerPivot for Excel workbook
1. In the D:\10778A\Labfiles\Lab01\Starter folder, double-click AW Sales.xlsx.

2. Click the Reseller Sales tab. This worksheet contains a PivotTable table that displays the Sales
Amount, Product Cost, and Total Profit measures, a PivotChart chart called Sales Amount by
Category by Year, and two slicers called Country and Calendar Year.
3. In the PivotTable table, expand Bikes. Note that the values in the Sales Amount, Product Cost, and
Total Profit columns update automatically to show the data for the Bikes category. Note that the
color-coded conditional formatting in the Total Profit column displays a different color for each of
the bike categories. The color that is displayed for a given category depends on the value in the Total
Profit column for that category.

4. Expand Mountain Bikes and review the data for the different products in the Mountain Bikes
subcategory.

5. Review the data in the Sales Amount by Category by Year PivotChart chart.

6. In the Country slicer, click United Kingdom. Note that the data in the PivotTable table and the
PivotChart chart updates to show only the sales figures for the United Kingdom.
7. In the Calendar Year slicer, click 2004. Note that the data in the PivotTable table and the PivotChart
chart updates to show only the sales figures for 2004.

8. In the Calendar Year slicer and the Country slicer, click the Clear Filter button.
9. Close the PowerPivot window, and then close Excel without saving any changes.

 Task 2: Upload a PowerPivot for Excel workbook to PowerPivot Gallery


1. Start Internet Explorer and browse to the http://mia-sqlbi SharePoint site.
2. In the Libraries list, click PowerPivot Gallery.

3. Click the Documents tab, click the Upload Document drop-down menu, and then click Upload
Document.
4. In the PowerPivot Gallery – Upload Document dialog box, click Browse.
5. In the File name box, navigate to the D:\10778A\Labfiles\Lab01\Starter\ folder, click
AW Sales.xlsx, and then click Open.

6. In the PowerPivot Gallery – Upload Document dialog box, click OK.

7. If the PowerPivot Gallery – AW Sales.xlsx dialog box appears, click Save.


Lab 1: Reporting and Analyzing Data L1-3

 Task 3: Open a PowerPivot for Excel workbook from PowerPivot Gallery


1. In the PowerPivot Gallery, click the large AW Sales icon.

2. Click the Reseller Sales tab, and then use the Calendar Year and Country slicers to modify the data
that is displayed in the PivotTable table and PivotChart charts.
3. Clear the Calendar Year and Country slicer filters.

4. In the breadcrumb trail at the top of the page, click PowerPivot Gallery to close the workbook.

5. Keep Internet Explorer open for the next exercise.


L1-4 Module 1: Introduction to Business Intelligence and Data Modeling

Exercise 3: Exploring a Power View Report


 Task 1: Open a Power View report and create a column chart
1. In the PowerPivot Gallery, to the right of AW Sales, click Create Power View Report.

2. In the Field List, in the Fields Section, expand Reseller Sales, and then select Sales Amount.
3. On the Design tab, in the Visualizations gallery, click Column.

4. Pause the pointer on the lower-right corner of the chart, and then drag the chart to enlarge it.

5. In the Field List, in the Fields Section, expand Date, and then select Calendar Year.
6. In the Field List, in the Fields Section, expand Product, and then select Category.

7. Drag the bottom right corner of the column chart to make it larger.

8. In the chart, in the Category series, click Clothing. The chart highlights the figures for the Clothing
category. Click Clothing again to display the figures for every category.

9. In the Field List, in the Fields Section, in Date, select Month. This displays multiple charts, one for
each month of the year.

10. Close Windows Internet Explorer. In the Windows Internet Explorer dialog box, click Leave this
page.
L2-5

Module 2: Implementing Reports with Reporting Services


Lab 2A: Creating a Report with Report
Designer
Exercise 1: Creating a Report
 Task 1: Prepare the lab environment
1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab02A, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab02A\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd) and click Run as administrator.
5. Click Yes when prompted to confirm you want to run the command file, and wait for the script to
finish.

 Task 2: Create a Report Server project


1. Click Start, click All Programs, click Microsoft SQL Server 2012 RC0, and click SQL Server Data
Tools. Then wait for the Visual Studio environment to load.
2. In Visual Studio, on the File menu, point to New and click Project.

3. In the New Project dialog box, select Report Server Project. Then specify the following project
properties and click OK:
• Name: AWReports

• Location: D:\10778A\Labfiles\Lab02A\Starter\Ex1
• Create directory for solution: Not selected

 Task 3: Add a report to the project


1. In the Solution Explorer pane, right-click the Reports folder and click Add New Report.

Note If the Solution Explorer pane is not visible, on the View menu, click Solution
Explorer.

2. In the Welcome to the Report Wizard page of the Report Wizard, click Next.
3. In the Select the Data Source page, enter the following information and click Next:

• Name: AdventureWorksDW

• Type: Microsoft SQL Server


• Connection String: Data Source=localhost;Initial Catalog=AdventureWorksDW

• Make this a shared data source: Not selected


L2-6 Module 2: Implementing Reports with Reporting Services

4. In the Design the Query page, click Query Builder. Then in the Query Designer window, click
Import, select the Sales Query Transact-SQL script file in the D:\10778A\Labfiles\Lab02A\Starter\Ex1
folder, and click Open.

5. In the Query Designer window, on the toolbar, click Run. Then view the results of the query in the
bottom pane of the Query Designer window. This is the data for the sales report.

6. In the Query Designer window, click OK, and in the Design the Query page of the Report Wizard,
click Next.

7. In the Select the Report Type page, select Tabular and click Next.

8. In the Design the Table page, click Year, and then while holding the Ctrl key, click Month,
ProductCategory, ProductSubcategory, Product, SalesOrderNumber, OrderDate, and
SalesAmount. Then click Details to add these fields to the details group of the report, and click
Next.
9. In the Choose the Table Style page, view each of the available styles, and then select Generic and
click Next.

10. In the Completing the Wizard page, change the report name to Sales Report, and click Finish.

 Task 4: Explore and modify report properties


1. In the Report Data pane, expand Data Sources.

Note If the Report Data pane is not visible, on the View menu, click Report Data.

2. Right-click the AdventureWorksDW data source and click Data Source Properties. Then view the
properties of the data source and click Cancel.
3. In the Report Data pane, expand the Datasets folder. Then right-click Dataset1 and click Dataset
Properties.

4. In the Dataset Properties dialog box, change the dataset name to Sales, and click OK.

5. In the Report Designer, view the Row Groups pane at the bottom and note that the report contains a
single row group named table1_Details_Group. Right-click table1_Details_Group and click Group
Properties.
6. In the Group Properties dialog box, on the General tab, change the name to SalesDetails. Then
click OK.

 Task 5: Format the report


1. In the Report Designer, click the Preview tab and view the report. Note that the report contains no
formatting.
2. In the Report Designer, click the Design tab, and then click in any blank space in the Report designer
pane to ensure no report elements are selected. Note that the report contains two elements: a
textbox containing the report title, and a table containing the report data.
3. Click the textbox containing the report title (Sales Report) and use the formatting buttons on the
toolbar to increase its size to 14pt and make it bold.
Lab 2A: Creating a Report with Report Designer L2A-7

4. Click the table containing the report data, so that the gray column and row headers are displayed,
and then click the gray cell where the column headers and row headers intersect to select the table.
When the table is selected, click and drag its selection handle (a small square containing four
directional arrows) to move the table down about a centimeter.

5. Select the title textbox and resize it to ensure the title is completely visible.

6. Click the table containing the report data, so that the gray column and row headers are displayed,
and click the row header for the first row (which contains the column titles). Then use the formatting
buttons on the toolbar to make the column titles bold, change the background color to light gray,
and align the column titles to the left.

7. Click the row header for the details row and use the formatting buttons on the toolbar to align the
cells to the left.

8. Right-click the OrderDate detail cell and click Text Box Properties; and on the Number tab, select
the Date category and the 31-Jan-00 format. Then click OK.
9. Right-click the SalesAmount detail cell and click Text Box Properties; and on the Number tab,
select the Currency category, specify 2 decimal places, select Use 1000 separator, and select the
($12,345.00) format. Then click OK.
10. Drag the borders of the column headings to resize the columns so that the values in the table fit
them. Switch back and forth between the Preview and Design tabs to ensure check your work.

 Task 6: Export the report to Microsoft Excel


1. In the Report Designer, click the Preview tab and view the report.
2. On the report toolbar, click Export and click Excel. Then in the Save As dialog box, browse to the
D:\10778A\Labfiles\Lab02A\Starter\Ex1 folder and click Save.

3. Close SQL Server Data Tools, saving your work if prompted.


4. View the contents of the D:\10778A\Labfiles\Lab02A\Starter\Ex1 folder, and then double-click the
Sales Report Microsoft Excel workbook to open it in Excel.
5. View the report, and then close Excel without saving any changes.
L2-8 Module 2: Implementing Reports with Reporting Services

Exercise 2: Grouping and Aggregating Data


 Task 1: Open the AWReports project
1. View the contents of the D:\10778A\Labfiles\Lab02A\Starter\Ex2 folder, and then double-click the
AWReports Visual Studio project to open it in SQL Server Data Tools.

2. In Solution Explorer, double-click Sales Report.rdl to open it in Report Designer.

 Task 2: Delete the Year column and titles row


1. Click the table in the report so that the gray column and row headers are displayed, and then click
the column header for the Year column to select it.

2. Right-click the selected Year column header, and click Delete Columns.

3. Click the gray row heading for the first row (which contains the column titles) to select it.

4. Right-click the selected row header, and click Delete Rows.

 Task 3: Group the report by Month


1. In the Groupings pane, select the SalesDetails group.

2. Right-click the selected group, point to Add Group, and click Parent Group.
3. In the Tablix group dialog box, in the Group by list, select [Month]. Then select Add group header
and click OK.

4. Click the Preview tab to view the report and note that a new row and column have been added to
the report, and that the Month field is now displayed in both the Month group header and in the
details group.

5. Click the Design tab, and then select the column containing the Month field in the details group,
and delete it.
6. Click the Preview tab to view the report and note that the month grouping displays the data in
alphabetical order by month name (so the first month is April, followed by August, and so on).

7. Click the Design tab, and in the Row Groups section of the Report Designer, click the drop-down
arrow for the Month group, and click Group Properties.

8. In the Group Properties dialog box, on the Sorting tab, change the Sort by column to [MonthNo].
Then click OK.

9. Click the Preview tab to view the report and note that the grouping now displays in calendar month
order (so the first month is January, followed by February, and so on).

 Task 4: Add groups for Product Category, Product Subcategory, and Product
1. Click the Design tab to view the report in design view.
2. In the Row Groups section of the Report Designer, click the drop-down arrow for the SalesDetails
group, point to Add Group, and click Parent Group.

3. In the Tablix group dialog box, in the Group by list, select [ProductCategory]. Then select Add
group header and click OK.
Lab 2A: Creating a Report with Report Designer L2A-9

4. Note that a new group header containing the ProductCategory field has been created, and that the
original ProductCategory column in the detail group still exists. Then select the column containing
the ProductCategory field in the details group, and delete it.

5. Repeat the previous three steps to create groups for the [ProductSubcategory] and [Product] fields.
6. Click the Preview tab and note that some group heading columns may not be wide enough to
display the field values. Then click the Design tab and adjust column widths accordingly.

 Task 5: Add aggregate summary values


1. In the Row Groups section of the Report Designer, click the drop-down arrow for the SalesDetails
group, point to Add Total, and click Before. Note that a total for the SalesAmount field is added to
the Product group header row.

2. In the Row Groups section of the Report Designer, click the drop-down arrow for the Product
group, point to Add Total, and click Before. Note that a textbox with the heading Total and a total
for the SalesAmount field is added to the ProductSubcategory group header row.
3. Repeat the previous step for the ProductSubcategory and ProductCategory groups.

4. Click the Preview tab and note that the totals are calculated for each group.

5. Click the Design tab and click the cell in the Product group heading row immediately above the
SalesOrderNumber field. Then right-click the selected cell and click Expression.
6. In the Expression dialog box, in the Category pane, expand Common Functions and select
Aggregate. Then in the Item pane, double-click Count. Note that the expression value changes to
=Count(.

7. In the Expression dialog box, in the Category pane, select Fields (Sales) and in the Item pane ensure
<All> is selected. Then in the Values pane, double-click SalesOrderNumber. Note that the
expression value changes to =Count(Fields!SalesOrderNumber.Value.
8. Click in the textbox containing the incomplete expression value, and type ) to complete the
expression as =Count(Fields!SalesOrderNumber.Value). Then click OK.
9. Right-click the cell containing the Count expression, and click Copy.

10. Right-click the cell immediately above the Count expression and click Paste to copy the expression
to the ProductSubcategory group heading row.
11. Repeat the previous step to copy the expression to the ProductCategory and Month group heading
rows.

12. Click the Preview tab and note that the Count expression is calculated for each group.

 Task 6: Enable drilldown interactions


1. Click the Design tab to view the report in design view.
2. In the Row Groups section of the Report Designer, click the drop-down arrow for the SalesDetails
group and click Group Properties.
L2-10 Module 2: Implementing Reports with Reporting Services

3. On the Visibility tab; select Hide, select Display can be toggled by this report item, and in the
drop-down list, select Product1. Product1 is the textbox containing the Product group heading.
Then click OK.

4. Repeat the previous two steps to hide the following groups:


• Product (toggled by ProductSubcategory1)

• ProductSubcategory (toggled by ProductCategory1)

5. Click the Preview tab and note that you can expand and collapse the Product Category, Product
Subcategory, and Product groups.

 Task 7: Add page breaks


1. Click the Design tab to view the report in design view.

2. Click anywhere on the report designer surface outside of the white body of the report, then in the
Properties pane, ensure the Report object is selected.

Note If the Properties pane is not visible, on the View menu, click Properties Window.

3. Set the InitialPageName property to Sales Summary.


4. In the Row Groups section of the Report Designer, click the Month group; and in the Properties
pane, expand Group and expand PageBreak. Then set the BreakLocation property to Between.

5. With the Month group still selected, click the drop-down arrow for the PageName property and
click Expression.

6. In the Expression dialog box, in the Category pane, select Fields (Sales); in the Item pane ensure
<All> is selected, and in the Values pane, double-click Month. Verify that the expression matches the
code sample below, and then click OK.

=Fields!Month.Value

7. In the Properties pane, in the drop-down list select the table1 Tablix object. Then expand
PageBreak and set the BreakLocation property to Start.
8. Click the Preview tab and note that the first page of the report contains only the report title. Then
use the page navigation buttons to scroll through the pages of the report, noting that each month
starts on a new page.
9. On the report toolbar, click Export and click Excel. Then in the Save As dialog box, browse to the
D:\10778A\Labfiles\Lab02A\Starter\Ex2 folder and click Save.

10. Close Visual Studio, saving your work if prompted.


11. View the contents of the D:\10778A\Labfiles\Lab02A\Starter\Ex2 folder, and then double-click the
Sales Report Microsoft Excel workbook to open it in Excel.

12. View the report, noting that the first sheet in the workbook is named Sales Summary, and that there
is an additional sheet for each month’s sales.
13. Click the January sheet and note that you can expand and collapse the Product Category, Product
Subcategory, and Product groups in Excel. Then close Excel without saving any changes.
L2-11

Module 2: Implementing Reports with Reporting Services


Lab 2B: Enhancing and Publishing a Report
Exercise 1: Adding a Chart to a Report
 Task 1: Prepare the lab environment
1. Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab02B, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab02B\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd) and click Run as administrator.
5. Click Yes when prompted to confirm you want to run the command file, and wait for the script to
finish.

 Task 2: Open the AWReports project


1. View the contents of the D:\10778A\Labfiles\Lab02B\Starter\Ex1 folder, and then double-click the
AWReports Visual Studio project to open it in Visual Studio.
2. In Solution Explorer, double-click Sales Report.rdl to open it in Report Designer.

 Task 3: Add a Chart report item


1. Click the table containing the report data, so that the gray column and row headers are displayed,
and then click the gray cell where the column headers and row headers intersect to select the table.
When the table is selected, click and drag its selection handle to move the table down about 10
centimeters.
2. In the toolbox, click and drag the Chart component to the space you have created above the table.

Note If the toolbox is not visible, on the View menu, click Toolbox.

3. In the Select Chart Type dialog box, select the 3D Clustered Column chart type. Then click OK.

Note Point the mouse over the chart icons to display a tooltip with name of the chart
type.

4. Use the resize handles and selection handles to fit the chart into the space created when you moved
the table.
L2-12 Module 2: Implementing Reports with Reporting Services

 Task 4: Specify the data for the chart


1. Click the chart area to select it, and then click inside the chart again to display the Chart Data editing
pane.

2. In the Chart Data editing pane, in the Values section, click the Add field button (a yellow plus
symbol) and click SalesAmount.
3. In the Category Groups section, click the drop-down button for the (Details) group and click
Month. Then in the Category Groups section, click the drop-down button for Month and click
Category Group Properties.

4. In the Category Group Properties dialog box, on the Sorting tab, in the Sort by drop-down list,
select MonthNo. Then click OK.

5. In the Chart Data editing pane, in the Series Groups section, click the Add field button and click
ProductCategory.

 Task 5: Format the chart


1. Click the chart area to select it, and then right-click inside the chart area again and click Chart
Properties.
2. In the Chart Properties dialog box, in the Color palette drop-down list, select Semi transparent.
Then click OK.

3. Right-click the Chart Title text box and click Delete Title.
4. Right-click the vertical axis title and clear the Show Axis Title checkmark.

5. Repeat the previous step to remove the horizontal axis title.


6. Right-click any of the numbers in the vertical axis and click Vertical Axis Properties.

7. In the Vertical Axis Properties dialog box, in the Number tab, select Currency. Then select Use
1000 separator and click OK.

8. Click the Preview tab and note that the first page of the report contains the chart.
9. On the report toolbar, click Export and click Excel. Then in the Save As dialog box, browse to the
D:\10778A\Labfiles\Lab02B\Starter\Ex1 folder and click Save.

10. Close Visual Studio, saving your work if prompted.


11. View the contents of the D:\10778A\Labfiles\Lab02B\Starter\Ex1 folder, and then double-click the
Sales Report Microsoft Excel workbook to open it in Excel.

12. View the report, noting that the first sheet in the workbook contains the chart as an image. Then
close Excel without saving any changes.
Lab 2B: Enhancing and Publishing a Report L2-13

Exercise 2: Adding Parameters to a Report


 Task 1: Open the AWReports project
1. View the contents of the D:\10778A\Labfiles\Lab02B\Starter\Ex2 folder, and then double-click the
AWReports Visual Studio project to open it in Visual Studio.

2. In Solution Explorer, double-click Sales Report.rdl to open it in Report Designer.

 Task 2: Add a parameter


1. In the Report Data pane, expand the Datasets folder. Then right-click Sales and click Dataset
Properties.

2. In the Dataset Properties dialog box, under the Query textbox, click Import and browse to
D:\10778A\Labfiles\Lab02B\Starter\Ex2. Then select Parameterized Sales Query and click Open.

Note The new query is exactly the same as before except for the addition of a WHERE
clause that includes a @Year parameter.

3. In the Dataset Properties dialog box, click OK.

4. In the Report Data pane, expand Parameters and then right-click the Year parameter and click
Parameter Properties.
5. On the General tab, in the data type drop-down list, select Integer, and select Allow multiple
values. Then click OK.

6. In the Report Data pane, right-click the Sales dataset and click Dataset Properties; and then on the
Parameters tab, note that the @Year dataset parameter is mapped to the @Year report parameter.
Then click Cancel.

7. Right-click the report title (Sales Report) and click Expression.


8. In the Expression dialog box, in the Set expression for: Value box, change the expression to the
following code and then click OK:

="Sales Report for " & Join(Parameters!Year.Value, ", ")

9. Click the Preview tab.

10. In the Year drop down list, type 2003. Then click View Report. The sales for 2003 are included in the
report.

11. In the Year drop down list, after 2003 insert a new line and type 2004. Then click View Report. The
sales for 2003 and 2004 are included in the report.

 Task 3: Configure available and default values for a parameter


1. Click the Design tab to view the report in design view.

2. In the Report Data pane, right-click the Datasets folder, and click Add Dataset.

3. In the Dataset Properties dialog box, change the Name to SalesYears, and select Use a dataset
embedded in my report.
L2-14 Module 2: Implementing Reports with Reporting Services

4. In the Data source drop-down list, select AdventureWorksDW. Then under the Query textbox, click
Import, browse to D:\10778A\Labfiles\Lab02B\Starter\Ex2, select Sales Years, and click Open.

5. View the query, noting that it returns all years for which there have been Internet sales, and then in
the Dataset Properties dialog box, click OK.
6. In the Report Data pane, right-click the Datasets folder, and click Add Dataset.

7. In the Dataset Properties dialog box, change the Name to MaxYear, and select Use a dataset
embedded in my report.

8. In the Data source drop-down list, select AdventureWorksDW. Then under the Query textbox, click
Import, browse to D:\10778A\Labfiles\Lab02B\Starter\Ex2, select Max Year, and click Open.
9. View the query, noting that it returns the year of the most recent Internet sales order, and then in the
Dataset Properties dialog box, click OK.

10. In the Report Data pane, expand Parameters and then right-click the Year parameter and click
Parameter Properties.

11. In the Parameter Properties dialog box, in the Available Values tab, select Get values from a
query. Then in the Dataset drop-down list, select SalesYears; in the Value field drop-down list,
select Year; and in the Label field drop-down list, select Year.
12. In the Parameter Properties dialog box, in the Default Values tab, select Get values from a query.
Then in the Dataset drop-down list, select MaxYear; and in the Value field drop-down list, select
MaxYear. Then click OK.
13. Click the Preview tab, and note that the report is displayed using the default parameter value for the
most recent year (which is 2004).
14. Click the Year drop-down list and note that it contains a list of years for which there have been sales.

15. Close Visual Studio, saving your work if prompted.


Lab 2B: Enhancing and Publishing a Report L2-15

Exercise 3: Publishing a Report


 Task 1: Open the AWReports project
1. View the contents of the D:\10778A\Labfiles\Lab02B\Starter\Ex3 folder, and then double-click the
AWReports Visual Studio project to open it in Visual Studio.

2. In Solution Explorer, double-click Sales Report.rdl to open it in Report Designer.

 Task 2: Configure deployment properties


1. In the Solution Explorer pane, right-click AWReports and click Properties.

2. In the AWReports Property Pages dialog box, set the following property values, and then click OK:
• OverwriteDatasets: True

• OverwriteDataSources: True

• TargetDatasetFolder: http://mia-sqlbi/Reports/Datasets
• TargetDataSourceFolder: http://mia-sqlbi/Reports/Data Sources

• TargetReportFolder: http://mia-sqlbi/Reports
• TargetReportPartFolder: http://mia-sqlbi/Reports/Report Parts
• TargetServerURL: http://mia-sqlbi

• TargetServerVersion: SQL Server 2008 R2 or later

 Task 3: Deploy the AWReports project


1. On the Build menu, click Deploy AWReports.
2. When deployment has succeeded, close Visual Studio, saving your changes if prompted. Then start
Internet Explorer and view the SharePoint site at http://mia-sqlbi.

3. In the Quick Launch area, under Libraries, click Reports.


4. In the Reports library, click Sales Report and note that the report is displayed with the default
parameter value.
5. On the Actions menu, point to Export and click Excel.

6. When prompted, click Save, and save the report as Sales_Report.xlsx in the
D:\10778A\Labfiles\Lab02B\Starter\Ex3 folder.

Note The export process can take a minute or so.

7. Wait for the file to be downloaded, then when the download is complete, click Open.

8. View the report in Excel, and then close Excel.

9. Close Internet Explorer.


L2-16 Module 2: Implementing Reports with Reporting Services

Optional Exercise: Using Data Bars and Sparklines


 Task 1: Open the AWReports project
1. View the contents of the D:\10778A\Labfiles\Lab02B\Starter\Opt1 folder, and then double-click the
AWReports Visual Studio project to open it in SQL Server Data Tools.

2. In Solution Explorer, double-click Sales Trends.rdl to open it in Report Designer.

3. Click the Preview tab and view the report, noting that it shows sales in a specified year broken down
by category and month.

 Task 2: Add a data bar


1. Click the Design tab.

2. In the tablix data region, click the cell to the right of the cell containing the [ProductCategory] field
and above the cell containing the [EnglishMonthName] field, and type Sales Volume: Then format
the Sales Volume: cell as italic.

3. .In the toolbox, drag a Data Bar item and drop it in the cell to the right of the Sales Volume cell.
Then, in the Select Data Bar Type dialog box, select the first style in the Data Bar section (Bar) and
click OK.

4. Click the data bar you just added to display the Chart Data pane, and then in the Values section, add
the SalesAmount field.
5. In the Chart Data pane, in the Values section, click the drop-down arrow next to the SalesAmount
field and click Series Properties. Then, in the Series Properties dialog box, on the Fill tab, set the
following options and click OK.
• Fill style: Gradient

• Color: Light Steel Blue


• Secondary color: Cornflower Blue
• Gradient Style: Left right

6. In the Chart Data pane, in the Values section, click the drop-down arrow next to the SalesAmount
field and click Horizontal Axis Properties. Then, in the Horizontal Axis Properties dialog box,
verify that the Align axes in checkbox is checked and table1 is selected, and click OK.

7. Click the report design surface to hide the Chart Data pane, and then click the cell containing the
data bar to select it. Then, in the toolbar, click the border drop-down list and select No Border.

8. Click the Preview tab and verify that your report shows a data bar that indicates the relative sales
volume for each product category.

 Task 3: Add a spark line


1. Click the Design tab.
2. In the tablix data region, click the cell to the right of the cell containing the data bar, and type
Monthly Trend:. Then format the Monthly Trend cell as italic.

3. In the toolbox, drag a Sparkline item and drop it in the cell to the right of the Monthly Trend cell.
Then, in the Select Sparkline Type dialog box, select the second style in the Area section (Smooth
Area) and click OK.
Lab 2B: Enhancing and Publishing a Report L2-17

4. Click the sparkline you just added to display the Chart Data pane, and then in the Values section, add
the SalesAmount field. Then in the Category Groups section, click the drop-down arrow for the
Details group and select MonthNumberOfYear.

5. In the Chart Data pane, in the Values section, click the drop-down arrow next to the SalesAmount
field and click Series Properties. Then, in the Series Properties dialog box, on the Fill tab, set the
following options and click OK:
• Fill style: Gradient

• Color: Light Steel Blue

• Secondary color: Cornflower Blue


• Gradient Style: Top bottom

6. In the Chart Data pane, in the Values section, click the drop-down arrow next to the SalesAmount
field and click Horizontal Axis Properties. Then, in the Horizontal Axis Properties dialog box,
check Align axes in, ensure table1 is selected, and click OK.
7. In the Chart Data pane, in the Values section, click the drop-down arrow next to the SalesAmount
field and click Vertical Axis Properties. Then, in the Vertical Axis Properties dialog box, check
Align axes in, ensure table1 is selected, and click OK.
8. Click the report design surface to hide the Chart Data pane, and then click the cell containing the
sparkline to select it. Then, in the toolbar, click the border drop-down list and select No Border.
9. Click the Preview tab and verify that your report shows a sparkline that indicates the relative monthly
sales volume for each product category.

10. Close SQL Server Data Tools.


L2-18 Module 2: Implementing Reports with Reporting Services

Optional Exercise: Using a Map


 Task 1: Open the AWReports project
1. View the contents of the D:\10778A\Labfiles\Lab02B\Starter\Opt2 folder, and then double-click the
AWReports Visual Studio project to open it in SQL Server Data Tools.

2. In Solution Explorer, double-click US Sales By State.rdl to open it in Report Designer.

3. Click the Preview tab and view the report, noting that it shows sales in a specified year for each state.

 Task 2: Add a map


1. Click the Design tab.

2. In the toolbox, drag a Map item and drop it in the report body to the right of the existing tablix data
region. Then complete the New Map Layer wizard using the following settings:
• On the Choose a source of spatial data, ensure Map gallery is selected and in the Map Gallery
pane, select USA by State Insert. Then click Next.

• On the Choose spatial data and map view options page, review the default settings and click
Next.
• On the Choose map visualization page, select Color Analytical Map and click Next.

• On the Choose the analytical dataset page, select Sales and click Next.

• On the Specify the match fields for spatial and analytical data page, select the checkbox for
the STATENAME field, and in the Analytical Data Fields column, select StateProvinceName.
Then click Next.

• On the Choose color theme and data visualization page, in the Theme drop-down list, select
Ocean; in the Field to visualize drop-down list, select [Sum(SalesTotal)]; and in the Color rule
drop-down list, select White-Blue. Then click Finish.

 Task 3: Format the map


1. Click the map to display the Map Layers pane is displayed (you might need to scroll to the right to
see the Map Layers pane). Then, in the Map Layers pane, click the drop-down arrow for the
PolygonLayer1 layer and click Polygon Properties.
2. In the Map Polygon Properties dialog box, on the General tab, in the Tooltip drop-down list, select
[Sum(SalesTotal)]. Then click OK.

3. In the Map Layers pane, click the drop-down arrow for the PolygonLayer1 layer and click Polygon
Color Rule.
4. In the Map Color Rules Properties dialog box:

a. On the General tab, note that the data is visualized by using color ranges from white to blue.
Then, on the Distribution tab, set the Number of subranges to 10 and the Range start to 0,
and then click OK.

b. Right-click the Title text box above the legend, and click Legend Title Properties. Then in the
Map Legend Title Properties dialog box, change the title text to Sales ($) and click OK.
Lab 2B: Enhancing and Publishing a Report L2-19

c. Right-click the Map Title textbox and click Title Properties. Then in the Map Title Properties
dialog box, change the title text to Sales by State and click OK.

d. Right-click the color scale at the bottom left of the map and deselect the Show Color Scale
option.
5. Click the Preview tab and view the report, verifying that the map indicates sales volume in each state
by the shade of the color used to fill the state.

6. Point the mouse to any state that has a blue fill color and verify that the tooltip displayed shows the
sales figure for that state.

7. Close SQL Server Data Tools.


L2-20 Module 2: Implementing Reports with Reporting Services
L3-21

Module 3: Supporting Self-Service Reporting


Lab 3: Implementing Self Service Reporting
Exercise 1: Using Report Builder
 Task 1: Prepare the lab environment
1. Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running. Then log on to MIA-SQLBI as
ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab03, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab03\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd) and click Run as administrator.
5. Click Yes when prompted to confirm you want to run the command file, and wait for the script to
finish.

 Task 2: Install Report Builder


1. On the Start menu, click Internet Explorer and open the SharePoint portal site at http://mia-sqlbi.
2. In the Quick Launch area, under Libraries, click Reports.

3. In the ribbon, on the Documents tab, in the New Document drop-down list, click Report Builder
Report. If you are prompted, click Run, and wait for Report Builder to be downloaded. The
application starts automatically after it has been downloaded.

 Task 3: Create a report


1. In the Getting Started dialog box, ensure that New Report is selected and click Table or Matrix
Wizard.
2. On the Choose a dataset page, ensure Create a dataset is selected, and click Next.

3. On the Choose a connection to a data source page, click New, and in the Data Source Properties
dialog box, create a data source with the following settings and click OK. Then click Next.

• On the General tab, change the Name property to AdventureWorksDW, ensure that the
Microsoft SQL Server connection type is selected, and enter the following connection string:

Data source=localhost;Initial Catalog=AdventureWorksDW

• On the Credentials tab, ensure that the Use current Windows user. Kerberos delegation
might be required option is selected.
4. On the Design a query page, in the Database view pane, expand Tables, expand the
DimProductCategory, DimProductSubcategory, DimProduct, DimGeography, DimReseller, and
FactResellerSales tables, and select the following fields:
• DimProductCategory.EnglishProductCategoryName

• DimProductSubcategory.ProductCategoryKey
L3-22 Module 3: Supporting Self-Service Reporting

• DimProduct.ProductSubcategoryKey

• DimGeography.EnglishCountryRegionName

• DimGeography.StateProvinceName

• DimGeography.City

• DimReseller.GeographyKey

• FactResellerSales.ResellerKey

• FactResellerSales.SalesAmount

5. After you have selected the fields, expand the Relationships pane and review the relationships that
have been automatically detected. Then click Next.
6. On the Arrange fields page, drag and drop the fields to the following groups and then click Next:

• Row groups:

EnglishCountryRegionName

StateProvinceName

City

• Column groups:

EnglishProductCategoryName
• Values:

SalesAmount
7. On the Choose the layout page, ensure that Show subtotals and grand totals, Blocked, subtotal
below, and Expand/collapse groups are all selected, and then click Next.

8. On the Choose a style page, in the Styles list, select Generic. Then click Finish.

 Task 4: Format the report


1. Click the Click to add title textbox, and type Reseller Sales by Product Category.
2. Click the cell containing the expression [Sum(SalesAmount)] directly beneath the
[EnglishProductCategoryName] cell, and then hold the Shift key and click the
[Sum(SalesAmount)] field at the bottom right of the tablix data region to select all of the
[Sum(SalesAmount)] cells. Then on the toolbar, click the currency ($) format button.

3. Click the Run button to preview the report, and then click the Design button to return to design view
and apply any additional formatting you think is appropriate.
Lab 3: Implementing Self Service Reporting L3-23

 Task 5: Publish the report


1. In the quick access toolbar, click Save. Then in the Save As Report dialog box, browse to the
http://mia-sqlbi/Reports folder, in the Name box type Reseller Sales by Product Category.rdl, and
click Save.

2. Close Report Builder.


3. In Internet Explorer, in the Quick Launch area of the http://mia-sqlbi SharePoint site, under Libraries,
click Reports to refresh the view and note that the Reseller Sales by Product Category report has
been published in the Reports document library.

4. Click Reseller Sales by Product Category and view the report.

5. After you have viewed the report, at the top of the page, click the Reports link to return to the
Reports document library. Keep Internet Explorer open for the next exercise.
L3-24 Module 3: Supporting Self-Service Reporting

Exercise 2: Simplifying Data Access for Business Users


 Task 1: Create a shared data source
1. In the ribbon, on the Documents tab, in the New Document drop-down list, click Report Data
Source.

2. In the Data Source Properties page, configure a data source with the following settings and click
OK:
• Name: Adventure Works Data Warehouse

• Data Source Type: Microsoft SQL Server

• Connection string: Data source=localhost;Initial Catalog=AdventureWorksDW


• Credentials: Windows authentication (integrated) or SharePoint user

• Availability: Enable this data source selected

 Task 2: Create shared datasets


1. In the ribbon, on the Documents tab, in the New Document drop-down list, click Report Builder
Report.
2. When Report Builder starts, in the Getting Started dialog box, select New Dataset.

3. In the Getting Started dialog box, click Browse other data sources and browse to the
http://mia-sqlbi/Reports folder. Then select the Adventure Works Data Warehouse.rsds shared
data source you created in the previous task and click Open.

4. In the Getting Started dialog box, ensure that the Adventure Works Data Warehouse.rds data
source is selected, and click Create.
5. On the ribbon, in the Query Designer section, click Import. Then browse to the
D:\10778A\Labfiles\Lab03\Starter folder, select Reseller Sales By Year.sql, and click Open.
6. Expand the query pane so you can see the Transact-SQL query, and note that the query includes a
parameter named @CalendarYear.

7. On the ribbon, click Set Options, and then in the Shared Dataset Properties dialog box, on the
Parameters tab, set the data type of the @CalendarYear parameter to Integer and select the Allow
multiple values checkbox. Then click OK.

8. On the ribbon, click the Run button, enter the parameter value 2004, and click OK. When the query
has completed, review the results, which show reseller sales for the year 2004.

9. In the quick access toolbar, click Save. Then in the Save As Dataset dialog box, browse to the
http://mia-sqlbi/Reports folder, in the Name box type Reseller Sales by Year.rsd, and save the
dataset.

10. Click the round button at the top left of the ribbon, and on the Report Builder menu, click New.
Then in the New Report or Dataset dialog box, select New Dataset, select the Adventure Works
Data Warehouse.rsds dataset, and click Create.

11. On the ribbon, in the Query Designer section, click Import. Then browse to the
D:\10778A\Labfiles\Lab03\Starter folder, select Reseller Years.sql, and click Open.
Lab 3: Implementing Self Service Reporting L3-25

12. On the ribbon, click the Run button. When the query has completed, review the results, which show
all years in which there have been any reseller sales.

13. In the quick access toolbar, click Save. Then in the Save As Dataset dialog box, browse to the
http://mia-sqlbi/Reports folder, in the Name box type Reseller Years.rsd, and save the dataset.
14. Repeat the previous four steps to create a new dataset from the Most Recent Reseller Year.sql
query file and save it in the http://mia-sqlbi/Reports folder as Most Recent Reseller Year.rsd.

 Task 3: Create a report from shared data items


1. Click the round button at the top left of the ribbon, and on the Report Builder menu, click New.
Then in the New Report or Dataset dialog box, select New Report and click Table or Matrix
Wizard.

2. On the Choose a dataset page, select Choose an existing dataset in this report or a shared
dataset, click Browse and in the http://mia-sqlbi/Reports folder, click Reseller Sales by Year.rsd and
click Open. Then click Next.
3. On the Arrange fields page, drag and drop the fields to the following groups and then click Next.

• Row groups

CalendarYear
Month

• Column groups

ProductCategory

• Values

SalesAmount

4. On the Choose the layout page, ensure that Show subtotals and grand totals, Blocked, subtotal
below, and Expand/collapse groups are all selected, and then click Next.

5. On the Choose a style page, in the Styles list, select Generic. Then click Finish.

6. In the Report Data pane, right-click the Datasets folder and click Add Dataset. Then add a dataset
with the following settings and click OK:
• Name: Years

• Use a shared dataset: Selected


• Dataset: Browse to the http://mia-sqlbi/Reports folder and select the Reseller Years.rsd dataset.

7. In the Report Data pane, right-click the Datasets folder and click Add Dataset again. Then add a
dataset with the following settings and click OK:

• Name: MostRecentYear
• Use a shared dataset: Selected

• Dataset: Browse to the http://mia-sqlbi/Reports folder and select the Most Recent Reseller
Year.rsd dataset.
L3-26 Module 3: Supporting Self-Service Reporting

8. In the Report Data pane, expand the Parameters folder and then right-click the CalendarYear
parameter and click Parameter Properties. Then, in the Report Parameter Properties dialog box,
make the following configuration changes and click OK.

• On the Available Values tab, select Get values from a query. Then in the Dataset drop-down
list, select Years; in the Value field drop-down list, select CalendarYear; and in the Label field
drop-down list, select CalendarYear.
• On the Default Values tab, select Get values from a query. Then in the Dataset drop-down list,
select MostRecentYear and in the Value field drop-down list, select CalendarYear.

9. Click the Click to add title textbox and type Reseller Sales by Year. Then format the cells in the
tablix data region as you think appropriate.

10. In the Groupings pane, in the Month group drop-down list, click Group Properties. Then on the
Sorting tab, change the Sort by field to MonthNo so that the months are sorted in calendar order,
and click OK.

11. Click Run the preview the report. Note that sales for the most recent year (2004) are shown by
default, but you can change the year to any of the available years.

12. In the quick access toolbar, click Save. Then in the Save As Report dialog box, browse to the
http://mia-sqlbi/Reports folder, in the Name box type Reseller Sales by Year.rdl, and click Save.
Lab 3: Implementing Self Service Reporting L3-27

Exercise 3: Using Report Parts


 Task 1: Create a report part
1. Click the round button at the top left of the ribbon, and on the Report Builder menu, click New.
Then in the New Report or Dataset dialog box, select New Report and click Chart Wizard.

2. On the Choose a dataset page, select Create a dataset and click Next.

3. On the Choose a connection to a data source page, select the Adventure Works Data
Warehouse.rsds shared data source and click Next.

4. On the Design a query page, click Import and browse to the D:\10778A\Labfiles\Lab03\Starter
folder, select Count Resellers by Country.sql, and click Open. Then on the toolbar, click the Run
button to verify that the query returns a list of countries with the number of resellers in each country,
and click Next.

5. On the Choose a chart type page, select Pie, and click Next.
6. On the Arrange chart fields page, drag Country to the Categories list, and drag Resellers to the
Values list. Then click Next.

7. On the Choose a style page, select Generic, and then click Finish.

8. When the report has been created, click the Chart Title text box and then select the text and change
it to Resellers by Country. Then resize the chart to make it bigger.

9. With the chart selected, on the View tab of the ribbon, select Properties. Then in the Properties
pane, change the Name property of the chart to ResellersChart.
10. In the Report Data pane, expand Datasets, right-click DataSet1 and click Dataset Properties. Then
in the Dataset Properties dialog box, change the Name property to ResellersByCountry and click
OK.
11. Click the round button at the top left of the ribbon, and on the Report Builder menu, click Publish
Report Parts, and in the Choose Sharepoint Document Library dialog box, select the Reports
document library and click OK. Then on the Publish Report parts dialog box, click Review and
modify report parts before publishing.

12. In the Publish Report Parts dialog box, expand ResellersChart and in the description box, type
Chart showing the number of resellers in each country. Then click Publish, and when the Result
message shows that a report part was published successfully, click Close.

 Task 2: Use a report part


1. Click the round button at the top left of the ribbon, and on the Report Builder menu, click New.
When prompted to save the current report, click No. Then in the New Report or Dataset dialog box,
select New Report and click Blank Report.

2. In the ribbon, on the Insert tab, click Report Parts.

3. In the Report Part Gallery pane, in the search box type Resellers and click the search button. Note
that the ResellersChart report part you published in the previous task is listed in the results.

4. Drag the ResellersChart report part to the body of the report.

5. Right-click the chart title, point to Chart, and click Chart Properties. Then in the Chart properties
dialog box, in the Color palette drop-down list, select Semi transparent and click OK.
L3-28 Module 3: Supporting Self-Service Reporting

6. Click the Click to add title textbox and type Resellers By Country - Pie Chart.

7. On the Home tab, click Run to preview the report and note that the report part is shown with the
semi-transparent color palette in this report.
8. In the quick access toolbar, click Save. Then in the Save As Report dialog box, browse to the
http://mia-sqlbi/Reports folder, in the Name box type Resellers By Country - Pie Chart.rdl, and
click Save.

9. Click the round button at the top left of the ribbon, and on the Report Builder menu, click New.
Then in the New Report or Dataset dialog box, select New Report and click Blank Report.

10. Drag the ResellersChart report part from the Report Parts Gallery pane to the body of the report.
11. Right-click the chart title, point to Chart, and click Change Chart Type. Then in the Select Chart
Type dialog box, select the first chart in the Column section and click OK.

12. Click the Click to add title textbox and type Resellers By Country - Column Chart. Then delete the
axis titles from the chart.

13. Click Run to preview the report and note that the report part is shown as a column chart in this
report.
14. In the quick access toolbar, click Save. Then in the Save As Report dialog box, browse to the
http://mia-sqlbi/Reports folder, in the Name box type Resellers By Country - Column Chart.rdl,
and click Save.
15. Close Report Builder and Internet Explorer.
L4-29

Module 4: Managing a Reporting Infrastructure


Lab 4: Configuring Report Execution and
Delivery
Exercise 1: Configuring Report Execution
 Task 1: Prepare the lab environment
1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running. Then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab04, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab04\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd) and click Run as administrator.
5. Click Yes when prompted to confirm you want to run the command file, and wait for the script to
finish.

 Task 2: Deploy reports


1. In the D:\10778A\Labfiles\Lab04\Starter folder, double-click AWReports.sln to open the solution in
SQL Server Data Tools. Note that the project contains a shared data source named
AdventureWorksDW and a report named Monthly Sales Report.

2. In Solution Explorer, right-click AWReports and click Properties. Then, in the AWReports Property
Pages dialog box, note the deployment properties and click OK.

3. On the Build menu, click Deploy AWReports. Then wait for the Output pane to display the message
Deploy complete – 0 errors, 0 warnings, and close SQL Server Data Tools.

 Task 3: Configure a shared data source


1. Start Internet Explorer and browse to SharePoint site at http://mia-sqlbi. Then, in the quick launch
area, under Libraries, click Reports.

2. In the Reports document library, note that the AdventureWorksDW data source and Monthly
Sales Report report have been deployed, and on the drop-down list for the AdventureWorksDW
data source, click View Dependent Items and note that the Monthly Sales Report report has a
dependency on this data source. Then click Close.

3. On the drop-down list for the AdventureWorksDW data source, click Edit Data Source Definition,
and in the Credentials section of the configuration page, note that the data source is currently
configured to use the Windows authentication (Integrated) or SharePoint user option.

4. In the Credentials section, select the Stored credentials option and enter the following credentials:
• User Name: ADVENTUREWORKS\ServiceAcct

• Password: Pa$$w0rd
5. Select Use as Windows credentials and click Text Connection. Then when the connection has been
tested successfully, click OK.
L4-30 Module 4: Managing a Reporting Infrastructure

 Task 4: Configure a report


1. In the Reports document library, on the drop-down menu for the Monthly Sales Report report, click
Manage Processing Options.

2. In the Data Refresh Options section, select the Use cached data option, and then in the Cache
Options section, select On a custom schedule and click Configure.
3. In the Frequency section, select Day, in the Schedule section select all of the days and set the Start
time to 12:00 am, and click OK. Then click OK again to set the processing options and return to the
Reports document library.

4. Click Monthly Sales Report and wait while the report is rendered. Then note the execution date and
time under the report heading.

5. At the top of the report page, click the Reports link to return to return to the Reports document
library, and then click Monthly Sales Report again. Note that the execution date and time have not
changed because the report has been cached.
6. Keep the report open for the next exercise.
Lab 4: Configuring Report Execution and Delivery L4-31

Exercise 2: Implementing a Standard Subscription


 Task 1: Subscribe to a report
1. With the Monthly Sales Report report displayed in the browser, on the Actions menu, click
Subscribe.

2. In the Delivery Extension drop-down list, ensure E-Mail is selected.

3. In the Delivery Options section, enter the following options:

• To: student@adventureworks.msft

• Comment: The sales report is attached.

4. In the Report Contents section, ensure that Show report inside message is selected and in the
Format drop-down list, select Excel.

5. In the Delivery Event section, ensure that On a custom schedule is selected and click Configure.
Then define a custom schedule that will send the report every day in two minutes from the current
time and click OK. You can determine the current system time by starting a command prompt
window and entering the command time /T.

6. In the Parameters section, ensure that Use Report Default Value is selected. Then click OK.

 Task 2: Verify the subscription


1. At the top of the report page, click the Reports link to return to return to the Reports document
library.

2. In the drop-down list for the Monthly Sales Report report, click Manage Subscriptions. Then view
the information about the E-Mail subscription you created in the previous task.

3. Wait two minutes and then refresh the page. The Last Results column should indicate that mail was
sent to student@adventureworks.msft.
4. View the contents of the C:\inetpub\mailroot\Drop folder and note the email messages that have
been received by the local SMTP server.

5. Double-click the most recent message to open it with Microsoft Outlook, and read the email
message. Then open the attached Monthly Sales Report.xlsx Excel file and view the report.

6. Close Excel and the e-mail message.

7. In Internet Explorer, click Close to return to the Reports document library.


L4-32 Module 4: Managing a Reporting Infrastructure

Exercise 3: Implementing a Data-Driven Subscription


 Task 1: Create a table of subscription data
1. In the D:\10778A\Labfiles\Lab04\Starter folder, double-click Subscription Table.sql to open it in SQL
Server Management Studio. Each time you are prompted, use Windows authentication to connect to
the database engine on the localhost server.

2. View the Transact-SQL code and note that it creates and populates a table named
ReportSubscriptions, which contains the following columns:

• SubscriptionID – a unique primary key

• RecipientEmail – the email address of a subscription recipient

• ReportFormat – the format in which the report should be rendered

• Linked – a Boolean value that indicates whether the subscription email should include a link to
the report on the report server
3. Click Execute to run the query. Then when it has completed, close SQL Server Management Studio.

 Task 2: Create a data-driven subscription


1. In Internet Explorer, in the Reports document library in the http://mia-sqlbi SharePoint site, in the
drop-down list for the Monthly Sales Report report, click Manage Subscriptions.
2. Click Add Data-Driven Subscription.

3. In the Description text box, type Weekly Sales Report.

4. In the Connection Type section, select Shared data source.


5. In the Data Source Link section, click the ellipsis (…) button, and then in the Select an Item dialog
box, select the AdventureWorksDW data source and click OK.

6. In the Query section, type the following query and click Validate. When the query is validated
successfully, click Next.

SELECT * FROM ReportSubscriptions

7. In the Calendar Year section, ensure that Use report default value is selected, and click Next.

8. In the Delivery Type section, ensure that E-Mail is selected Then set the following configuration
values and click Next.

• To: Select a value from the database (select RecipientEmail)

• Include Report: True


• Render Format: Select a value from the database (select ReportFormat)

• Subject: Specify a static value (enter Weekly sales report)

• Comment: Specify a static value (enter The weekly sales report is attached)

• Include Link: Select a value from the database (select Linked)


9. In the Delivery Event section, ensure that On a custom schedule is selected.
Lab 4: Configuring Report Execution and Delivery L4-33

10. In the Frequency section, select Day.

11. In the Schedule section, select the current day and enter a time that is two minutes later than the
current time. You can determine the current system time by starting a command prompt window and
entering the commands and time /T. You can also use the command echo %date% to determine the
current day and date.

12. Click Finish and view the subscription details.

 Task 3: Verify the subscription


1. Wait for two minutes and then refresh the page. When the subscription has been processed, the Last
Results column should contain the message Done: 3 processed of 3 total; 0 errors.

2. View the contents of the C:\inetpub\mailroot\Drop folder and note the email messages that have
been received by the local SMTP server.
3. Open the three most recent messages, and verify that the report has been sent in Excel, Word, and
embedded HTML formats.

4. Close all attachments, email messages, and folder windows. Then close Internet Explorer.
L4-34 Module 4: Managing a Reporting Infrastructure
L5-35

Module 5: Creating Multidimensional Databases


Lab 5: Creating a Multidimensional
Database
Exercise 1: Creating a Data Source
 Task 1: Prepare the lab environment
1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab05, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab05\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd), and then click Run as
administrator.
5. Click Yes when prompted to confirm that you want to run the command file, and then wait for the
script to finish.

 Task 2: Create a new SSAS project


1. Click Start, point to All Programs, click Microsoft SQL Server 2012, and then click SQL Server Data
Tools.

2. On the File menu, point to New, and then click Project.

3. In the Templates pane, click Analysis Services Multidimensional and Data Mining Project.
4. Change the value in the Name box to Adventure Works OLAP.

5. Click Browse, browse to the D:\10778A\Labfiles\Lab05\Starter folder, and then click Select Folder.

6. Click OK.

 Task 3: Create a data source for the AdventureWorksDW relational database


1. In Solution Explorer, right-click the Data Sources folder, and then click New Data Source.

2. On the Welcome to the Data Source Wizard page, click Next.


3. On the Select how to define the connection page, click New.

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.

7. On the Select how to define the connection page, click Next.


L5-36 Module 5: Creating Multidimensional Databases

8. On the Impersonation Information page, select Use a specific Windows user name and
password.

9. In the User name box, type ADVENTUREWORKS\Student.


10. In the Password box, type Pa$$w0rd, and then click Next.

11. On the Completing the Wizard page, change the data source name to Adventure Works Data
Warehouse, and then click Finish.
Lab 5: Creating a Multidimensional Database L5-37

Exercise 2: Creating and Modifying a Data Source View


 Task 1: Create a data source view
1. In Solution Explorer, right-click the Data Source Views folder, 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, 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), and FactInternetSales (dbo).

5. On the Select Tables and Views page, click the > button to add the selected tables to the Included
objects list, and then click Next.

6. On the Completing the Wizard page, change the name of the data source view to Adventure
Works DSV, and then click Finish.

Notice that the Data Source View Designer opens automatically after you click Finish.

 Task 2: Modify the data source view


1. In the Data Source View Designer, use the Zoom icon to change the zoom level to 50%.
2. In the Diagram pane, click the FactInternetSales table.

3. In the Properties pane, in the FriendlyName box, type InternetSales.

4. In the Diagram pane, click the DimCustomer table.


5. In the Properties pane, in the FriendlyName box, type Customer.

6. Change the FriendlyName property of the remaining tables to remove the Dim prefix.

7. In the Diagram pane, right-click the Customer table, and then click New Named Calculation.
8. In the Create Named Calculation dialog box, in the Column name box, type Full Name.
9. 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

10. In the Create Named Calculation dialog box, click OK.

11. On the File menu, click Save All.


L5-38 Module 5: Creating Multidimensional Databases

Exercise 3: Creating and Modifying a Cube


 Task 1: Create a cube
1. In Solution Explorer, right-click the Cubes folder, and then click New Cube.

2. On the Welcome to the Cube Wizard page, click Next.


3. On the Select Creation Method page, verify that Use existing tables is selected, and then click
Next.

4. On the Select Measure Group Tables page, click Suggest.

5. Note that the wizard selects the InternetSales table as the measure group table, and then click Next.

6. On the Select Measures page, clear every check box except Unit Price, Unit Price Discount Pct,
Sales Amount, Tax Amt, and Internet Sales Count and click Next.

7. On the Select New Dimensions page, clear the Internet Sales check box, and then click Next.

Note that by clearing the check box for the Internet Sales dimension, the check box for the
InternetSales table clears automatically.
8. On the Completing the Wizard page, change the Cube name to Adventure Works Cube, and then
click Finish. The Cube Designer opens automatically after you click Finish.

 Task 2: Modify the cube


1. In the Measures pane of the Cube Designer, expand the Internet Sales measure group, right-click the
Unit Price Discount Pct measure, and then click Rename.

2. Rename Unit Price Discount Pct to Unit Price Discount Percent.

3. In the Measures pane, right-click Tax Amt, and then click Rename.
4. Rename Tax Amt to Tax Amount.

5. On the File menu, click Save All.

 Task 3: Modify dimensions


1. In Solution Explorer, in the Dimensions group, right-click Customer.dim, and then click View
Designer.

2. In the Data Source View pane, in the Geography table, click City.

3. Hold down the Ctrl key, click StateProvinceName, EnglishCountryRegionName, and


SalesTerritoryKey, 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.

6. Drag the selected columns to the Attributes pane.

7. On the File menu, click Save All.

8. Close the Customer.dim dimension designer.

9. In Solution Explorer, in the Dimensions group, right-click Product.dim, and then click View
Designer.
Lab 5: Creating a Multidimensional Database L5-39

10. In the Data Source View pane, in the Product table, click ProductAlternateKey.

11. Hold down the Ctrl key, click ProductSubcategoryKey, EnglishProductName, and ListPrice and
drag the selected columns to the Attributes pane.
12. On the File menu, click Save All.

13. Close the Product.dim dimension designer.

14. In Solution Explorer, in the Dimensions group, right-click Date.dim, and then click View Designer.
15. In the Data Source View pane, in the Date table, click FullDateAlternateKey.

16. Hold down the Ctrl key, click EnglishDayNameOfWeek, EnglishMonthName,


MonthNumberOfYear, CalendarQuarter, CalendarYear, and CalendarSemester, and drag the
selected columns to the Attributes pane.

17. On the File menu, click Save All. Keep the Date.dim designer open for the next task.

 Task 4: Modify attribute columns


1. In the Attributes pane, right-click Calendar Semester, and click Properties.
2. In the Properties pane, scroll down to the Source section.

3. Click the KeyColumns field, and then click the ellipses (…) button.

4. In the Key Columns dialog box, in the Available Columns table, click Calendar Year, and then click
the Right Arrow (>) icon.
5. Click the Up Arrow icon to move CalendarYear above CalendarSemester, and then click OK.

6. In the Properties pane, click the NameColumn field, and then click the ellipses (…) button.

7. In the Name Column dialog box, in the Source column field, click CalendarSemester, and then click
OK.

8. In the Attributes pane, click Calendar Quarter.

9. In the Properties pane, scroll down to the Source section.

10. Click the KeyColumns field, and then click the ellipses (…) button.

11. In the Key Columns dialog box, in the Available Columns table, click Calendar Year, and then click
the Right Arrow (>) icon.

12. Click the Up Arrow icon to move CalendarYear above CalendarQuarter, and then click OK.

13. In the Properties pane, click the NameColumn field, and then click the ellipses (…) button.

14. In the Name Column dialog box, in the Source column field, click CalendarQuarter, and then click
OK.

15. In the Attributes pane, right-click English Month Name and click Rename. Then change the
attribute name to Month.
16. With the Month attribute still selected, in the Properties pane, scroll down to the Source section,
click the KeyColumns field, and then click the ellipses (…) button.

17. In the Key Columns dialog box, in the Key Columns table, click EnglishMonthName, and then click
the Left Arrow (<) icon.
L5-40 Module 5: Creating Multidimensional Databases

18. In the Available Columns table, click Calendar Year, and then click the Right Arrow (>) icon.

19. In the Available Columns table, click MonthNumberOfYear, click the Right Arrow (>) icon. Ensure
that Calendar Year appears above MonthNumberOfYear, and then click OK.
20. In the Properties pane, click the NameColumn field, and then click the ellipses (…) button.

21. In the Name Column dialog box, in the Source column field, click EnglishMonthName, and then
click OK.

22. On the File menu, click Save All.


23. Close the Date.dim dimension designer.

 Task 5: Browse the cube


1. In Solution Explorer, right-click the Adventure Works OLAP solution, and then click Deploy. If an
Account Password dialog box appears, in the Password field type Pa$$w0rd and click OK. Then
wait for the Deploy Succeeded message in the status bar.

2. When deployment has completed successfully, in the Cube Designer, click the Browser tab.

Tip In SQL Server Data Tools, click the Auto Hide icon on the various panes to make it
easier to see the entire Cube Browser window.

3. In the Measure Group pane, expand Measures, expand Internet Sales, and then drag the Sales
Amount measure to the Drag levels or measures here to add to the query area of the Data pane.

4. In the Measure Group pane, drag Internet Sales Count to the right of the Sales Amount column.
5. In the Measure Group pane, expand the Order Date dimension.
6. Drag the Order Date.Calendar Year hierarchy to the left of the Sales Amount column. The cube
browser shows sales amounts and counts for multiple years.

7. Minimize SQL Server Data Tools.


8. Click Start, point to All Programs, click Microsoft Office, and then click Microsoft Excel 2010.

9. Maximize the Microsoft® Excel® 2010 window.

10. On the Data tab of the ribbon, click Get External Data, click From Other Sources, and then click
From Analysis Services.

11. In the Data Connection Wizard, in the Server name field, enter localhost, verify that Use Windows
Authentication is selected, and then click Next.
12. In the Data Connection Wizard, on the Select Database and Table page, in the Select the database
that contains the data you want field select Adventure Works OLAP and click Next.
13. On the Save Data Connection File and Finish page, click Finish.
14. In the Import Data dialog box, select PivotTable Report,, verify that Existing worksheet is selected
and the location is set to =$A$1, and then click OK.
15. In the PivotTable Field List, beneath the Internet Sales measure, select Sales Amount.
Lab 5: Creating a Multidimensional Database L5-41

16. Scroll down the PivotTable Field List, beneath the Customer dimension select Full Name. Notice
that the named calculation from the data source view is displaying the customers’ full names.

17. Choose other fields from the PivotTable Field List to continue browsing the cube. When you have
finished browsing the Adventure Works Cube cube in Excel 2010, close the window without saving
the changes.

18. Maximize SQL Server Data Tools.

19. On the File menu, click Save All to save your project. Then close SQL Server Data Tools.
L5-42 Module 5: Creating Multidimensional Databases
L6-43

Module 6: Working with Cubes and Dimensions


Lab 6: Defining Dimensions
Exercise 1: Configuring Dimensions
 Task 1: Prepare the lab environment
1. Ensure the MIA-DC and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab06, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab06\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd) and click Run as administrator.
5. Click Yes when prompted to confirm you want to run the command file, and wait for the script to
finish.

 Task 2: Remove unused attributes from dimensions


1. Navigate to D:\10778A\Labfiles\Lab06\Starter and double-click Adventure Works OLAP.sln to open
it with SQL Server Data Tools.
2. In Solution Explorer, right-click the Customer.dim dimension, and then click View Designer. Notice
that many attributes have been added to this dimension 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. 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.
4. In the Delete Objects dialog box, click OK.

5. On the File menu, click Save All. Then close the Customer dimension designer.
6. In Solution Explorer, right-click the Product.dim dimension, and then click View Designer. Again,
users have requested that you remove some unnecessary attributes from this dimension.

7. In the Attributes pane, right-click the Days To Manufacture attribute, press the Ctrl key and click
Safety Stock Level. Then click Delete.
8. In the Delete Objects dialog box, click OK.

9. On the File menu, click Save All. Then close the Product dimension designer.

 Task 3: Add dimension intelligence


1. In Solution Explorer, right-click Date.dim, and then click Add Business Intelligence.
2. On the Welcome to the Business Intelligence Wizard page, click Next.

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.
L6-44 Module 6: Working with Cubes and Dimensions

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:

Attribute Type Dimension Attribute


Year Calendar Year

Half Year Calendar Semester

Quarter Calendar Quarter

Month Month

Date Simple Date

Note You might need to resize the columns to view Attribute Type and Dimension
Attribute.

6. Click Next, and then click Finish.


Lab 6: Defining Dimensions L6-45

Exercise 2: Defining Relationships and Hierarchies


 Task 1: Create attribute relationships in the Date dimension
1. In Solution Explorer, right-click the Date.dim dimension, and then click View 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.

3. In the designer pane, click the Attributes Relationships tab.

4. In the Attribute Relationships diagram pane, right-click an empty space, and then click New
Attribute Relationship.

5. In the Create Attribute Relationship dialog box, in the Source Attribute section, in the Name field,
click Simple Date.
6. In the Related Attribute section, in the Name field, click Month.

7. 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.

8. Repeat steps 5-7 to create the following relationships:

Source Attribute Related Attribute Relationship type


Month Calendar Quarter Rigid (will not change over time)

Calendar Quarter Calendar Semester Rigid (will not change over time)

Calendar Semester Calendar Year Rigid (will not change over time)

9. When you have finished, on the File menu, click Save All.

 Task 2: Create a natural hierarchy in the Date dimension


1. In the designer pane for the Date.dim dimension, click the Dimension Structure tab.

2. In the Attributes pane, drag Calendar Year into the Hierarchies pane.

3. In the Attributes pane, drag the following attributes one-by-one to the Hierarchies pane and drop
them on to the <new level> area:

• Calendar Semester
• Calendar Quarter

• Month

• SimpleDate
4. In the Hierarchies pane, click the title bar of the Hierarchy hierarchy.

5. In the Properties pane, change the Name field to Calendar Date.


L6-46 Module 6: Working with Cubes and Dimensions

6. In the Attributes pane, select Calendar Year, press the Ctrl key and click Calendar Semester,
Calendar Quarter, Month, and Simple Date to select all of these attributes.

7. 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.

8. On the File menu, click Save All. Then close the date dimension designer.

 Task 3: Create attribute relationships in the Customer dimension


1. In Solution Explorer, right-click the Customer.dim dimension, and then click View Designer.

2. Click the Attribute Relationships tab.

3. In the Attribute Relationships pane, right-click an empty space, and then click New Attribute
Relationship.

4. In the Create Attribute Relationship dialog box, in the Source Attribute section, in the Name field,
click Full Name.
5. In the Related Attribute section, in the Name field, click Postal Code.
6. In the Relationship type field, ensure that Flexible (may change over time) is selected, because the
geographic relationships might be redefined over time, and then click OK.

7. Repeat steps 2-4 to create the following relationships:

Source Attribute Related Attribute Relationship type


Postal Code City Flexible (may change over time)

City State-Province Name Flexible (may change over time)

State-Province English Country Region Name Flexible (may change over time)
Name

Marital Status Gender Flexible (may change over time)

 Task 4: Create hierarchies in the Customer dimension


1. In the designer pane for the Customer.dim dimension, click the Dimension Structure tab.

2. In the Attributes pane, drag English Country Region Name into the Hierarchies pane.

3. In the Attributes pane, drag the following attributes one-by-one to the Hierarchies pane and drop
them on to the <new level> area:

• State Province Name


• City

• Postal Code

• Full Name
4. In the Hierarchies pane, click the title bar of the Hierarchy hierarchy.

5. In the Properties pane, change the Name field to Customer Geography.


Lab 6: Defining Dimensions L6-47

6. In the Attributes pane, drag Gender into an empty area of the Hierarchies pane.

7. In the Attributes pane, drag Marital Status to the <new level> area beneath Gender in the
Hierarchies pane.
8. In the Hierarchies pane, click the title bar of the Hierarchy hierarchy.

9. In the Properties pane, change the Name field to Gender - Marital Status.

10. In the Attributes pane, select English Country Region Name, press the Ctrl key and click State
Province Name, City, Postal Code, Full Name, Gender, and Marital Status to select all of these
attributes.

11. In the Properties pane, change the AttributeHierarchyVisible property to False.

12. On the File menu, click Save All.

13. Close the customer dimension designer.

 Task 5: Create attribute relationships in the Product dimension


1. In Solution Explorer, right-click the Product.dim dimension, and then click View Designer.
2. Click the Attribute Relationships tab.

3. In the Attribute Relationships pane, right-click an empty space, and then click New Attribute
Relationship.
4. In the Create Attribute Relationship dialog box, in the Source Attribute section, in the Name field,
click English Product Name.

5. In the Related Attribute section, in the Name field, click English Product Subcategory Name.
6. In the Relationship type field, ensure that Flexible (may change over time) is selected, because the
product categorization relationships might be redefined over time, and then click OK.

7. In the Attribute Relationships pane, right-click an empty space, and then click New Attribute
Relationship.

8. In the Create Attribute Relationship dialog box, in the Source Attribute section, in the Name field,
click English Product Subcategory Name.
9. In the Related Attribute section, in the Name field, click English Product Category Name.

10. In the Relationship type field, ensure that Flexible (may change over time) is selected, because the
product categorization relationships might be redefined over time, and then click OK.

11. On the File menu, click Save All.

 Task 6: Create hierarchies in the Product dimension


1. In the designer pane for the Product.dim dimension, click the Dimension Structure tab.

2. In the Attributes pane, drag English Product Category Name into an empty area of the Hierarchies
pane.
3. In the Attributes pane, drag English Product Subcategory Name to the <new level> area beneath
English Product Category Name in the Hierarchies pane.
4. In the Attributes pane, drag English Product Name to the <new level> area beneath English
Product Subcategory Name in the Hierarchies pane.
L6-48 Module 6: Working with Cubes and Dimensions

5. In the Hierarchies pane, click the title bar of the Hierarchy hierarchy.

6. In the Properties pane, change the Name field to Product Category.

7. In the Attributes pane, select English Product Category Name, press the Ctrl key and click English
Product Subcategory Name and English Product Name to select all of these attributes.

8. In the Properties pane, change the AttributeHierarchyVisible property to False.

9. On the File menu, click Save All.


10. Close the product dimension designer.

 Task 7: Browse the hierarchies you have created


1. In Solution Explorer, right-click the Adventure Works OLAP solution, and then click Deploy. If an
Account Password dialog box appears, in the Password field type Pa$$w0rd and click OK. Then
wait for the Deploy Succeeded message in the status bar.

2. In Solution Explorer, right-click the Customer dimension, and then click Browse.

3. In the Hierarchy drop-down list, ensure that Customer Geography is selected. Then expand the All
level of the hierarchy and note that several countries are listed along with an Unknown level for
customers where the country is not known.

4. Expand Australia, and note that several states are listed. Then continue expanding the levels to
explore the hierarchy.
5. In the Hierarchy drop-down list, select Gender – Marital Status, and explore this hierarchy.

6. In Solution Explorer, right-click the Adventure Works Cube.cube cube, and then click Browse.

7. In the Measure Group pane, expand Measures, expand Internet Sales, and then drag the Sales
Amount measure to the Drag levels or measures here to add to the query area of the Data pane.

8. In the Measure Group pane, expand Product and drag the Product Category hierarchy to the left of
the Sales Amount column; and note that the hierarchy displays products by category, subcategory,
and individual product name.
Lab 6: Defining Dimensions L6-49

Exercise 3: Sorting and Grouping Dimension Attributes


 Task 1: Modify the sort order of the Month attribute
1. In Solution Explorer, right-click the Date dimension, and then click Browse.

2. In the Hierarchy drop-down list, ensure that Calendar Date is selected. Then expand the All level of
the hierarchy and note that several years are listed.

3. Expand 2005, and note that two half-years are listed. Then expand H2CY2005 and note that two
quarters are listed. Finally, expand Q4 CY 2005 and note that the months in that quarter are shown.
However, the months are ordered alphabetically rather than in calendar order.

4. Click the Dimension Structure tab of the date dimension designer.

5. In the Attributes column, right-click Month Number of Year and click Properties.

6. In the Properties pane, set the following values:

Property Subsection Property Value


Advanced AttributeHierarchyOptimizedState NotOptimized

Misc AttributeHierarchyOrdered False

7. Click the Attribute Relationships tab. Then, in the Attributes pane, right-click Month, and click New
Attribute Relationship.

8. In the Create Attribute Relationship window, in the Source Attribute section, in the Name field,
ensure that Month is selected. Then, in the Related Attribute section, in the Name field, click
Month Number of Year.

9. In the Relationship type field click Rigid (will not change over time) because a particular month
will always be the same month number of the year, and then click OK.
10. Click the Dimension Structure tab.

11. In the Attributes pane, click Month.

12. In the Properties pane, in the OrderBy box, click AttributeKey, and then in the OrderByAttribute
box, click Month Number Of Year.

13. On the File menu, click Save All.

14. In Solution Explorer, right-click the Adventure Works OLAP solution, and then click Deploy. Wait for
the Deploy Succeeded message in the status bar.

15. On the Browser tab of the Date.dim Dimension Designer, click the Reconnect icon.

16. If necessary, in the Hierarchy box, click Calendar Date. Expand the hierarchy to the month level and
notice that the months are now in date order rather than alphabetical order.

17. Close the date dimension designer


 
L6-50 Module 6: Working with Cubes and Dimensions

 Task 2: Group the Yearly Income attribute hierarchy members


1. In Solution Explorer, right-click the Customer.dim dimension, and then click View Designer.

2. 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.
3. On the Explore Customer Table tab, click the Close button.

4. Click the Browser tab of the Customer.dim Dimension Designer, and then click the Reconnect
button.

5. In the designer pane, change the Hierarchy field to Yearly Income.


6. Expand All, and notice that the salaries have no hierarchy.

7. Click the Dimension Structure tab. Then, in the Attributes pane, right-click Yearly Income and click
Properties.

8. In the Properties pane, in the DiscretizationMethod box, click Automatic, in the


DiscretizationBucketCount box type 5 and in the OrderBy list, select Key.
9. On the File menu, click Save All.

10. In Solution Explorer, right-click the Adventure Works OLAP solution, and then click Deploy. Wait for
the Deploy Succeeded message in the status bar.
11. In the customer dimension designer, click the Browser tab, and click the Reconnect icon.
12. If necessary, in the Hierarchy box, click Yearly Income and expand the All level.

13. Note that the salaries are now grouped into ranges.

14. In Solution Explorer, right-click Adventure Works Cube.cube, and then click Browse.
15. If necessary, remove any existing measures from the grid by right-clicking anywhere in the grid area
and clicking Clear Grid. Then, in the Measure Group pane, expand Measures, expand Internet Sales,
and then drag the Sales Amount measure to the Drag levels or measures here to add to the
query area of the Data pane.

16. In the Measure Group pane, expand Customer and drag the Yearly Income attribute to the left of
the Sales Amount column.
17. Notice that the individual income values have been automatically grouped.

18. Click File, and then click Save All. Then close SQL Server Data Tools.
L7-51

Module 7: Working with Measures and Measure Groups


Lab 7: Configuring Measures and Measure
Groups
Exercise 1: Configuring Measures
 Task 1: Prepare the lab environment
1. Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab07, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab07 Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd) and click Run as administrator.
5. Click Yes when prompted to confirm you want to run the command file, and wait for the script to
finish.

 Task 2: Create a Measure Group


1. Browse to the D:\10778A\Labfiles\Lab07\Starter folder and double-click the Adventure Works
OLAP.sln project solution file.
2. In Solution Explorer, right-click Adventure Works DSV.dsv, and then click View Designer.

3. Click the Add/Remove Objects icon. Then, in the Add/Remove Tables dialog box, in the Available
objects list, select FactResellerSales (dbo) and click the > button to add the selected table to the
Included objects list.

4. 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 click Save All.
5. Close the Adventure Works DSV.dsv designer.

6. In Solution Explorer, right-click Adventure Works Cube.cube, and then click View Designer.

7. Click the New Measure Group icon, and then in the New Measure Group dialog box, select
FactResellerSales and click OK.

8. In the Measures pane, right-click the Fact Reseller Sales measure group and click Rename. Then
change the name of the measure group to Reseller Sales.

9. Expand both the Internet Sales and Reseller Sales measure groups and review the names of the
measures they contain. Note that when the Reseller Sales measure group was created, measures
were created for all of the numerical fields in the FactResellerSales table. In cases where an measure
with the same field name already existed, a new measure was created with “ - Fact Reseller Sales”
appended to its name.
 
L7-52 Module 7: Working with Measures and Measure Groups

 Task 3: Modify Measure Groups


1. On the Cube Structure tab, click the Show Measures Grid icon to view all of the measures in the
cube as a grid. Note the aggregations that are used to summarize the measures when they are
analyzed across dimensions.

2. Click the row for the Promotion Key measure, and then hold the Ctrl key and click the rows for the
following measures to select them all:

• Currency Key

• Sales Territory Key

• Revision Number

• Extended Amount

• Unit Price Discount Percent

• Discount Amount

• Product Standard Cost

• Freight
• Revision Number – Fact Reseller Sales

• Extended Amount – Fact Reseller Sales


• Unit Price Discount Pct

• Discount Amount – Fact Reseller Sales

• Product Standard Cost – Fact Reseller Sales


• Freight – Fact Reseller Sales
3. Click the Delete icon, and then in the Delete Objects dialog box, click OK to remove these measures
(which are not required by the business analysts who use the cube).
4. Right-click the Order Quantity measure and click Rename. Then change the name of the measure to
Order Quantity – Internet Sales.
Lab 7: Configuring Measures and Measure Groups L7-53

5. Repeat the previous step for the following measures:

Measure Rename to:


Unit Price Unit Price – Internet Sales

Total Product Cost Total Product Cost – Internet Sales

Sales Amount Sales Amount – Internet Sales

Tax Amount Tax Amount – Internet Sales

Order Quantity – Fact Reseller Sales Order Quantity – Reseller Sales

Unit Price – Fact Reseller Sales Unit Price – Reseller Sales

Total Product Cost – Fact Reseller Sales Total Product Cost – Reseller Sales

Sales Amount – Fact Reseller Sales Sales Amount – Reseller Sales

Tax Amt Tax Amount – Reseller Sales

Fact Reseller Sales Count Reseller Sales Count

6. Click the Show Measure Tree icon to view your measure groups as a tree. Then on the File menu,
click Save All.
L7-54 Module 7: Working with Measures and Measure Groups

Exercise 2: Defining a Regular Relationship


 Task 1: View existing dimensions for measure groups
1. In Solution Explorer right click Adventure Works OLAP and click Deploy.

2. If an Account Password dialog box appears, in the Password field type Pa$$w0rd and click OK.
3. Wait for the Deploy Succeeded message in the status bar.

4. In Solution Explorer, right-click Adventure Works Cube.cube and click Browse.

5. In the Metadata pane, in the Measure Group drop-down list select Internet Sales and notice the
Product dimension.

6. In the Measure Group drop-down list select Reseller Sales and notice that there is no Product
dimension.

 Task 2: Create a dimension


1. Click the Dimensions Usage tab.

2. Click the cell at the intersection of the Reseller Sales measure group and the Product dimension and
click the ellipses (…).

3. In the Define Relationship dialog box, in the Select relationship type list, select Regular.

4. In the Granularity attribute field select Product Key.


5. In the Measure Group Columns column select ProductKey and click OK.

6. On the File menu, click Save All.

7. In Solution Explorer, right click Adventure Works OLAP and click Deploy.

8. Wait for the Deploy Succeeded message in the status bar.


9. Click the Browser tab for the Adventure Works Cube cube.

10. Click Reconnect.


11. In the Measure Group drop-down list, select Reseller Sales and notice that there is now a Product
dimension.

12. In the Metadata pane expand Measures, expand Reseller Sales, and drag Sales Amount – Reseller
Sales to the Drag levels or measures here to add to the query pane.

13. In the Metadata pane, expand the Product dimension and drag the Product Category hierarchy to
the left of Sales Amount –Reseller Sales and note that you can now analyze reseller sales data by
product.
Lab 7: Configuring Measures and Measure Groups L7-55

Exercise 3: Configuring Measure Group Storage


 Task 1: Configure the storage mode of the Internet Sales measure group
1. In Cube Designer for the Adventure Works Cube cube, on the Cube Structure tab, in the Measures
pane, right-click Internet Sales, and then click Properties.

2. In the Properties window, click ProactiveCaching and click the ellipses (…) button.

3. Under Standard setting, review each of the storage setting options. When finished, drag the slider to
Automatic MOLAP and then click OK.

 Task 2: Design aggregations for the Internet Sales measure group


1. Click the Aggregations tab of Cube Designer for the Adventure Works Cube cube.

2. Right-click Internet Sales (0 Aggregation Designs), and then click Design Aggregations.
3. The Aggregation Design Wizard appears. Click Next.

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. Then, when the count process has completed, click
Next.

6. On the Set Aggregations Options page, select Performance gain reaches and ensure that the
value is set to 35%. Then click Start.
7. Click Stop when the optimization level reaches approximately 35%, and then 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. In the Aggregations tab of Cube Designer for the Adventure Works cube, verify that Internet
Sales now has one aggregation design named InternetSalesAgg.

10. On the File menu, click Save All. Then, close the Cube Designer.

11. In Solution Explorer, right click Adventure Works OLAP and click Deploy.
12. Wait for the Deploy Succeeded message in the status bar. Then close SQL Server Data Tools.

13. Click Start, point to All Programs, click Microsoft SQL Server 2012, and then click SQL Server
Management Studio. When prompted, in the Connect to Server dialog box, specify the following
settings and click Connect:

• Server type: Analysis Services


• Server name: localhost

14. In Object Explorer, expand Databases, expand Adventure Works OLAP, expand Cubes, expand
Adventure Works Cube, expand Measure Groups, expand Internet Sales, and expand
Aggregation Designs.

15. Verify that the InternetSalesAgg aggregation has been deployed with the cube, and then close SQL
Server Management Studio.

Results: After this exercise, you should have defined the storage mode aggregations and for the Internet
Sales measure group.
L7-56 Module 7: Working with Measures and Measure Groups
L8-57

Module 8: Introduction to MDX


Lab 8: Using MDX
Exercise 1: Querying a Cube by Using MDX
 Task 1: Prepare the lab environment
1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab08, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab08\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd), and then click Run as
administrator.
5. Click Yes when prompted to confirm that you want to run the command file, and then wait for the
script to finish.

 Task 2: Deploy an OLAP database


1. In the D:\10778A\Labfiles\Lab08\Starter folder, double-click the Adventure Works OLAP.sln project
solution file to it in SQL Server Data Tools.

2. In the Solution Explorer pane, right-click Adventure Works OLAP, and then click Deploy.

3. If a dialog box appears asking whether you would like to continue, click Yes.
4. If the Account Password dialog box appears, in the Password box, type Pa$$w0rd.

5. When deployment has completed successfully, close SQL Server Data Tools.

 Task 3: Write simple MDX queries


1. Start SQL Server Management Studio and connect to the localhost instance of Analysis Services.
2. In the Object Explorer pane, in the Databases folder, right-click Adventure Works OLAP, point to
New Query, and then click MDX.

3. In the query window, type the following Multidimensional Expressions (MDX) query to return the
Internet sales totals for each product category:

SELECT
[Measures].[Sales Amount – Internet Sales] On 0,
NonEmpty([Product].[Product Category].[English Product Category Name].Members) On 1
FROM [Adventure Works Cube]

4. Click Execute.

5. Review the query results.


6. Close the query window, clicking No when prompted to save the query.

7. Click New Query.


L8-58 Module 8: Introduction to MDX

8. Type the following MDX query:

SELECT
[Measures].[Internet Sales Count] On 0,
NonEmpty([Customer].[Customer Geography].[English Country Region Name].Members) On
1
FROM [Adventure Works Cube]

9. Click Execute.

10. Review the query results.


11. Close the query window, clicking No when prompted to save the query.

 Task 4: Write an MDX query to return data on rows and columns


1. Click New Query.

2. Type the following MDX query:

SELECT
NonEmpty([Order Date].[Calendar Date].[Calendar Year].Members) ON COLUMNS,
[Customer].[Customer Geography].[City].Members ON ROWS
FROM [Adventure Works Cube]
WHERE [Measures].[Sales Amount - Internet Sales]

3. Click Execute.
4. Review the query results. Notice that the NonEmpty function eliminates any Year columns without
sales, but the lack of the NonEmpty function on the City results in null values on rows where there
are no sales.

5. Close the query window, clicking No when prompted to save the query.
6. Minimize SQL Server Management Studio. You will use it again in the next exercise.
Lab 8: Using MDX L8-59

Exercise 2: Creating a Calculated Member


 Task 1: Define a Profit calculated member based on physical measures
1. Browse to the D:\10778A\Labfiles\Lab08\Starter folder and double-click the Adventure Works
OLAP.sln project solution file to open the solution in SQL Server Data Tools.

2. In Solution Explorer, right-click Adventure Works Cube.cube, click Open, and then click the
Calculations tab.
3. On the toolbar of the Calculations tab, click the New Calculated Member icon.

4. In the Name box, change the name of the calculated measure to [Profit].

5. On the Calculations tab, in the Calculation Tools pane, on the Metadata tab, expand Measures, and
then expand Internet Sales to view the metadata for the Internet Sales measure group.
6. Drag Sales Amount – Internet Sales from the Metadata tab in the Calculation Tools pane into the
Expression box.

7. In the Expression box, after [Measures].[Sales Amount – Internet Sales], type a minus sign (-).
8. On the Metadata tab in the Calculation Tools pane, drag Total Product Cost – Internet Sales into
the Expression box after the minus sign (-).

9. In the Format string list, select "Currency".

10. In the Non-empty behavior list, select the check boxes for Total Product Cost – Internet Sales and
Sales Amount – Internet Sales, and then click OK.

11. In the Associated measure group field, select Internet Sales.


12. On the File menu, click Save All.

 Task 2: Define gross profit margin calculations


1. In the Script Organizer pane, verify that [Profit] is selected, and then, on the toolbar of the
Calculations tab, click the New Calculated Member icon.
2. In the Name box, change the name of this new calculated measure to [Gross Profit Margin].

3. In the Expression box, create the following MDX expression.

([Measures].[Sales Amount – Internet Sales] - [Measures].[Total Product Cost –


Internet Sales])
/ [Measures].[Sales Amount – Internet Sales]

4. In the Format string list, select "Percent".

5. In the Non-empty behavior list, select the check box for Sales Amount – Internet Sales, and then
click OK.

6. In the Associated measure group field, select Internet Sales.

7. On the File menu, click Save All.


L8-60 Module 8: Introduction to MDX

8. On the Build menu, click Deploy Adventure Works OLAP. If you are prompted to replace the
existing database, click Yes.

9. If the Account Password dialog box appears, in the Password box, type Pa$$w0rd.
10. Close SQL Server Data Tools.

 Task 3: Query the new calculated members


1. Maximize SQL Server Management Studio.

2. Click New Query.


3. Type the following MDX query.

SELECT
{[Measures].[Profit], [Measures].[Gross Profit Margin]} ON COLUMNS,
NonEmpty([Product].[Product Category].[English Product Category Name]) ON ROWS
FROM [Adventure Works Cube]

4. Click Execute.

5. Review the query results. Notice that the calculated members you defined in the cube are applied to
sales for the product categories.

6. Close the query window, clicking No when prompted to save the query.

7. Close SQL Server Management Studio.

Results: After this exercise, you should have created two calculated members and then queried them.
L9-61

Module 9: Customizing Cube Functionality


Lab 9: Customizing a Cube
Exercise 1: Implementing an Action
 Task 1: Prepare the lab environment
1. Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab09, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab09\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd) and click Run as administrator.
5. Click Yes when prompted to confirm you want to run the command file, and wait for the script to
finish.

 Task 2: Deploy an OLAP database


1. In the D:\10778A\Labfiles\Lab09\Starter folder and double-click the Adventure Works OLAP.sln
solution file.
2. In the Solution Explorer pane, right-click Adventure Works OLAP, and then click Deploy.

3. If the Account Password dialog box appears, in the Password box, type Pa$$w0rd and click OK.
4. Keep SQL Server Data Tools open. You will use it in the next task.

 Task 3: Create a drillthrough action


1. In SQL Server Data Tools, in Solution Explorer right-click Adventure Works Cube.cube and click
View Designer.
2. In Cube Designer for the Adventure Works cube, click the Actions tab.

3. On the toolbar of the Actions tab, click the New Drillthrough Action icon.

4. In the Name box, change the name of this action to Internet Sales Details Drillthrough Action.
5. In the Measure group members list, click Internet Sales.

6. In the Drillthrough Columns box, in the Select Dimensions list, click Customer; and then in the
Return Columns list, select English Country Region Name and Full Name, and click OK.

7. Repeat the previous step to add the following dimensions and return columns:

Dimension Return Columns


Order Date Simple Date

Product English Product Name

8. Expand Additional Properties.


L9-62 Module 9: Customizing Cube Functionality

9. In the Caption box, type Drillthrough to Order Details….

10. On the File menu, click Save All.

11. In the Solution Explorer pane, right-click Adventure Works OLAP, and then click Deploy.

 Task 4: Browse a drillthrough action


1. In SQL Server Data Tools, in the Adventure Works Cube.cube designer, click the Browser tab.

2. Click the Analyze in Excel icon to create an Excel workbook with a connection to cube. If a security
notice is displayed, click Enable.
3. In Excel, in the PivotTable Field List pane, under Internet Sales, select Sales Amount.

4. In the PivotTable Field List pane, under Order Date, select Order Date.Calendar Date.

5. In the PivotTable Field List pane, under Product, select Product Category.
6. In the PivotTable, right-click the sales amount for Bikes in 2003 (cell D4), point to Additional
Actions, and click Drillthrough to order details….

7. View the new worksheet generated by the drillthrough action, noting that it shows the country,
customer name, order date, and product name for each sale of a bike in 2003.

8. Close Excel without saving your changes.

9. Keep SQL Server Data Tools open for the next exercise.
Lab 9: Customizing a Cube L9-63

Exercise 2: Implementing a Perspective


 Task 1: Define a Sales Summary perspective
1. In SQL Server data Tools, in the Cube Designer for the Adventure Works cube, click the
Perspectives tab.

2. On the toolbar of the Perspectives tab, click the New Perspective icon.

3. Change the name of the new perspective to Sales Summary.

4. Clear the check boxes for all measures in the Internet Sales measure group other than Sales
Amount – Internet Sales.

5. Clear the check boxes for all dimensions other than Customer.
6. Clear the checkbox for all actions and calculated members.

7. On the File menu, click Save All.

 Task 2: Browse the cube using the Sales Summary perspective


1. On the SQL Server Data Tools Build menu, click Deploy Adventure Works OLAP.
2. When deployment has successfully completed, switch to the Browser tab, and then click the
Reconnect icon.

3. If there is any data in the Data pane, right-click in the data area and then click Clear Grid. If there are
any dimensions in the Filter pane, right-click each dimension and click Delete.
4. In the Cube Selection area above the Metadata pane, click the ellipses (…), click Sales Summary,
and click OK.

5. In the Measure Group pane, expand Measures, expand Internet Sales. Note that the only measure
displayed is Sales Amount and the only dimension displayed is Customer. This enables users in the
sales department to focus on the data that is useful to them.
6. Drag the Sales Amount – Internet Sales measure to the Drag levels or measures here to add to
the query pane.

7. In the Measure Group pane, expand the Customer dimension and drag the Gender – Marital Status
hierarchy to the left of Sales Amount – Internet Sales.
8. Note that users can browse the data in the perspective in the same way they browse data in the
whole cube.

9. In the Cube Selection field, click the ellipses (…), click Adventure Works Cube, and click OK. Note
that all measures and dimensions are now visible.

10. Keep SQL Server Data Tools open for the next exercise.
L9-64 Module 9: Customizing Cube Functionality

Exercise 3: Implementing a Translation


 Task 1: Specify translations for the Time Dimension metadata
1. In Solution Explorer, in the Dimensions folder, right-click Date.dim, click View Designer, and then
click the Translations tab.

2. On the toolbar of the Translations tab, click the New Translation icon. Then, in the Select
Language dialog box, click French (France), and click OK.
3. In the row for the Caption object for the Date dimension, type Date in the French (France)
translation column.

4. In the row for the Caption object for the Month Number of Year attribute, type Mois d'Année in
the French (France) translation column.

Tip To type é hold the Alt key and type 130 using the number pad on your keyboard
ensuring NumLock is turned on. If this is not possible type the captions without accents.

5. Click the ellipses (…) button for the French (France) translation for the Month Number of Year
attribute. The Attribute Data Translation dialog box appears.
6. In the Translation columns list, click FrenchMonthName, and then click OK.
7. On the File menu, click Save All.

8. Close the Date.dim dimension designer.

 Task 2: Specify translations for the Adventure Works cube metadata


1. In Solution Explorer right-click Adventure Works Cube.cube and click View Designer.
2. In the Adventure Works Cube.cube designer, click the Translations tab.

3. On the toolbar of the Translations tab, click the New Translation icon, and then in the Select
Language dialog box, click French (France). Then click OK.
4. In the row for the Caption object for the Internet Sales measure group, in the French (France)
translation column, type Ventes d'Internet.
5. In the row for the Caption object for the Sales Amount measure, in the French (France) translation
column, type Ventes Total.

6. On the File menu, click Save All.

 Task 3: Browse the cube using the new translations


1. On the Build menu of SQL Server Data Tools, click Deploy Adventure Works OLAP. Then, when
deployment has successfully completed, click the Browser tab, and then click Reconnect.

2. If there is any data in the Data pane, right-click in the data area and then click Clear Grid. If there are
any dimensions in the Filter pane, right-click each dimension and click Delete.

3. On the toolbar, in the Language list, click French (France).

4. In the Measure Group pane, expand Measures, expand Ventes d’Internet, and drag Ventes Total to
the Drag levels or measures here to add to the query pane.

5. In the Measure Group field, expand the Order Date dimension and drag the Order Date.Mois
d’Année hierarchy to the left of Ventes Total and note that the caption and data is now in French.
L10-65

Module 10: Implementing a Tabular Data Model with


Microsoft PowerPivot
Lab 10: Using PowerPivot for Excel
Exercise 1: Creating a Tabular Data Model by Using PowerPivot for Excel
 Task 1: Prepare the lab environment
1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab10, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab10\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd), and then click Run as
administrator.

5. Click Yes when prompted to confirm that you want to run the command file, and then wait for the
script to finish.

 Task 2: Import data into a PowerPivot for Excel workbook


1. Click Start, point to All Programs, click Microsoft Office, and then click Microsoft Excel 2010.

1. In Microsoft® Excel® 2010, on the ribbon, click the PowerPivot tab.


2. On the ribbon, click PowerPivot Window.

3. In the PowerPivot window, on the Home tab, in the Get External Data group, click From Database,
and then click From SQL Server.
4. In the Table Import Wizard, on the Connect to a Microsoft SQL Server Database page, in the
Friendly connection name box, type AdventureWorksDW.

5. In the Server name box, type localhost.


6. In the Log on to the server box, ensure that Use Windows Authentication is selected.

7. In the Database name list, click AdventureWorksDW, and then click Next.

8. On the Choose How to Import the Data page, click Select from a list of tables and views to
choose the data to import, and then click Next.
9. On the Select Tables and Views page, select the FactResellerSales check box.

10. Click Select Related Tables to import other tables that are directly related to the FactResellerSales
table.
11. Deselect the check boxes for the DimCurrency, DimPromotion, and DimReseller tables.

12. Select the DimProductSubcategory and DimProductCategory tables. These tables were not added
automatically because they are not directly related to the FactResellerSales table.
L10-66 Module 10: Implementing a Tabular Data Model with Microsoft PowerPivot

13. In the Friendly Name column, change the friendly names of the selected tables as follows:

• DimDate: Date

• DimEmployee: Employee

• DimProduct: Product

• DimProductCategory: Product Category

• DimProductSubcategory: Product Subcategory

• DimSalesTerritory: Sales Territory

• FactResellerSales: Reseller Sales

14. Click the DimDate row to select it, and then click the Preview & Filter button.

15. On the Preview Selected Table page, uncheck the following columns, and then click OK:

• SpanishDayNameOfWeek

• FrenchDayNameOfWeek

• SpanishMonthName
• FrenchMonthName

16. Remove the following columns from the DimEmployee table in the same way, and then click OK:
• LoginID

• EmailAddress

• Phone
• EmergencyContactName
• EmergencyContactPhone

17. Remove the following columns from the DimProduct table in the same way, and then click OK:

• SpanishProductName
• FrenchProductName

• FrenchDescription
• ChineseDescription

• ArabicDescription

• HebrewDescription
• ThaiDescription

• GermanDescription

• JapaneseDescription

• TurkishDescription
Lab 10: Using PowerPivot for Excel L10-67

18. Remove the following columns from the DimProductCategory table in the same way, and then click
OK:

• SpanishProductCategoryName
• FrenchProductCategoryName

19. Remove the following columns from the DimProductSubcategory table in the same way, and then
click OK:

• SpanishProductSubcategoryName
• FrenchProductSubcategoryName

20. In the Table Import Wizard, click Finish.


21. When the data import completes, in the Message column, click Details, and then review the details
of the import process. Note that there is an error relating to the DimEmployee table that states that
self-referential relationships are not supported.
22. In the Details box, click OK.

23. In the Table Import Wizard, click Close.

24. On the taskbar, click the Save button. In the Save As dialog box, navigate to the
D:\10778A\Labfiles\Lab10\Starter folder, in the File name box, type Sales Overview, and then click
Save.

Note When importing tables, it is best practice to remove all columns that you do not
require. This can substantially improve the performance of the Microsoft PowerPivot
workbook.

 Task 3: Rename columns in a PowerPivot for Excel workbook


1. In the PowerPivot window, click the Date tab in the lower-left corner to select the Date table.
2. Double-click the EnglishDayNameOfWeek column header, type Day, and then press Enter.

3. Rename the columns in the following table in the same way:

Table name Existing column name New column name


Date EnglishMonthName Month

Date CalendarYear Calendar Year

Date FiscalYear Fiscal Year

Employee FirstName First Name

Employee LastName Last Name

Product EnglishProductName Product

Product Category EnglishProductCategoryName Category


L10-68 Module 10: Implementing a Tabular Data Model with Microsoft PowerPivot

(continued)

Table name Existing column name New column name


Product Subcategory EnglishProductSubcategoryName Subcategory

Sales Territory SalesTerritoryCountry Country

Reseller Sales TotalProductCost Total Product Cost

Reseller Sales SalesAmount Sales Amount

Note You should consider renaming all columns that you expect to use in the workbook
for ease of understanding and clarity.

 Task 4: Import data into a PowerPivot workbook by using a query


1. In the PowerPivot window, on the Home tab, in the Get External Data group, click From Database,
and then click From SQL Server.

2. In the Friendly connection name dialog box, type AdventureWorksDWGeography.

3. In the Server name box, type localhost.


4. In the Log on to the server box, ensure that Use Windows Authentication is selected.

5. In the Database name list, click AdventureWorksDW, and then click Next.

6. On the Choose How to Import the Data page, click Write a query that will specify the data to
import, and then click Next.

7. In the Specify a SQL Query window, click Design.

8. In the Design window, in the Database view pane, expand Tables, and then select DimGeography.
9. In the Selected fields area, click IpAddressLocator, and then click the Delete Field button to
remove this column from the imported table.
10. Remove the SpanishCountryRegionName, FrenchCountryRegionName, and PostalCode columns
in the same way, and then click OK.

11. In the Specify a SQL Query window, click Validate, and then click Finish.

12. When the data import completes, in the Table Import Wizard, click Close.
13. In the PowerPivot window, at the bottom, right-click the Query tab, click Rename, type Geography,
and then press Enter.

 Task 5: Create a relationship manually


1. In the PowerPivot window, on the ribbon, in the View group, click Diagram View.

2. If necessary, rearrange the tables so that you can see the Sales Territory and Geography tables at
the same time.
3. In the Sales Territory table, click SalesTerritoryKey, drag it to SalesTerritoryKey in the Geography
table, and then release it.
Lab 10: Using PowerPivot for Excel L10-69

 Task 6: Create a hierarchy


1. In the PowerPivot window, on the ribbon, in the View group, click Data View.

2. Click the Product table tab.

3. Scroll across to the final column in the table, double-click the Add Column header, type
Subcategory, and then press Enter.

4. Below the ribbon, in the formula bar, type the following Data Analysis Expressions (DAX) formula, and
then press Enter:

=RELATED('Product Subcategory'[Subcategory])

5. Not all rows in the Products table have a value for the Subcategory column. Use the scroll bar to
scroll down the Subcategory column until you see the rows that have an value for Subcategory.

6. In the column to the right of Subcategory, double-click the Add Column header, type Category,
and then press Enter.
7. Below the ribbon, in the formula bar, type the following DAX formula, and then press Enter:

=RELATED('Product Category'[Category])

8. On the ribbon, in the View section, click the Diagram View button.
9. In the Product table, right-click the Product table header, click Create Hierarchy, type Products,
and then press Enter.

10. In the Product table, click Category, drag it onto the Products hierarchy, and then release it.
11. In the Product table, click Subcategory, drag it onto the Products hierarchy, and then release it.
12. In the Product table, click Product, drag it onto the Products hierarchy, and then release it. (You
may need to resize the table to do this.)

 Task 7: Hide tables from client tools


1. In the PowerPivot window, click the Data View button.
2. Right-click the Product Category table tab, and then click Hide from Client Tools.

3. Right-click the Product Subcategory table tab, and then click Hide from Client Tools.

4. On the taskbar, click the Save button.


L10-70 Module 10: Implementing a Tabular Data Model with Microsoft PowerPivot

Exercise 2: Using a Tabular Data Model in Excel


 Task 1: Create a PivotTable table
1. In the PowerPivot window, in the upper-left corner, click Switch to Workbook.

2. Click Sheet 1, and then click in cell B2.


3. On the ribbon, on the PowerPivot tab, click PivotTable, and then click PivotTable.

4. In the Create PivotTable dialog box, click Existing Worksheet, and then click OK.

5. In the PowerPivot Field List, expand Reseller Sales, and then select Sales Amount and Total
Product Cost to add these columns to the Values area.

Note You can also drag columns into the Values area and other areas under the
PowerPivot Field List.

6. In the PowerPivot Field List, expand Product, and then select Products (this is the hierarchy that
you created in Exercise 1).

 Task 2: Create a measure


1. In the PowerPivot Field List, right-click Reseller Sales, and then click Add New Measure.

2. In the Measure name (all PivotTables) field, type Total Profit.


3. In the Formula box, after the equal sign (=), type the following DAX formula:

SUM('Reseller Sales'[Sales Amount]) – SUM('Reseller Sales'[Total Product Cost])

4. In the Category list, select Currency, and then click OK.

 Task 3: Add formatting to a PivotTable table


1. On the ribbon, in the PivotTable Tools group, click the Design tab.
2. In the PivotTable Styles area, click any style.

3. In the Layout area, click Blank Rows, and then click Insert Blank Line after Each Item.

4. On the ribbon, click the Home tab.

5. In the PivotTable table, select all of the rows in the Total Profit column (do not include the Total
Profit header row).

6. In the Styles area, click Conditional Formatting, click Color Scales, and then click Green–Yellow-
Red Color Scale.

7. In the PivotTable table, in the Row Labels column, expand Bikes, and then expand Road Bikes to
view the effects of the formatting options that you configured.

 Task 4: Create PivotChart charts


1. In the Sales Overview workbook, on Sheet 1, click in cell G9, and then click the PowerPivot tab.
2. Click PivotTable, click PivotChart, in the Create PivotChart dialog box, click Existing Worksheet,
and then click OK.
Lab 10: Using PowerPivot for Excel L10-71

3. In the PowerPivot Field List, expand Reseller Sales, and then select Sales Amount.

4. Expand Product, and then select Category to add it to the Axis Fields area.

5. Expand Date, and then drag Calendar Year to the Legend Fields area.

6. On the ribbon, in the PivotChart Tools group, click the Layout tab.

7. In the Labels area, click Chart Title, click Above Chart, and then type Sales Amount by Category
by Year.
8. Click the PivotChart chart, and then click the Format tab.

9. In the Size area, in the Height field, type 4.

10. In the Width field, type 6.


11. In the Shape Styles area, click any of the shape styles.

12. Click in cell G30, and then click the PowerPivot tab.

13. Click PivotTable, click PivotChart, in the Create PivotChart dialog box, click Existing Worksheet,
and then click OK.
14. In the PowerPivot Field List, expand Reseller Sales, and then select Sales Amount.

15. Expand Sales Territory, and then select Country.


16. Repeat steps 6–11 above to make the changes in the following table to the PivotChart chart:

Formatting option Setting


Shape Height 3.5

Shape Width 6

Shape Style Any shape style

Chart Title Sales Amount by Country

17. Right-click the PivotChart chart, and then click Change Chart Type.

18. In the Change Chart Type window, click Exploded pie in 3-D, and then click OK.

 Task 5: Add slicers


1. Click cell B2 to select the PivotTable table that you created in Task 1. If your PivotTable table is not in
cell B2, click anywhere in your PivotTable table to select it.

2. In the PowerPivot Field List, expand Sales Territory, and then drag Country to the Slicers
Horizontal area.

3. Expand Date, and then drag Calendar Year to the Slicers Horizontal area.

4. In the Country slicer, click Australia. The values in the PivotTable table update to show the totals for
Australia only. Note that the two PivotChart charts do not update.
5. In the Country slicer, click Clear Filter.

6. In the Calendar Year slicer, click 2003. The values in the PivotTable table update to show the totals
for 2003 only. Note that the two PivotChart charts do not update.
L10-72 Module 10: Implementing a Tabular Data Model with Microsoft PowerPivot

7. In the Calendar Year slicer, click Clear Filter.

8. Right-click the Calendar Year slicer, click PivotTable Connections, select PivotTable2 and
PivotTable3, and then click OK. This associates the slicer with the two PivotChart charts.
9. In the Calendar Year slicer, click 2003. Note that the PivotTable table and both PivotChart charts
update.

10. In the Calendar Year slicer, click Clear Filter.

11. Right-click the Country slicer, click PivotTable Connections, select PivotTable2, and then click OK.
12. In the Country slicer, click Australia. Note that the PivotTable table and the Sales Amount by
Category by Year PivotChart chart both update, but the Sales Amount by Country PivotChart chart
does not.
13. In the Country slicer, click Clear Filter.

14. On the taskbar, click the Save button, and then close Sales Overview.xlsx.
Lab 10: Using PowerPivot for Excel L10-73

Exercise 3: Sharing a PowerPivot Workbook to PowerPivot Gallery


 Task 1: Upload a PowerPivot for Excel workbook to PowerPivot Gallery
1. Click Start, and then click Internet Explorer and browse to the SharePoint site at http://mia-sqlbi.

2. In Internet Explorer, on the Adventure Works Portal - Home web page, in the Libraries list, click
PowerPivot Gallery.

3. Click the Documents tab, click Upload Document, and then click Upload Document.

4. In the PowerPivot Gallery – Upload Document dialog box, click Browse.

5. In the File name box, navigate to D:\10778A\Labfiles\Lab10\Starter, click Sales Overview.xlsx and
then click Open.
6. In the PowerPivot Gallery – Upload Document dialog box, click OK.

7. If the PowerPivot Gallery – Sales Overview.xlsx dialog box appears, click Save.

 Task 2: Open a PowerPivot for Excel workbook from PowerPivot Gallery


1. On the PowerPivot Gallery web page, click the large Sales Overview icon.
2. Use the Calendar Year and Country slicers to modify the data that is displayed in the PivotTable
table and PivotChart charts.

3. Close Internet Explorer.


L10-74 Module 10: Implementing a Tabular Data Model with Microsoft PowerPivot

Exercise 4: Using a PowerPivot Workbook as a Data Source


 Task 1: Connect to a PowerPivot workbook in PowerPivot Gallery and use it to create
a PivotTable table in Excel
1. Click Start, point to All Programs, click Microsoft Office, and then click Microsoft Excel 2010.

2. In the new workbook, on the ribbon click the Data tab, click Get External Data, click From Other
Sources, and then click From Analysis Services.

3. In the Data Connection Wizard dialog box, on the Connect to Database Server page, in the Server
name field, type http://localhost/PowerPivot Gallery/Sales Overview.xlsx, and then click Next.

4. On the Select Database and Table page, click Next.

5. On the Save Data Connection File and Finish page, click Finish.
6. In the Import Data dialog box, click OK.

7. In the PivotTable Field List, expand Reseller Sales if necessary, and then select Sum of Sales
Amount.

8. Expand Employee if necessary, select Last Name, and then review the data in the PivotTable table.
9. Click File, and then click Close.

10. In the Microsoft Excel dialog box, click Don’t Save.


11. Close Excel and then close Internet Explorer.
L11-75

Module 11: Introduction to DAX


Lab 11: Creating Calculated Columns and
Measures by Using DAX
Exercise 1: Creating Calculated Columns
 Task 1: Prepare the lab environment
1. Ensure that the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab11, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab11\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd), and then click Run as
administrator.
5. Click Yes when prompted to confirm that you want to run the command file, and then wait for the
script to finish.

 Task 2: Create a calculated column by using concatenation


1. Navigate to the D:\10778A\Labfiles\Lab11\Starter folder, and then double-click the Sales
Overview.xlsx file.

1. In the Sales Overview workbook, click the PowerPivot tab, and then on the Microsoft PowerPivot
ribbon, click PowerPivot Window.

2. In the PowerPivot window, click the Employee tab to view the Employee table.

3. In the Employee table, scroll across to the last column, double-click Add Column, type Full Name,
and then press Enter.
4. In the formula bar above the Employee table, type the DAX formula in the following code example,
and then press Enter:

=CONCATENATE('Employee'[First Name], CONCATENATE(" ", 'Employee'[Last Name]))

 Task 3: Create calculated columns to support parent-child relationships


1. In the Employee table, scroll across to the last column, and then double-click Add Column.
2. In the Add Column column header, type Path, and then press Enter.

3. In the formula bar above the Employee table, type the DAX formula in the following code example,
and then press Enter:

=PATH([EmployeeKey], [ParentEmployeeKey])

4. Double-click Add Column, in the Add Column column header, type Employee Level 1, and then
press Enter.
L11-76 Module 11: Introduction to DAX

5. In the formula bar above the Employee table, type the DAX formula in the following code example,
and then press Enter:

=LOOKUPVALUE('Employee'[Full Name], 'Employee'[EmployeeKey], PATHITEM([Path], 1))

6. Double-click Add Column, in the Add Column column header, type Employee Level 2, and then
press Enter.

7. In the formula bar above the Employee table, type the DAX formula in the following code example,
and then press Enter:

=LOOKUPVALUE('Employee' [Full Name], 'Employee' [EmployeeKey], PATHITEM([Path], 2))

8. Double-click Add Column, in the Add Column column header, type Employee Level 3, and then
press Enter.

9. In the formula bar above the Employee table, type the DAX formula in the following code example,
and then press Enter:

=LOOKUPVALUE('Employee' [Full Name], 'Employee' [EmployeeKey], PATHITEM([Path], 3))

10. Double-click Add Column, in the Add Column column header, type Employee Level 4, and then
press Enter.
11. In the formula bar above the Employee table, type the DAX formula in the following code example,
and then press Enter:

=LOOKUPVALUE('Employee' [Full Name], 'Employee' [EmployeeKey], PATHITEM([Path], 4))

12. Click the Path column header, hold down Shift, and then click the Employee Level 1, Employee
Level 2, Employee Level 3, and Employee Level 4 column headers to multiselect them.
13. Right-click the Employee Level 4 column header, and then click Hide from Client Tools.

 Task 4: Create a hierarchy that uses calculated columns


1. On the ribbon, in the View group, click Diagram View.
2. In the Employee table, right-click the Employee table header, click Create Hierarchy, type
Employees, and then press Enter.

3. In the Employee table, click Employee Level 1, drag it onto the Employees hierarchy, and then
release it. (You may need to resize the table to do this.)

4. In the Employee table, click Employee Level 2, drag it onto the Employees hierarchy, and then
release it.

5. In the Employee table, click Employee Level 3, drag it onto the Employees hierarchy, and then
release it.

6. In the Employee table, click Employee Level 4, drag it onto the Employees hierarchy, and then
release it.
Lab 11: Creating Calculated Columns and Measures by Using DAX L11-77

 Task 5: Create a PivotTable table that contains the Employees hierarchy


1. In the PowerPivot window, in the upper-left corner, click the Switch to Workbook button.

2. In the Microsoft Excel workbook, right-click the Sheet2 tab, click Rename, type Employee Sales, and
then press Enter.
3. Click in cell B1, on the ribbon, on the PowerPivot tab, click PivotTable, and then click PivotTable.

4. In the Create PivotTable dialog box, click Existing Worksheet, and then click OK.

5. In the PowerPivot Field List, expand Employee, and then drag the Employees hierarchy to the Row
Labels area.
6. Expand Reseller Sales, and then select Sales Amount to add it to the Values area.

7. In the PivotTable table, in the Row Labels column, expand Ken Sanchez, expand Brian Welcker, and
then expand Amy Alberts.

8. Right-click Ken Sanchez, click Show/Hide Fields, and then click Employee Level 1 to clear it.

9. Right-click Brian Welcker, click Show/Hide Fields, and then click Employee Level 2 to clear it.

10. Click File, and then click Save.


L11-78 Module 11: Introduction to DAX

Exercise 2: Creating Measures


 Task 1: Create a measure that calculates total sales for all employees
1. In the Sales Overview.xlsx Excel workbook, click any cell in the PivotTable on the Employee Sales
worksheet, and in the PowerPivot Field List, right-click Reseller Sales, and then click Add New
Measure.

2. In the Measure Settings dialog box, in the Measure Name (all PivotTables) field, type Total Sales
for All Employees.

3. In the Formula field, type the formula in the following code example after the equals sign (=), and
then click Check Formula:

CALCULATE([Sum of Sales Amount], ALL('Employee'))

4. In the Category field, click Currency, and then click OK.

5. In the PowerPivot Field List, in Reseller Sales, clear Total Sales for All Employees.

 Task 2: Create a measure that calculates percentage of sales per employee


1. In the PowerPivot Field List, right-click Reseller Sales, and then click Add New Measure.
2. In the Measure Settings dialog box, in the Measure Name (all PivotTables) field, type Percentage
of Sales.

3. In the Formula field, type the formula in the following code example after the equals sign (=):

[Sum of Sales Amount]/[Total Sales for All Employees]

4. In the Category field, click Number, in the Format field, select Percentage, and then click OK.

 Task 3: Add conditional formatting to the PivotTable table


1. In the PivotTable table, expand Stephen Jiang and Syed Abbas.

2. Select all of the rows in the Percentage of Sales column, but do not include the column header or
the Grand Total row value.

3. Click the Home tab, in the Styles area, click Conditional Formatting, click Data Bars, and then
under Gradient Fill, click Blue Data Bar.

4. Click File, and then click Save.


Lab 11: Creating Calculated Columns and Measures by Using DAX L11-79

Exercise 3: Using Time Intelligence


 Task 1: Create a measure that uses a time intelligence function
1. Click the PowerPivot tab, and then click PowerPivot Window.

2. If necessary, on the ribbon, in the View group, click Data View. Click the Date tab to select the Date
table, and then on the ribbon, click the Design tab.

3. Click Mark as Date Table, and then click Mark as Date Table.

4. In the Mark as Date Table dialog box, in the Date field, ensure that FullDateAlternateKey is
selected, and then click OK.

5. Click the Switch to Workbook button.


6. Click the PowerPivot tab, click PivotTable, and then click PivotTable.

7. In the Create PivotTable dialog box, ensure New Worksheet is selected, and click OK.

8. Right-click the new worksheet tab, click Rename, type Year on Year Growth, and then press Enter.
9. In the PivotTable Field List, expand Date, and then drag Calendar Year to the Row Labels area.

10. Expand Reseller Sales, and then select Sales Amount.

11. Right-click Reseller Sales, and then click Add New Measure.
12. In the Measure Settings dialog box, in the Measure Name (all PivotTables) field, type Previous
Year.

13. In the Formula field, type the formula in the following code example after the equals sign (=):

CALCULATE([Sum of Sales Amount], DATEADD('Date'[FullDateAlternateKey], -1, YEAR))

14. In the Category field, click Currency, and then click OK.
15. In the PowerPivot Field List, in Reseller Sales, clear Previous Year.

 Task 2: Create a measure that uses conditional logic


1. In the PowerPivot Field List, right-click Reseller Sales, and then click Add New Measure.

2. In the Measure Settings dialog box, in the Measure Name (all PivotTables) field, type Year on
Year Growth.

3. In the Formula field, type the formula in the following code example after the equals sign (=):

IF([Previous Year], ([Sum of Sales Amount] - [Previous Year])/[Previous Year],


BLANK())

4. In the Category field, click Number, in the Format field, select Percentage, and then click OK.

Note You will use the Year on Year Growth measure in the next exercise.
L11-80 Module 11: Introduction to DAX

Exercise 4: Creating a Dynamic Measure


 Task 1: Create a linked table
1. Click the Time Period worksheet tab.

2. Select cells A1 to A4, click the PowerPivot tab, and then click Create Linked Table.
3. In the Create Table dialog box, select My table has headers, and then click OK.

4. In the PowerPivot window, right-click the Table 1 tab, click Rename, type Time Period, and then
press Enter.

 Task 2: Create a measure that checks whether inputs have a single value
1. In the PowerPivot window, in the upper-left corner, click the Switch to Workbook button.

2. Click the Time Period worksheet tab, click the PowerPivot tab, click PivotTable, and then click
PivotTable.
3. In the Create PivotTable dialog box, click OK.

4. Right-click the new worksheet tab, click Rename, type Dynamic Time, and then press Enter.
5. In the PowerPivot Field List, expand Time Period, and then drag Period to the Row Labels area.

6. Expand Date, and then drag Calendar Year to the Column Labels area.

7. Right-click Reseller Sales, and then click Add New Measure.

8. In the Measure Settings dialog box, in the Measure Name (all PivotTables) field, type Check
Single Values.

9. In the Formula field, type the formula in the following code example after the equals sign (=), and
then click OK:

IF(HASONEVALUE('Time Period'[Period]) && HASONEVALUE('Date'[Calendar Year]), TRUE(),


FALSE())

10. In the PowerPivot Field List, in Reseller Sales, clear Check Single Values.

 Task 3: Create a measure that dynamically calculates values


1. In the PowerPivot Field List, right-click Reseller Sales, and then click Add New Measure.
2. In the Measure Settings dialog box, in the Measure Name (all PivotTables) field, type Sales Over
Time.

3. In the Formula field, type the formula in the following code example after the equals sign(=):

IF([Check Single Values], SWITCH(VALUES('Time Period'[Period]), "Current Year", [Sum


of Sales Amount], "Previous Year", [Previous Year], "YOY Growth",
IF(NOT(ISBLANK([Previous Year])), [Sum of Sales Amount] – [Previous Year], BLANK())),
BLANK())

4. In the Category field, click Currency, and then click OK.

5. Click File, click Save, and then close the Sales Overview workbook.
L12-81

Module 12: Implementing an Analysis Services Tabular Data


Model
Lab 12: Working with an Analysis Services
Tabular Data Model
Exercise 1: Creating an Analysis Services Tabular Data Model Project from a
PowerPivot Workbook
 Task 1: Prepare the lab environment
1. Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab12, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab12\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd) and click Run as administrator.
5. Click Yes when prompted to confirm you want to run the command file, and wait for the script to
finish.

 Task 2: Review the Reseller Sales Analysis PowerPivot workbook


1. In the D:\10778A\Labfiles\Lab12\Starter folder, double-click the file Reseller Sales Analysis.xlsx. This
workbook does not contain any PivotTable tables or PivotChart charts, but it does contain PowerPivot
data.

2. In the Reseller Sales Analysis.xlsx workbook, click the PowerPivot tab, and then click PowerPivot
Window. The PowerPivot window opens behind the workbook, so minimize the workbook to see it.

3. In the PowerPivot window, note that there are no linked tables in the Tabular Data Model.

4. Click on the Employee tab. Note that the Employee table does not contain any calculated columns.
Repeat this step for the other tables.
5. Close the PowerPivot window, and then close the Reseller Sales Analysis.xlsx workbook. If you are
prompted to save the changes to the workbook, click Don’t Save.

 Task 3: Create a tabular data model project by using SQL Server Data Tools
1. Click Start, click All Programs, click Microsoft SQL Server 2012, and then click SQL Server SQL
Server Data Tools.

2. On the Start Page tab, click New Project.

3. In the New Project dialog box, in the Installed Templates pane, expand Business Intelligence, click
Analysis Services, and then click Import from PowerPivot.

4. In the Name box, type Reseller Sales, and then click Browse to select the
D:\10778A\Labfiles\Lab12\Starter folder.

5. In the New Project dialog box, click OK.


L12-82 Module 12: Implementing an Analysis Services Tabular Data Model

6. If the Workspace and Deployment Server Configuration dialog box appears, in the Default Server
list, select localhost\SQL2, and then click OK. If you have previously configured this setting, you will
not be prompted (you can change the setting in the Analysis Services section of the tool options for
SQL Server Data Tools.)

7. In the Open dialog box, navigate to the D:\10778A\Labfiles\Lab12\Starter folder, click Reseller Sales
Analysis.xlsx, and then click Open. When prompted to import the metadata but not the data, click
Yes. Then wait until the creation of the Reseller Sales project completes.

 Task 4: Set the impersonation account for the data connection


1. On the Model menu, click Existing Connections.

2. In the Existing Connections dialog box, ensure the connection to the AdventureWorksDW
database is selected and click Edit, and then in the Edit Connection dialog box, click Impersonation.
3. In the Impersonation Information dialog box, click Specific Windows user name and password,
in the User Name field, type ADVENTUREWORKS\ServiceAcct, in the Password field, type
Pa$$w0rd, and then click OK.

4. In the Edit Connection dialog box, click Save, and then in the Existing Connections dialog box,
click Process.
5. In the Data Processing dialog box, after all of the tables have been processed, click Close. Then in
the Existing Connections dialog box, click Close. The model now shows the data in each table.

 Task 5: Explore the workspace database


1. Click Start, click All Programs, click Microsoft SQL Server 2012, and then click SQL Server
Management Studio.
2. In the Connect to Server dialog box, in the Server Type list, select Analysis Services, in the Server
Name dialog box, type localhost\SQL2, and then click Connect.

3. In Object Explorer, expand localhost\SQL2, expand Databases, and then expand the workspace
database, which has a name that begins Reseller Sales_Student.

Note Workspace databases for Tabular Data Model projects have a GUID in their name.
The exact value of the GUID will vary between different computers, and consequently, so
will the name of the workspace database.

4. Expand Tables and examine the tables in the workspace database. Note that they are the same as the
tables in the Reseller Sales Analysis.xlsx PowerPivot workbook that you used to create the Reseller
Sales project.

5. Minimize SQL Server Management Studio.


Lab 12: Working with an Analysis Services Tabular Data Model L12-83

Exercise 2: Implementing a Perspective


 Task 1: Create measure calculations
1. In SQL Server Data Tools, on the Reseller Sales table tab, click the column header for the
SalesAmount column and then on the Column menu, point to AutoSum, and click Sum. This
creates a measure calculation for the SalesAmount column.

2. Repeat the previous step to create a Sum measure calculation for the TotalProductCost column.
Then on the File menu, click Save All.

3. On the Model menu, point to Process and click Process All. In the Data Processing dialog, when
processing is complete. Click Close.

 Task 2: Create a perspective


1. In SQL Server Data Tools, on the Model menu, click Perspectives.

2. In the Perspectives dialog box, click New Perspective.

3. Press Delete to delete the text New Perspective, type No Employee Data and then press Enter.

4. In the No Employee Data column, in the Tables row, click the empty check box to select all of the
tables.

5. In the No Employee Data column, clear the Employee and Sales Quota checkboxes, and then click
OK.

 Task 3: Test a perspective


1. On the Model menu, click Analyze in Excel. Then in the Analyze in Excel dialog box, ensure that
Current Windows User is selected, in the Perspective drop-down list, select (Default), and then
click OK.
2. In Excel, in the PivotTable Field List pane, select Sum of SalesAmount. Then in the Employee table,
select EmailAddress. Note that the PivotTable shows sales by employee.
3. Close Excel without saving any changes.

4. In SQL Server Data Tools, on the Model menu, click Analyze in Excel. Then in the Analyze in Excel
dialog box, ensure that Current Windows User is selected, in the Perspective drop-down list, select
No Employee Data, and then click OK.

5. In Excel, in the PivotTable Field List pane, select Sum of SalesAmount. However, note that the
Employee and Sales Quota tables are not available. Instead, in the Product Category table, select
Category to view sales by product category.

6. Close Excel without saving any changes.


L12-84 Module 12: Implementing an Analysis Services Tabular Data Model

Exercise 3: Implementing Partitions


 Task 1: Create partitions
1. In SQL Server Data Tools, on the Table menu, click Partitions.

2. In the Partition Manager dialog box, in the Table list, select Reseller Sales.
3. Click New, and then in the Partition Name field, type 2001.

4. Click the Query Editor button.

5. In the SQL Statement field, under the existing Transact-SQL statement, type the following WHERE
clause, and then click Validate, to verify that the syntax is valid:

WHERE DATEPART(YEAR, OrderDate)=2001

6. Repeat steps 3 to 5 to create three more partitions by using the information in the following table:

Partition Name SQL WHERE Clause


2002 WHERE DATEPART(YEAR, OrderDate)=2002

2003 WHERE DATEPART(YEAR, OrderDate)=2003

2004 WHERE DATEPART(YEAR, OrderDate)=2004

7. When all of the partitions have been created, in the Partition Manager dialog box, click OK.

8. Click the Reseller Sales tab, and on the Model menu, point to Process and click Process Partitions.

9. In the Process Partitions dialog box, in the Process column, select 2001, 2002, 2003, and 2004, and
then click OK.
10. In the Data Processing dialog box, wait until the Status column displays Success for all of the
partitions, and then click Close.
11. On the Table menu, click Partitions.

12. In the Partition Manager dialog box, in the Table list, click Reseller Sales.

13. In the Partitions table, in the Last Processed column, note that the partitions that you created in
steps 1 to 6 have been processed. Look in the # Rows column, and note the number of rows that
each partition contains.

14. In the Partitions table, click the ResellerSales partition, and click Delete. Then click OK.

 Task 2: View partitions in the workspace database


1. Maximize SQL Server Management Studio, and in Object Explorer, in the workspace database for your
project, right-click the Reseller Sales table and then click Partitions.

2. Review the # Rows and the Last Processed columns for each partition. Note that they match the
values that you saw in the Partition Manager dialog box in the Reseller Sales project in SQL Server
Data Tools.

3. In the Partitions dialog box, click Cancel.

4. Minimize SQL Server Management Studio.


Lab 12: Working with an Analysis Services Tabular Data Model L12-85

Exercise 4: Deploying an Analysis Services Tabular Data Model


 Task 1: Deploy the Reseller Sales project
1. In SQL Server Data Tools, in Solution Explorer, right-click Reseller Sales, and then click Properties.

2. In the Reseller Sales Property Pages dialog box, in the Deployment Server area, in the Server field,
ensure that the server name is localhost\SQL2, and then click Cancel.

3. In Solution Explorer, right-click Reseller Sales, and then click Deploy.

4. In the Deploy dialog box, view the Status column. When the Status column displays Success for
every item in the Work Item column, click Close.

 Task 2: View the deployed tabular database


1. Maximize SQL Server Management Studio, and in Object Explorer, right-click the Databases node,
and then click Refresh. Note that the database has been deployed with the name Reseller Sales.

2. Under the Databases, node, expand Reseller Sales, expand Connections, expand Tables, and then
review the items in the Connections and Tables folders.

3. In Windows Explorer, browse to the C:\Program Files\Microsoft SQL Server\MSAS11.SQL2\OLAP


\Data folder, double-click the Reseller Sales.0.db folder. If prompted, click Continue.

4. Review the items in the Reseller Sales.0.db folder. These are the physical files for the deployed
database.
5. Close Windows Explorer.
L12-86 Module 12: Implementing an Analysis Services Tabular Data Model

Exercise 5: Enabling Access to a Tabular Data Model


 Task 1: Enable the BI Semantic Model Connection content type
1. Start Internet Explorer and browse to the SharePoint site at http://mia-sqlbi. Then, on the Adventure
Works Portal Home page, in the Libraries list in the Quick Launch area on the left of the site, click
PowerPivot Gallery.

2. On the ribbon, in the Library Tools section, click Library; and in the Settings area, click Library
Settings.

3. Under the General Settings area, if a Content Types section exists, review the content types enabled
for this document library. If no Content Types section exists or the BI Semantic Model Connection
is not listed, perform the following steps to enable management of content types and add it.

1. In General Settings, click Advanced settings.

2. In Content Types, in the Allow management of content types? section, click Yes, and then
click OK.
3. On the Document Library Settings page, in the Content Types section, click Add from
existing site content types.

4. In the Select site content types from: list, click Business Intelligence.
5. In the Available Site Content Types list, click BI Semantic Model Connection, click Add, and
then click OK.

 Task 2: Create a BI semantic model connection


1. In the Adventure Works Portal SharePoint site, in the Libraries list in the Quick Launch area, click
PowerPivot Gallery.

2. On the ribbon, in the Library Tools section, click Documents; and then click the New Document
drop-down list and click BI Semantic Model Connection.

3. On the New BI Semantic Model Connection page, in the File Name field, type Reseller Sales
Connection, in the Workbook URL or Server Name field, type localhost\SQL2, in the Database (if
connecting to a server) field, type Reseller Sales, and then click OK.
4. Verify that the Reseller Sales Connection BI semantic model connection is added to the PowerPivot
Gallery.
Lab 12: Working with an Analysis Services Tabular Data Model L12-87

 Task 3: Use a BI semantic model connection


1. On PowerPivot Gallery page, click the Open New Excel Workbook icon for the Reseller Sales
Connection BI semantic model connection you created in the previous task.

2. When prompted, click Open. Then, when the download has completed, click Open again.
3. In Excel, in the Microsoft Excel Security Notice dialog box, click Enable.

4. In the Select Table dialog box, ensure that Model is selected, and then click OK.

5. In the PivotTable Field List pane, select Sum of SalesAmount. Then in the Sales Territory table,
select SalesTerritoryRegion. Note that the PivotTable shows sales by sales territory.
6. Close Excel without saving any changes.

7. Keep Internet Explorer open, you will use it in the next exercise.
L12-88 Module 12: Implementing an Analysis Services Tabular Data Model

Exercise 6: Configuring DirectQuery Storage Mode


 Task 1: Create a SQL Server Profiler trace
1. Click Start, click All Programs, click Microsoft SQL Server 2012, click Performance Tools, and then
click SQL Server Profiler.

2. On the File menu, click New Trace.

3. In the Connect to Server dialog box, in the Server Type list, select Analysis Services, in the Server
Name dialog box, select localhost\SQL2, and then click Connect.

4. In the Trace Properties dialog box, change the Trace name to BI Queries, and then click the
Events Selection tab.

5. In the table of events, in the Events column, clear all events other than Query Begin and Query End.

6. Select the Show all events check box.

7. In the table of events, in the Events column, in the Query Processing section, select the Direct
Query Begin, Direct Query End, VertiPaq SE Query Begin, and VertiPaq SE Query End
checkboxes, and then click Run.

8. Minimize SQL Server Profiler.

 Task 2: Test InMemory storage mode


1. In Internet Explorer, on PowerPivot Gallery page, click the Reseller Sales Connection BI semantic
model connection you created in the previous exercise. This creates a new Power View report.

2. In the list of fields to the right, expand Reseller Sales and select Sales Amount. The total sales
amount is displayed in the report.

3. Maximize SQL Server Profiler and view the trace. Note that the EventClass entries include Query
Begin, VertiPaq SE Query Begin, VertiPaq SE Query End, and Query End.
4. Minimize SQL Server Profiler.

 Task 3: Enable Direct Query storage mode


1. Maximize SQL Server Management Studio and in Object Explorer, under Databases, right-click
Reseller Sales, and then click Properties.
2. In the Database Properties – Reseller Sales dialog box, on the Database page, in the General
section, in the DirectQueryMode list, click DirectQuery, and then click OK.

3. Minimize SQL Server Management Studio. You will use it again in the next exercise.

 Task 4: Test Direct Query storage mode


1. Maximize Internet Explorer and in the list of fields, expand Product Category and click Category.
The report now shows sales by product category.

2. Close Internet Explorer, clicking Leave this page when prompted.

3. Maximize SQL Server Profiler and view the trace. Note that the EventClass entries now include Query
Begin, DirectQuery Begin, DirectQuery End, and Query End.

4. On the File menu, click Stop Trace. Then close SQL Server Profiler.
Lab 12: Working with an Analysis Services Tabular Data Model L12-89

Exercise 7: Implementing Security in a Tabular Data Model


 Task 1: Disable Direct Query storage mode
1. Maximize SQL Server Management Studio and in Object Explorer, under Databases, right-click
Reseller Sales, and then click Properties.

2. In the Database Properties – Reseller Sales dialog box, on the Database page, in the General
section, in the DirectQueryMode list, click InMemory, and then click OK.
3. Close SQL Server Management Studio.

 Task 2: Create roles and apply database permissions


1. In SQL Server Data Tools, on the Model menu, click Roles.

2. In the Role Manager dialog box, click New.


3. In the Name column, type Germany, click in the Permissions column, and then in the list box, click
Read.

4. Repeat the previous two steps to create the following roles: Canada, France, United Kingdom,
United States, and Australia. Give all roles the Read database permission. Do not close the Role
Manager dialog box.

 Task 3: Apply row-level permissions to roles


1. In the Role Manager dialog box, click Germany.

2. On the Row Filters tab, in the DAX Filter column, double-click the Sales Territory row, and type the
following DAX expression:

=[SalesTerritoryCountry]="Germany"

3. Repeat steps 1 and 2 to apply row filters to the other roles by using the values in the following table:

Role Name DAX Filter Expression


Canada =[SalesTerritoryCountry]=“Canada”

France =[SalesTerritoryCountry]=“France”

United Kingdom =[SalesTerritoryCountry]=“United Kingdom”

United States =[SalesTerritoryCountry]=“United States”

Australia =[SalesTerritoryCountry]=“Australia”

4. In the Role Manager dialog box, click OK.

5. On the File menu, click Save All.


L12-90 Module 12: Implementing an Analysis Services Tabular Data Model

 Task 4: Test row-level permissions


1. On the menu bar, click Model, and then click Analyze in Excel.

2. In the Analyze in Excel dialog box, select Role, and in the drop-down list, select France and click OK.
Then in the Analyze in Excel dialog box click OK.
3. In Excel, in the PivotTable Field List, under Reseller Sales, select Sum of SalesAmount.

4. In the Sales Territory table, select SalesTerritoryCountry. Note that in the PivotTable, France is the
only country that is displayed.

5. Close Excel without saving the workbook.


6. Close SQL Server Data Tools.
L13-91

Module 13: Creating Data Visualizations with Power View


Lab 13: Creating Interactive Reports with
Power View
Exercise 1: Configuring a Tabular Data Model for Power View
 Task 1: Prepare the Lab Environment
1. Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab13, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab13\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd) and click Run as administrator.
5. Click Yes when prompted to confirm you want to run the command file, and wait for the script to
finish.

 Task 2: Define reporting properties


1. In the D:\10778A\Labfiles\Lab13\Starter folder, double-click Reseller and Internet Sales.sln.
2. View the Model.bim model in the project, and on the Product Category tab, click the Product
Category column header. Then in the Properties window, in the Reporting Properties group, click
Default Label, and in the drop down list, click True.

3. On the Reseller Sales tab, click the Order Quantity column. Then in the Properties window, in the
Reporting Properties group, click Summarize By, and in the drop down list, change the value to
Sum.
4. On the Internet Sales tab, click the Order Quantity column. Then in the Properties window, in the
Reporting Properties group, click Summarize By, and in the drop down list, change the value to
Sum.

5. On the Date tab, click the Month column. Then in the Properties window, in the Basic group, in the
Sort by Column drop-down list, select MonthNumberOfYear.

6. On the tool bar, click the Save All button.

 Task 3: Deploy the project


1. In Solution Explorer, right click Reseller and Internet Sales and then click Deploy. If you are
prompted for impersonation credentials, specify the user name ADVENTUREWORKS\ServiceAcct
and the password Pa$$w0rd.

2. In the Deploy dialog box, when deployment has completed successfully, click Close.

3. Close SQL Server Data Tools.


L13-92 Module 13: Creating Data Visualizations with Power View

 Task 4: Create a BI semantic model connection


1. Start Internet Explorer and browse to the SharePoint site at http://mia-sqlbi. Then, on the Adventure
Works Portal Home page, in the Libraries list in the Quick Launch area on the left of the site, click
PowerPivot Gallery.

2. On the ribbon, in the Library Tools section, click Library; and in the Settings area, click Library
Settings.

3. Under the General Settings area, if a Content Types section exists, review the content types enabled
for this document library. If no Content Types section exists or the BI Semantic Model Connection
is not listed, perform the following steps to enable management of content types and add it.

1. In General Settings, click Advanced settings.

2. In Content Types, in the Allow management of content types? section, click Yes, and then
click OK.

3. On the Document Library Settings page, in the Content Types section, click Add from
existing site content types.

4. In the Select site content types from: list, click Business Intelligence.

5. In the Available Site Content Types list, click BI Semantic Model Connection, click Add, and
then click OK.
4. In the Adventure Works Portal Home page at http://mia-sqlbi, in the Libraries list in the Quick
Launch area, click PowerPivot Gallery.
5. On the ribbon, in the Library Tools section, click Documents; and then click the New Document
drop-down list and click BI Semantic Model Connection.

6. On the New BI Semantic Model Connection page, in the File Name field, type Reseller and
Internet Sales, in the Workbook URL or Server Name field, type localhost\SQL2, in the Database
(if connecting to a server) field, type Reseller and Internet Sales, and then click OK.

7. Verify that the Reseller and Internet Sales BI semantic model connection is added to the PowerPivot
Gallery.
Lab 13: Creating Interactive Reports with Power View L13-93

Exercise 2: Creating a Simple Power View Report


 Task 1: Create a Power View report
1. On the PowerPivot Gallery page, to the right of Reseller and Internet Sales, click the Create
Power View Report button.

2. In the Power View window, in the View area, click Click here to add title, and then type Internet
Sales by Calendar Year and Month.
3. In the fields pane, expand Internet Sales, and then select Internet Sales Total.

4. On the ribbon, on the Design tab, in the Visualizations area, click Column.

5. Click and drag the lower right corner of the chart to resize it and fill the available space.
6. In the fields pane, expand Date, and then select Calendar Year to add this column to the Axis field
in the Layout Section.

7. Select Month to add this column to the Series field in the Layout Section.

8. In the fields pane, expand Geography, and then select Country Region to add this column to the
Vertical Multiples field in the Layout Section.

 Task 2: Add a Card visualization


1. Drag the lower right corner of the chart to resize it to create some space to the right of the chart.
Then click in the blank space to the right of the column chart.
2. In the fields pane, under Internet Sales, select Internet Sales Total.

3. On the ribbon, on the Design tab, expand the Visualizations area, and in the Other category, click
Card.
4. In the fields pane, expand Product Category, and select Product Category.

5. Click and drag the corner of the Card to resize it as necessary.

 Task 3: Add a filter


1. Click in a blank area of the canvas, and then on the ribbon, on the Home tab, in the Filters area, click
Filters Area.

2. In the fields pane, expand Product Category if necessary, drag Product Category to the filters tab,
and then select the Bikes and Clothing check boxes. The report is filtered to show data for only the
selected categories.
L13-94 Module 13: Creating Data Visualizations with Power View

Exercise 3: Creating Interactive Visualizations


 Task 1: Create a new view
1. On the ribbon, in the Home tab, in the Views group, in the New View drop-down list, click New
View.

2. In the View area, click Click here to add title, and then type Reseller Sales by Calendar Year and
Country.
3. In the ribbon, on the Home tab, click Filters Area to hide the filters tab.

 Task 2: Add tiles


1. In the Field List, under Product Category, select Product Category, and then on the ribbon, in the
Visualizations group, click Tiles.

2. Resize the visualization so that it fills the view area.


3. Click the Product Category table under the blue line beneath the product category names, and then
in the fields pane, expand Reseller Sales, and select Reseller Sales Total.

4. In the fields pane, in the Fields list, click the drop-down arrow for the Product Category field and
click Remove Field to remove it from the table.

5. On the ribbon, on the Design tab, in the Visualizations area, click Bar. Then resize the bar chart area
so you can see the bar.
6. In the fields pane, under Date, select Calendar Year to add this field to the Axis box in the Layout
Section.

7. In the fields pane, expand Sales Territory, and select Country to add this field to the Series box in
the Layout Section.

8. Resize the chart, leaving space below it and to the right of it for other visualizations.

9. Click in the blank area to the right of the bar chart, and then in the fields pane, under Reseller Sales,
select Reseller Sales Total, Reseller Profit, and Order Quantity.

10. On the ribbon, on the Design tab, in the Visualizations area, click Card. Then resize the card area to
fill the available height to the right of the bar chart.

11. In the fields pane, under Product Category, click Product Category.

12. Click in the blank area under the bar chart, and then in the fields pane, in Reseller Sales, click
Reseller Sales Total.

13. On the ribbon, on the Design tab, in the Visualizations area, click Column.

14. In the fields pane, expand Employee, and select Last Name to add this field to the Axis box in the
Layout Section, and then under Date, select Calendar Year to add this field to the Series box.

15. Resize the visualizations as required.

16. In the navigation strip, click each of the category names and note that the charts update
automatically to show sales data for the selected category.
Lab 13: Creating Interactive Reports with Power View L13-95

Exercise 4: Creating a Scatter Chart and a Play Axis


 Task 1: Create a new view
1. On the ribbon, in the Home tab, in the Views group, in the New View drop-down list, click New
View.

2. Click Click here to add title, and then type Reseller Profit Over Time.

 Task 2: Create a scatter chart


1. In the fields pane, under Reseller Sales, click Reseller Sales Total.

2. On the ribbon, on the Design tab, in the Visualizations area, click Scatter.
3. Click and drag the corner of the chart to resize it to fill the available space.

4. In the fields pane, under Reseller Sales, click Total Product Cost to add this field to the Y Value box.

5. In the fields pane, under Reseller Sales, click Reseller Profit to add this field to the Size box.
6. In the fields pane, expand Product Subcategory, and select Product Subcategory to add this field
to the Details box .
7. In the fields pane, under Date, click and drag Calendar Year to the Play Axis box.

8. If the filters pane is not visible, on the ribbon, on the Home tab, click Filters Area.

9. In the fields pane, under Product Category, drag Product Category to the filters pane, and then
select the Bikes check box.

10. On the ribbon, in the Chart Tools area, click the Layout tab. Then in the Labels area, click Data
Labels, and then click Right.
11. In the chart, on the Calendar Year play axis, click the play button.
12. Note that for Mountain Bikes and Road Bikes, Reseller Sales Total and Total Product Cost both
increase over time, before the Total Product Cost for Road Bikes starts to fall in 2003. When
Touring Bikes were first introduced, the Total Product Cost was high relative to the ResellerSales
Total value, but the Reseller Sales Total value rapidly increased over time, while the Total Product
Cost remained quite static over the same period.
L13-96 Module 13: Creating Data Visualizations with Power View

Exercise 5: Exporting a Power View Report to Excel


 Task 1: Save the report
1. On the ribbon, click File, and then click Save.

2. In the Save As dialog box, change the File name to Sales Report and click Save.
3. On the ribbon, click File, and then click Export to PowerPoint. When a message box informs you
that the export is complete, click Save, and save the presentation as Sales Report.pptx in the
D:\10778A\Labfiles\Lab13\Starter folder.

4. Close Internet Explorer.

 Task 2: View the presentation


1. In the D:\10778A\Labfiles\Lab13\Starter folder, double-click Sales Report.pptx to open it in
Microsoft PowerPoint.

2. In the ribbon, on the Slide Show tab, click From Beginning. If a message warns you about a graphics
card issue, click OK.

3. View the first slide, and then move the mouse to the bottom left of the slide and click the Next
button.

4. On the Reseller Sales by Calendar Year and Country slide, click the click to interact button at the
bottom right.
5. When the slide is redrawn, in the list of categories along the top of the main report area, click Bikes
and note that the data visualizations are updated to show sales for bikes.
6. Click outside of the border around the visualizations area to move to the next slide.
7. On the Reseller Profit Over Time slide, click the click to interact button at the bottom right.

8. When the slide is redrawn, click the Play button for the Calendar Year axis.
9. Press Esc to stop the slide show, and then close PowerPoint without saving any changes.
L14-97

Module 14: Performing Predictive Analysis with Data Mining


Lab 14: Using Data Mining to Support a
Marketing Campaign
Exercise 1: Using Table Analysis Tools
 Task 1: Prepare the lab environment
1. Ensure the MIA-DC1 and MIA-SQLBI virtual machines are both running, and then log on to
MIA-SQLBI as ADVENTUREWORKS\Student with the password Pa$$w0rd.

2. Click Start, and then click Computer.


3. Double-click Local Disk (D:), double-click 10778A, double-click Labfiles, double-click Lab14, and
then double-click Starter to view the contents of the D:\10778A\Labfiles\Lab14\Starter folder.

4. Right-click the Setup Windows Command Script file (Setup.cmd) and click Run as administrator.
5. Click Yes when prompted to confirm you want to run the command file, and wait for the script to
finish.

 Task 2: Use the Data Mining Add-in for Excel to create a connection to
Analysis Services
1. In the D:\10778A\Labfiles\Lab14\Starter folder, double click Customer Data For Data Mining.xlsx to
open it in Microsoft Excel.
2. On the ribbon, in the Table Tools group, click the Analyze tab, in the Connection group, click the
connection icon (which is labeled with the name of the last connection used or <No Connection>).
Then in the Analysis Services Connections dialog box, click New.

3. In the Connect to Analysis Services dialog box, in the Server name field, type localhost, in the
Catalog name drop-down list, click DMAddinsDB, and then click OK.
4. In the Analysis Services Connections dialog box, click Close.

 Task 3: Use the Data Mining Add-in for Excel table analysis tools
1. On the ribbon, click Analyze Key Influencers.

2. In the SQL Server Data Mining - Analyze Key Influencers dialog box, in the Column Selection
drop-down list, click Purchased Bike, and then click Run.

3. In the SQL Server Data Mining – Discrimination based on key influencers dialog box, in the
Compare Value 1 drop-down list, click Yes, and then in the to Value 2 drop-down list, click No.

4. Click Add Report, and then click Close.

5. Review the Key Influencers Report for ‘Purchased Bike’ report. And note the values that most
strongly correlate with a customer purchasing a bike.
6. Click File, click Exit, and then in the Microsoft Excel dialog box, click Save.
L14-98 Module 14: Performing Predictive Analysis with Data Mining

Exercise 2: Creating a Data Mining Model


 Task 1: Create a data mining project
1. Click Start, click All Programs, click Microsoft SQL Server 2012, and then click SQL Server Data
Tools.

2. In SQL Server Data Tools, click File, click New, click Project.

3. In the New Project dialog box, click Analysis Services Multidimensional and Data Mining Project,
in the Name field, type, AW Data Mining, in the Location field, browse to the
D:\10778A\Labfiles\Lab14\Starter folder, click Select Folder, 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, and then
on the Select how to define the connection page, click New.

6. In the Connection Manager dialog box, in the Server name field, type localhost, in the Select or
enter a database name drop-down list, click AdventureWorksDW, and then click OK.

7. In the Data Source Wizard, on the Select how to define the connection page, click Next, on the
Impersonation Information page, click Use a specific Windows user name and password, in the
User name field, type ADVENTUREWORKS\Student, in the Password field, type Pa$$w0rd, and
then click Next.

8. On the Completing the Wizard page, click Finish.


9. In Solution Explorer, right-click Data Source Views, and then click New Data Source View.

10. In the Data Source View Wizard, on the Welcome to the Data Source View Wizard page, click
Next, on the Select a Data Source page, ensure that Adventure Works DW is selected, and then
click Next.
11. 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.
12. On the Completing the Wizard page, in the Name field, type Adventure Works DW DM View,
and then click Finish.

 Task 2: Create a data mining structure and a data mining model


1. In Solution Explorer, right-click Mining Structures, click New Mining Structure, and then in the
Data Mining Wizard, on the Welcome to the Data Mining Wizard page, click Next.

2. On the Select the Definition Method page, ensure that From existing relational database or data
warehouse is selected, and then click Next.

3. On the Create the Data Mining Structure page, ensure that Create mining structure with mining
model is selected, in the Which data mining technique do you want to use? drop-down list, click
Microsoft Decision Trees, and then click Next.
4. On the Select a Data Source View page, click Next.

5. On the Specify Table Types page, in the vTargetMail row, select the check box in the Case column,
and then click Next.
Lab 14: Using Data Mining to Support a Marketing Campaign L14-99

6. 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, in the CustomerKey row, select the check box
in the Key column, in the Input column select all of the rows except CustomerKey and BikeBuyer,
and then click Next.

7. 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 be
Discrete. Then click Next.
8. On the Create Testing Set page, note that the Percentage of data for testing value is 30%, and
then click Next.

9. On the Completing the Wizard page, in the Mining structure name field, type Purchase
Prediction in the Mining model name field, type Purchase Decision Tree and then click Finish.

 Task 3: Deploy the data mining model


• On the menu bar, click Build, and then click Deploy AW Data Mining.
L14-100 Module 14: Performing Predictive Analysis with Data Mining

Exercise 3: Using the Data Mining Add-in for Excel to Modify the Data
Mining Structure
 Task 1: Connect to the AW Data Mining model
1. Click Start, click All Programs, click Microsoft Office, and then click Microsoft Excel 2010.

2. On the ribbon, click the Data Mining tab, in the Connection area, click the connection icon (which is
labeled with the name of the last connection used or <No Connection>), and then in the Analysis
Services Connections dialog box, click New.

3. In the Connect to Analysis Services dialog box, in the Server name field, type localhost, in the
Catalog name drop-down list, click AW Data Mining, and then click OK.

4. In the Analysis Services Connections dialog box, click Close.

 Task 2: Add a model to the data mining structure


1. On the ribbon, in the Data Modeling area, click Advanced, and then click Add Model to Structure.
2. In the Add Model to Structure Wizard, on the Getting Started with the Add Model to Structure
Wizard page, click Next, on the Select Structure or Model page, ensure that the Purchase
Prediction structure is selected, and then click Next.

3. On the Select Mining Algorithm page, in the Algorithm drop-down list, click Microsoft Naive
Bayes, and then click Next.

4. On the Select Columns page, in the Bike Buyer row, in the Usage column, click Predict Only, in the
Name Style row, in the Usage column, click Do not use, and then click Next.
5. On the Finish page, click Finish.

 Task 3: Review the data mining model


1. In the Browse dialog box, on the Dependency Network tab, review the diagram that shows the
factors that correlate with Bike Buyer, and then under All Links, click once to remove the weakest
correlates from the diagram.

2. Repeat step 1 until the diagram shows only the strongest correlations.

3. Click the Attribute Profiles tab, and review the attribute profile graphics.
4. Click the Attribute Characteristics tab, in the Value drop-down list click 1, and then review the
information in the Characteristics for 1 table.

5. Click the Attribute Discrimination tab, in the Value 1 drop-down list, click 1, in the Value 2 drop-
down list, click 0, and then review the information in the Discrimination scores for 1 and 0 table.
Maximize the window if necessary.
6. In the Browse dialog box, click Close.
Lab 14: Using Data Mining to Support a Marketing Campaign L14-101

Exercise 4: Validating Data Mining Models


 Task 1: Use the Accuracy Chart wizard
1. On the ribbon, in the Accuracy and Validation area, click Accuracy Chart.

2. In the Accuracy Chart Wizard, on the Getting Started with the Accuracy Chart Wizard page, click
Next.

3. On the Select Structure or Model page, click Next.

4. On the Specify Column to Predict and Value to Predict page, in the Mining column to predict
drop-down list, ensure that Bike Buyer is selected, in the Value to predict drop-down list, click 1,
and then click Next.

5. On the Select Source Data page, ensure that Test data from mining structure is selected, and then
click Finish.

6. In the Accuracy Chart for Structure ‘Purchase Prediction’ chart, review the data for Purchase –
Bayes, Purchase Decision Tree, Ideal Model, and No Model.

 Task 2: Use the Classification Matrix Wizard


1. On the ribbon, in the Accuracy and Validation area, click Classification Matrix.

2. In the Classification Matrix Wizard, on the Getting Started with the Classification Matrix Wizard
page, click Next.

3. On the Select Structure or Model page, click Next.

4. On the Specify Column to Predict page, click Next.


5. On the Select Source Data page, ensure that Test data from mining structure is selected, and then
click Finish.

6. In the Counts of correct/incorrect classification for structure ‘Purchase Prediction’ chart, review
the data for Purchase – Bayes and Purchase Decision Tree.

 Task 3: Use the Profit Chart Wizard


1. On the ribbon, in the Accuracy and Validation area, click Profit Chart.

2. In the Profit Chart Wizard, on the Getting Started with the Profit Chart Wizard page, click Next.
3. On the Select Structure or Model page, click Next.

4. On the Specify Profit Chart Parameters page, in the Value to predict drop-down list, click 1, in the
Target Population field, type 5000 in the Fixed cost field, type 500.00 in the Individual cost field,
type 1.00 in the Revenue per individual field, type 150.00 and then click Next.

5. On the Select Source Data page, ensure that Test data from mining structure is selected, and then
click Finish.
6. In the Profit Chart for Structure ‘Purchase Prediction’ chart, review the data for Purchase – Bayes
and Purchase Decision Tree.

7. Click File, click Save, in the Save As dialog box, navigate to D:\10778A\Labfiles\Lab14\Starter, in the
File name field, type DM Validation.xlsx, and then click Save.
L14-102 Module 14: Performing Predictive Analysis with Data Mining

Exercise 5: Using a Data Mining Model in a Report


 Task 1: Create a report
1. On the taskbar, click AW Data Mining – Microsoft Visual Studio, on the menu bar, click File, and
then click Close Project.

2. Click File, click New, click Project, in the Installed Templates pane, click Business Intelligence, click
Report Server Project Wizard, in the Name field, type Promotion Targeting, and then click OK.
3. In the Report Wizard, on the Welcome to the Report Wizard page, click Next.

4. On the Select the Data Source page, under New data source, in the Type drop-down list, select
Microsoft SQL Server Analysis Services.

5. Click Edit, in the Connection Properties dialog box, in the Server name field, type localhost, in the
Connect to a database area, in the Select or enter a database name drop-down list, click AW Data
Mining, and then click OK.
6. On the Select the Data Source page, click Next.
7. On the Design the Query page, click Query Builder.

8. In Query Designer, in the Mining Model pane, click Select Model, in the Select Mining Model
dialog box, expand Purchase Prediction, click Purchase - Bayes, and then click OK.
9. In the Select Input Table(s) pane, click Select Case Table, in the Select Table dialog box, click
ProspectiveBuyer (dbo), and then click OK.

10. Under the Mining Model pane, in the Source column, in the drop-down list, click ProspectiveBuyer
table, and then in the Field column, in the drop-down list, click FirstName.

11. Repeat step 10 to add five more rows to the table by using the settings in the following table, and
then click OK.

Source Field Alias Criteria/Argument


ProspectiveBuyer LastName N/A N/A
table

ProspectiveBuyer Address Line 1 N/A N/A


table

ProspectiveBuyer City N/A N/A


table

Purchase – Bayes Bike Buyer N/A =1


mining model

Prediction Function PredictProbability Purchase Probability [Purchase - Bayes].[Bike


Buyer]

12. On the Design the Query page, click Next, on the Select the Report Type page, select Tabular,
click Next, on the Design the Table page, click Next, on the Choose the Table Style page, click
Next, on the Choose the Deployment Location page, click Next, on the Completing the Wizard
page, in the Report name field, type Potential Bike Buyers, and then click Finish.
Lab 14: Using Data Mining to Support a Marketing Campaign L14-103

13. On the design surface, on the Design tab, in the Potential Bike Buyers report, in the First Name
column, click [First Name], to the left of [First Name], right-click the button, and then click Tablix
Properties.

14. In the Tablix Properties dialog box, click Sorting, in the Change sorting options pane, click Add, in
the Sort by drop-down list, click [Purchase_Probability], in the Order drop-down list, click Z to A,
and then click OK.
15. In the Purchase Probability column, right-click [Purchase Probability], click Text Box Properties,
in the Text Box Properties dialog box, click Number, in the Set number and data formatting
options pane, click Percentage, and then click OK.

16. Click the Preview tab to review the Potential Bike Buyers report.
L14-104 Module 14: Performing Predictive Analysis with Data Mining

Vous aimerez peut-être aussi