Professional Documents
Culture Documents
Multidimensional Modeling: Using SQL Server 2012 Analysis Services
Multidimensional Modeling: Using SQL Server 2012 Analysis Services
2
Sample Data
• Fictitious company Adventure Works Cycle
– Large, multinational manufacturing company that
produces and distributes
• Metal, composite bicycles
– Sell their products in North America, Europe and Asia
– Headquarter is in Bothell, Washington (500 workers)
– Employs regional sales team throughout its market base
3
Install Sample Data & Project Files
• Software
– SQL Server 2012 with following features:
• Database Engine
• Analysis Services
• SQL Server Data Tools (SSDT)
• SQL Server Management Studio
• Install Database (Method 1 - MDF file)
– Download the AdventureWorksDW2012_Data.mdf from
http://msftdbprodsamples.codeplex.com/releases/view/55330
– https://docs.microsoft.com/en-us/sql/samples/adventureworks-install-
configure?view=sql-server-ver16&tabs=ssms
• .mdf (SQL Server Master Database File)
– Copy the file in Data Directory of SQL Server Database Engine instance:
• C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Data
– Start SQLServerManagementStudio & connect to DB
• Right click Databases -> Attach -> Add -> AdventureWorksDW2012_Data.mdf 4
• Remove the log file entry from the Database details pane. A new log file will be
created automatically.
Install Sample Data & Project Files
• Install Database (Method 2 - BAK file)
– Download the appropriate .bak file from one of links provided in the
download backup files section.
– Move the .bak file to your SQL Server backup location. This varies
depending on your installation location, instance name and version of
SQL Server. For example, the default location for a default instance of
SQL Server 2019 is:
C:\Program Files\Microsoft SQL
Server\MSSQL15.MSSQLSERVER\MSSQL\Backup.
– Open SQL Server Management Studio (SSMS) and connect to your SQL
Server.
– Right-click Databases in Object Explorer > Restore Database... to launch
the Restore Database wizard.
5
Install Sample Data & Project Files
6
Install Sample Data & Project Files
• Select Device and then select the ellipses (...) to choose a device.
• Select Add and then choose the .bak file you recently moved to the backup
location. If you moved your file to this location but you're not able to see it in
the wizard, this typically indicates a permissions issue - SQL Server or the
user signed into SQL Server does not have permission to this file in this
folder.
• Select OK to confirm your database backup selection and close the Select
backup devices window.
• Check the Files tab to confirm the Restore as location and file names match
your intended location and file names in the Restore Database wizard.
• Select OK to restore your database.
7
8
Grant Database Permissions
• Determine the Service Account under which Analysis Services runs by:
– SQL Server Configuration Manager
– check the Account (LOG ON AS) under which Analysis services is running
– usually it will be NT Service\MSSQLServerOLAPService
9
Install Sample Projects (OPTIONAL)
• Download the “Analysis Services Tutorial SQL Server 2012.zip” from
– X http://msftdbprodsamples.codeplex.com/releases/view/55330 (obsolete)
– https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks-
analysis-services/adventure-works-multidimensional-tutorial-projects.zip
• Extract the compressed file, which contains the sample projects for each
week
• Open SQL Server Data Tools (SSDT) (opens up Visual Studio)
• Deploy the solution (.sln) file of the first lesson (build menu -> deploy)
• During deployment, Data will be processed (or imported) from the
AdventureWorksDW2012 on the local Database Engine instance
11
Defining a Data Source
• In SSDT -> right click Data Sources -> New Data Source
• Opens up Data Source Wizard -> Select How to Define Connection page ->
Create a Data Source based on New or Existing connection -> New
• Opens up Connection Manager -> Provider list box (Native OLE DB\SQL
Server Native Client 11.0)
• Server Name -> localhost
• Use Windows Authentication is selected
• Database name -> AdventureWorksDW2012
• Test connection
12
Defining a Data Source View
• A Data Source View is a single, unified view of the metadata from the
specified tables and views that Data Source defines
• Storing the metadata enables to work with the metadata during development
without an open connection to any underlying data source
• Steps:
– Right click Data Source Views -> New Data Source View
– Data Source View Wizard -> Select a Data Source -> Adventure Works DW 2012
-> Next
– ON Select Tables and Views Page -> Available object ->
• DimCustomers (dbo), DimDate (dbo), DimGeography (dbo), DimProduct (dbo), FactInternetSales
(dbo) -> NEXT
– Name field -> Adventure Works DW 2012
– Data Source View will appear in Solution explorer
– Content of the View will be displayed in Data Source View Designer which
contains:
• A Diagram Pane, which displays tables and their relationships
13
• A Tables Pane, which displays the tables and their schema in a tree view
• A Diagram Organizer pane, for creating subdiagrams, to view subsets of the view
Modifying Default Table Names
• Change the FriendlyName property of all the
tables to in the Properties window
– FactInternetSales -> InternetSales
– DimProduct -> Product
– DimCustomer -> Customer
– DimDate -> Date
– DimGeography -> Geography
14
Defining and deploying a Cube
• Defining a Dimension
– In the Solution Explorer in SSDT
• Right click Dimensions -> New Dimension – Next ->
• Select Creation Method (Use an existing table) -> Next ->
• Specify Source Information -> Adventure Works DW 2012
• Main table list -> Date -> Next
• Select Dimension Attributes ->
– Date Key, Full Date Alternate Key, English Month Name, Calendar
Quarter, Calendar Year, Calendar Semester
• Change the Attribute Type column value for FullDateAlternateKey
from Regular to Date (Date.Calendar.Date)
• Change EnglishMonthName to Month (Date.Calendar.Month)
• CalenderQuarter to Quarter
15
• CalenderYear to Year
• CalendarSemester to Half Year
• NEXT -> Finish
Defining a Cube
• In the Solution Explorer in SSDT
– Right click Cubes -> New Cube – Next ->
– Select Creation Method (Use an existing table) -> Next ->
– Select Measure Group Tables -> Adventure Works DW 2012 ->
– Click Suggest, to let the wizard suggest table to create measures -> Next
(It suggested internetSales)
– On Select Measures -> uncheck the following measures:
• Promotion Key, Currency Key, Sales Territory Key, Revision Number
– Next
– Select existing Dimension page -> Date -> Next
– Select New Dimensions page -> select Customer,
Geography and Product,
– uncheck the Fact InternetSales checkbox 16
• Save All
Reviewing Cube and Dimension Properties
• Steps to review the structure of Cube & Dimension properties:
– Double click the Analysis Services Tutorial Cube in the Cubes node of Solution
Explorer
– In the Measures pane, expand the InternetSales measure group to reveal the
defined measures.
• You can change the order of measures by dragging in the list
• The measure group and each measure have properties that you can edit in the properties window
– In the Dimensions pane, review the cube dimensions.
– NOTICE:
• Solution explorer displaying 3 dimensions == the Dimensions pane displaying 5 dimensions
• Cube contains more dimensions than the dimensions created in the Database
• Because “Date” database dimension is used as the basis for three separate “date-related” cube
dimensions, based on different date-related facts in the fact table.
• These date-related dimensions are called role playing dimensions
• They allow the user, dimensions the cube by three separate facts related to each product sale
– i.e., orderdate, duedate, shipdate
• By reusing a single database dimension for multiple cube dimensions, Analysis services simplifies
18
dimension management, uses less disk space, reduces overall processing time.
Deploying an Analysis Services Project (1)
• Right click the Cube and select View Designer
– In Cube Designer -> Browser tab
• Notice that the cube cannot be browsed, because it has not yet been deployed to an instance of
Analysis Services
• Currently it is just a definition of cube
• Deploying and processing a cube performs two things:
– creates the defined objects in an instance of Analysis Services and
– populates the objects with data from the underlying data sources.
20
Browsing the Cube
• After you deploy and process a cube and dimensions, the cube &
dimensions data are viewable on the Browser tab, in Cube & Dimension
Designer.
• Switch to Cube Designer in SSDT. Double click your cube name in cubes
node of Solution explorer
• Select the Browser tab, and then click the Reconnect icon on the toolbar of
the designer.
• For cubes, the browser tab provides two approaches for exploring data:
– Built-in MDX Query designer to build queries that returns a flattened rowset
– Excel shortcut. It opens with a PivotTable already in the worksheet and a predefined
connection to the model workspace database
– Excel generally offers a better browsing experience, because you explore cube data
interactively, using horizontal and vertical axis to analyze the relationships in your data.
– Excel also provides drilldown feature
– Practice with the browsing by adding or removing dimensions, and see how excel displays
21
PivotTable data.