You are on page 1of 160

Agenda

 Intro to Data Warehouse Concepts


 Data Mart / Data Warehouse / Enterprise Data Warehouse
 Top Down Vs Bottom Up
 ODS (Operational Data Source)
 Introduction to Dimension Modeling (OLAP Modeling)
 Measure or Fact
 Dimensions
 Hierarchies
 Types of Dimensions and Measures

 Schemas
 Star Schema
 Snow Flake Schema

8/9/2018
Agenda
 Building Data Warehouse
 SSAS Architecture
 Dimensional Model Development
 Data Source
 Data Source View (DSV)
 Named Calculations
 Demo: Creating Named Calculations
 Named Queries
 Demo: Creating Named Queries

8/9/2018
Agenda
 Dimension Development
 Dimension Development Overview
 Dimension Designer
 Attributes
 Basic Attribute Properties
 Attribute Relationships
 Hierarchy

8/9/2018
Agenda
 Cube Development
 Cube Development Overview
 Cube Designer
 Measure Properties
 Aggregate Functions
 Role Play Dimension
 Cube Dimension
 Database Dimension
 Dimension Usage
 Demo: Deploy and Browse the Cube
 Relationship Types: Regular, Referenced, Fact & Many to Many
8/9/2018
Agenda
 Calculations
 Overview
 Calculation Designer
 Named Sets
 Overview
 Cube Processing and Deployment
 Overview
 Cube Deployment
 Processing Options

8/9/2018
Agenda – Adv SSAS
 KPIs
 Actions
 Translations
 Perspectives
 Partitions
 Aggregations
 Performance Tuning
 Security
 MDX
 DAX
 Data Mining Overview
8/9/2018
Data Warehouse Concepts
www.GoOnlineTrainings.com
Mr. Bhaskar Jogi
bhaskarjogi@gmail.com

8/9/2018
Data Warehouse Jargons…
 OLTP vs OLAP
 Data Mart vs Data Warehouse  Hierarchy
 ODS (Operational Data Source)  Member
 CUBE  Attribute
 UDM (Unified Dimension Model)
 Dimension
 Measure or Fact
 Measure Group

8/9/2018
History - Father of Data Warehouse

Dr. William Inmon


Dr. Ralph Kimball
Introduced Dimension
Model in 1990
8/9/2018
Data Warehouse means…
 According to Dr. Inmon:
 Subject-oriented:
 Customer, Product, Shipment etc are
typical subject areas.
 Integrated:
 It means that data from heterogeneous data
sources are integrated in Data warehouse.

8/9/2018
Data Warehouse means…

 Nonvolatile Data:
 Once loaded, is usually never changed i.e.
updated or deleted
 Read only data
 Time Variant

8/9/2018
Data Warehouse (DWH)

It is a centralized DB system


which stores Integrated,
Summarized and Historical
Data for Analysis and
Decision Making Purpose.
8/9/2018
Top-down Approach
 Dr. Bill Inmon proposed the top-down approach of data
warehouse.
 In top-down approach complete data warehouse is created
first and then the data marts are derived from the data
warehouse.
 As the data marts are created from a single data warehouse,
all the data marts have consistent data.
 It is robust against business changes. The cost of the project is
very high.

8/9/2018
Bottom-up Approach
 Dr. Ralph Kimball proposed the bottom-up design approach

of data warehouse.

 In bottom-up approach data marts are created first.

 Data marts are then integrated and a comprehensive data

warehouse is created.

 As the data marts are created first, business solutions can be

answered quickly.

8/9/2018
ODS (Operational Data Source)

8/9/2018
Intro to Dimension Modeling
www.GoOnlineTrainings.com

Mr. Bhaskar Jogi


bhaskarjogi@gmail.com

8/9/2018
Dimension Modeling
 Developed by Dr. Kimball
 Its a DWH design concept
 It is a process to convert OLTP data into OLAP data in the
form of Dimension tables and Fact tables
 Dimension Modeling is heart of data warehouse

8/9/2018
Design Concepts – OLTP and OLAP

8/9/2018
Measure or Fact
 Measures are the numeric values that we want to aggregate,
slice, dice and analyze
 Measure has following properties:
 How they should be formatted
 How they should aggregate up
 How they interact with specific dimensions and so on.
 Measure always answer questions for ‘How much’ or ‘How
many’ etc
 Data in the fact table can be filtered and grouped (“sliced and
diced”)

8/9/2018
Dimension
 Dimension is a string, which always answer the questions like
‘When’, ‘Where’, ‘What’, ‘Who’ , ‘Which’ etc
 Examples for Dimensions:
 Customer, Product
 Time, Geography etc
 Dimension Table Primary Key is F/K of Fact Table
 Dimension contains multiple Hierarchies
 Hierarchy supports drilling up and down
 Hierarchy speeds the aggregation in a cube while processing
 Even though Hierarchies are optional .. These are
recommended
Types of Hierarchies
 Natural Hierarchy (Balanced)
 Un-Natural Hierarchy (Un-Balanced)
 Ragged Hierarchy
 No end in the hierarchy
 Eg: Employee Hierarchy
 Note: Purpose of hierarchy is to speed up the calculations
 Note: Hierarchy is applied ONLY on Dimension Tables
 Note: Hierarchy is not mandatory… it is recommended

8/9/2018
Example – Natural Hierarchy
Year
Semester
Quarter
Month
Week
Day
8/9/2018
Example – Un Natural Hierarchy

Year
Quarter
Week
Day
8/9/2018
Example – Un Natural Hierarchy
Product Category

Sub Category

Product

Dealer

Customer

8/9/2018
Intro to Schemas
www.GoOnlineTrainings.com

8/9/2018
How Fact and Dimension tables are
organized in a DWH/Cube?
 Star Schema

 Snow Flake Schema

 Note:

 Always create the schema in DWH only, if not create the same

in Cube.
 Recommended: Always create the schema in DWH only

8/9/2018
Star Schema

Star Schema
means Dimension
Tables are directly
linked to the Fact
Table 8/9/2018
Star Schema

8/9/2018
Snow Flake Schema
Dimension Tables
are indirectly linked
to the Fact Table

Or

Dimension table is
linking to another
dimension table

8/9/2018
Snow Flake Schema

8/9/2018
Diff b/w Star & Snow Flake Schemas
Star Schema Snow Flake Schema
1.Has redundant data and hence tough to 1.No redundency and hence more easy to
maintain /change maintain /change
2.Less complex queries and hence easy to 2.More complex queries and hence less easy
understand is to understand
3.Less foreign keys so faster execution time 3.More foreign keys so takes more execution
Of cube time of cube
4.Has De-Normalized tables 4.Has Normalized tables

5.Good to use for large databases 5.Good to use for small databases

6.Less number of joins 6.More number of joins

7.When dimension table has less number of 7.When dimension table is relatively big in
rows we can go for this size it is better as it reduces space

8/9/2018
OLTP vs OLAP

8/9/2018
Snow Flake Schema

8/9/2018
Star Vs. Snow Flake Schema

Note: Star Schema is


recommended for Data
Warehouse
8/9/2018
Purpose of SSAS
www.GoOnlineTrainings.com

Mr. Bhaskar Jogi


SSAS
bhaskarjogi@gmail.com

8/9/2018
Intro to SSAS
 Is an Analysis Tool
 Stores Multidimensional Aggregated
Data to speed up the queries
 Used for Large Data to Aggregate and
stores the aggregated data
 Is a Multi Dimensional OLAP Server
and Data Mining Server
8/9/2018
Roles of SSAS
 OLAP Server
 To store Pre-aggregate Values (Totals) for Multi
Dimensional Analysis
 Understand the Past
 Data Mining Server
For Understand Trends and Patterns
For Predictions
Understand the Future

8/9/2018
Purpose for SSAS
 SSAS makes super slow BI application to super fast BI
application, by using pre-aggregated totals for multi-
dimensional analysis
 We may develop BI app using OLTP  Reporting
 Or
 We may develop BI app using OLTP  OLAP  Reporting
 Note: Hence SSAS is NOT a mandatory component to
develop a BI application

8/9/2018
8/9/2018
SSAS Usages…
 Consistently Fast Response
 Cubes
 Dimensions and Fact Tables
 Measures, Hierarchies and Aggregations
 Meta Data Based Queries
 MDX (Multi Dimensional Expressions)
 XMLA (XML for Analysis)
 ASSL (Analysis Services Scripting Language)
 DMX (Data Mining Expressions)
 Integration with other tools
 Ease Integration with office tools like excel
 Ease Integration with SharePoint Portal etc

8/9/2018
Types of Dimensions and Facts
www.GoOnlineTrainings.com

8/9/2018
Types of Dimensions
 Role Playing Dimensions:
 Dimensions are often recycled for multiple applications within
the same database.
 For instance, a "Date" dimension can be used for "Date of
Sale", as well as "Date of Delivery", or "Date of Hire". This is
often referred to as a "role-playing dimension".
 Conformed Dimensions: a dimension that has exactly the
same meaning and content when being referred to from
different fact tables.
 Date is a common conformed dimension because its attributes
(day, week, month, quarter, year, etc.) have the same meaning
when joined to any fact table.
8/9/2018
Types of Dimensions
 Junk Dimensions:
 A junk dimension is a single table with a
combination of different and unrelated
attributes to avoid having a large number
of foreign keys in the fact table.
 Junk dimensions are often created to
manage the foreign keys created by
Rapidly Changing Dimensions.
8/9/2018
Types of Dimensions
 Degenerate Dimensions:
 When the dimension attribute is stored as part of fact table,
and not in a separate dimension table.
 These are essentially dimension keys for which there are no
other attributes. In a data warehouse, these are often used as
the result of a drill through query to analyze the source of an
aggregated number in a report.
 You can use these values to trace back to transactions in the
OLTP system.

8/9/2018
Slowly Changing Dimension (SCD)
It is used to capture history of the
row.
Type 0: Changes treated as errors
Type 1: Overwrite the changes
Type 2: Store the history of the row

8/9/2018
Measure Vs Measure Group
 Measure is single numeric value whereas a Measure Group is
a collection of measures.
 Measure Group referrers to Fact Table

8/9/2018
Types of Measures/Facts
 Fully Additive Measures/Facts

 Can be added across all the associated dimensions

 Eg: Sales Amount

 Semi-Additive Measures/Facts

 Can be added across only few dimensions rather than all

dimensions.
 Eg: Customer Balance at the Q1 and Q2

8/9/2018
Types of Measures/Facts
 Non-Additive Measures/Facts

 cannot be added across any of the dimensions in the cube. For

Eg: Pass Marks etc

 Derived Measures/Facts

 Calculated from one or more base facts

 These are not stored in the cube and are calculated on the fly at

the time of accessing them.


 For example, profit margin
8/9/2018
Types of Measures/Facts
 Factless Measures/Facts

 Fact table does not have any facts…it has only FKs

 Eg: Student Attendance

 Textual Measures/Facts

 Refers to textual data present in the fact table, which is not

measurable (non-additive), but is important for analysis


purposes. For example, codes (i.e. product codes), flags (i.e.
status flag), etc.
8/9/2018
Fact Less Fact Table
 Fact Table which does not contain any measures or facts
 Fact Table contains only key Attributes

8/9/2018
OLTP to OLAP Table Conversion
 OLTP Contains
 Master Tables
 Product
 Course
 Student etc
 Transactional Tables
 Payment Details
 Order Details etc

 In OLAP
 Master tables converted as Dimension Tables
 Transactional tables converted as Fact Tables

8/9/2018
Mapping Document
 It is used to map the OLTP columns with OLAP columns
while creating DWH database.

OLTP OLAP
Table Name Student DimStudent

Column Name Column Name


SID StudentKey
FirstName
MidName Full Name

LastName
Qualification Qualification

8/9/2018
Building DB for DWH

8/9/2018
Steps to Create Cube
Build DWH

Create Data Source

Create DSV

Build DB
Dimensions

Build Cube
Dimensions

Build Cube

Build, Process and 8/9/2018


Deploy Cube
Steps to Create Cube
 Create Data Source (DWH)
 Create Data Source Views
 Create DB Dimensions
 Add Attributes
 Create Hierarchies
 Create Dimension Usage
 Create New Cube
 Add Measure Groups
 Add Dimensions
 Build and Deploy
 Process the Cube
 Browse the Cube
8/9/2018
Deploy
 Once we create a cube perform the following steps:

 Build
 To check syntax errors
 Deploy
 It will deploy the structure of the cube
 Process
 Cube will perform aggregations

8/9/2018
Data Source View – Properties
 Named Calculations – Computed Columns
 Named Query – is a view in the SSAS at Data Source View
 New Relationships

8/9/2018
Attribute Relationships

8/9/2018
Attribute Relationships
 https://www.youtube.com/watch?v=88De9IIPAyo

 Arrange attributes from More specific to more


Generic
8/9/2018
Attribute Relationships
 Click on Arrow and Press F4
 Change it to all Arrows ()

8/9/2018
Relationships b/w Tables
 1 to 1
 1 to many
 Many to Many

8/9/2018
Relationships b/w Facts &
Dimensions (Cube)
 Regular (1 to m) – Star Schema
 dimension main table is joined directly to the fact table

 Role Playing
 dimension has more than one relationship to the fact table.
 Many-Many
 dimension table is joined to an intermediate fact table which is in turn is joined, in
turn to an intermediate dimension table to which the fact table is joined.
 Reference – Snow Flake Schema
 dimension table is joined to an intermediate dimension table, which is in turn joined
to the fact table.
 Fact (1 to 1)
 The dimension table is the fact table.
 Data Mining
 The dimension is based on an OLAP mining model, which in turn is based on another
database dimension.

AS / 62
Note
 Many to many relationship must be avoided in DWH.
 It reduces the performance of the cube processing
 Tabular model does not support M  M relationship

 Note:
http://social.technet.microsoft.com/wiki/contents/articles
/19854.tutorial-many-to-many-dimension-example-for-sql-
server-analysis-services.aspx

8/9/2018
Cube

8/9/2018
Cube

8/9/2018
Browse the Data in SSMS

8/9/2018
Dimensions
 Contains attributes and hierarchies
 Member is a value in dimension/hierarchy

8/9/2018
Hierarchy and Attribute
 Hierarchy:
 Drag and drop a Country
 [Dim Location]  Dimension Name
 [Hierarchy] Hierarchy Name
 [Country] Level Name
 Attribute:
 Drag and drop a City
 [Dim Location]  Dimension Name
 [City]  Hierarchy Name
 [City] Level Name
 “All” is the default Level
8/9/2018
MDX Syntax
SELECT SET/TUPLE/MEMBER ON COLUMNS/0/axis(0),
SET/TUPLE/MEMBER ON ROWS/1/axis(1),
…….2 pages ,
…….3 extents ,
…….4 Chapter etc ,
FROM <Cube Name>
WHERE <Condition>

Note: No Names after 5 Levels and max 127 Levels

8/9/2018
MDX Keywords…
 Members:
 Member is a value stored in a dimension
 Set
 Members from same Hierarchy is called SET
 Use { } braces to represent a set

 Tuple
 Members from different Hierarchy is called TUPLE
 Use ( ) braces to represent a tuple

 Note: Same dimension cannot be in more


than one axis
8/9/2018
Simple Query
SELECT
FROM [CubeProdcuctDW]

Note: No X and Y axis data in this query

8/9/2018
Questions using Facts…?
 What is total Sales Amount?
 What is the total Sales Qty?
 What is the total Fact Sales Count?

SELECT [Measures].[Sales Amount] ON COLUMNS


FROM [CubeProducts]

SELECT [Measures].[Sales Qty] ON COLUMNS


FROM [CubeProducts]

SELECT [Measures].[Fact Sales Count] ON COLUMNS


FROM [CubeProducts]

8/9/2018
Questions using Facts, Dimensions…?
 What is total Sales Amount, Country-wise?
 What is the total Sales Qty, Year-Wise?
 What is the total Fact Sales Count, Product Category-wise ?

SELECT [Measures].[Sales Amount] ON COLUMNS,


[Dim Location].[Country].[Country] ON ROWS
FROM [CubeProducts]

SELECT [Measures].[Sales Qty] ON COLUMNS,


[Dim Time].[Year No].[Year No] ON ROWS
FROM [CubeProducts]

SELECT [Measures].[Fact Sales Count] ON COLUMNS,


[Dim Product].[Product Category].[Product Category] ON ROWS
FROM [CubeProducts]
Find out Total Sales Qty
SELECT
FROM [CubeProdcuctDW]
WHERE [Measures].[Sales Qty]

8/9/2018
Query with X and Y Axis
SELECT [Measures].[Sales Qty] on Columns
FROM [CubeProdcuctDW]

Note:
 Column is must
 Row is optional

8/9/2018
Gives Error…No Column
SELECT [Measures].[Sales Qty] on Rows
FROM [CubeProdcuctDW]

Note:
 Column is must
 Row is optional

8/9/2018
Use { } …Else Error
SELECT { [Measures].[Sales Qty],
[Measures].[Sales Amount]} on Columns
FROM [CubeProdcuctDW]

8/9/2018
Simple MDX Query
State wise Sales Qty
and Sales Amt

SELECT {[Measures].[Sales Qty],


[Measures].[Sales Amount]} on Columns,
[Dim Location].[State].[State] on Rows
FROM [CubeProdcuctDW]

8/9/2018
Cannot use same hierarchy in Col
and rows
SELECT {[Measures].[Sales Qty],
[Measures].[Sales Amount]} on Columns,
[Measures].[Fact Sales Count] on Rows
FROM [CubeProdcuctDW]

8/9/2018
Dim and Measure One Axes and
another Dim another Axes
Year wise and Product
wise Sales Amt and
Sales Count

SELECT ([Dim Time].[Year No].[Year No],


{[Measures].[Sales Amount],[Measures].[Fact Sales
Count]}) ON COLUMNS,
[Dim Product].[Product Name].[Product Name] ON
ROWS
FROM [CubeProdcuctDW] 8/9/2018
All Vs Members
 --Gives Grand Total (ALL) – Grand Total
 select [Dim Location].[Country] on columns
 from [ProductsCube]

 --Gives various countries sales


 select [Dim Location].[Country].[Country] on columns
 from [ProductsCube]

8/9/2018
Filter Condition
Find out Sales Amount
only for Year 2005

SELECT ([Dim Time].[Year No].[Year No],


{[Measures].[Sales Amount],[Measures].[Fact Sales
Count]}) ON COLUMNS,
[Dim Product].[Product Name].[Product Name] ON
ROWS
FROM [CubeProdcuctDW] 8/9/2018
Non Empty() Function
 Eliminates or hide NULL data on entire column or row

SELECT Non Empty(([Dim Time].[Year No].[Year


No],{[Measures].[Sales Amount],[Measures].[Fact Sales
Count]})) ON COLUMNS,
Non Empty([Dim Product].[Product Name].[Product
Name]) ON ROWS
FROM [CubeProdcuctDW]

8/9/2018
Year-wise, Month-wise,
Filter - MDX Query
State wise, Sales Count
and Sales Amt ONLY
FOR year 2005

SELECT NON EMPTY (([Dim


Location].[State].[State],{[Measures].[Fact Sales Count],
[Measures].[Sales Amount]})) ON COLUMNS,
NON EMPTY(([Dim Time].[Year No].&[2005],[Dim Time].[English
Month Name].[English Month Name])) ON ROWS
FROM [CubeProdcuctDW]

8/9/2018
Filter using WHERE Clause
SELECT Non Empty({[Measures].[Sales
Amount],[Measures].
[Fact Sales Count]}) ON
COLUMNS,
Non Empty ([Dim Product].[Product
Name].[Product Name]) ON ROWS
FROM[CubeProdcuctDW]
WHERE [Dim Time].[Year No].&[2005]

8/9/2018
Year and Month in a Single Column
SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,
([Dim Time].[Year No].[Year No],[Dim Time].[English Month Name].[English
Month Name] ) ON ROWS
FROM [CubeProdcuctDW]

SELECT {[Measures].[Sales Amount],Year Wise and


[Measures].[Sales Month
Qty]} ON COLUMNS,
Wise
{[Dim Time].[Hierarchy].[Year No],[Dim Sales Amt and Month
Time].[Hierarchy].[English
Name]} ON ROWS Sales Qty
FROM [CubeProdcuctDW]

Note: Hierarchy gives Year and Month on Same COLUMN

8/9/2018
MDX Query
 Requirement: Month on Column and Year on Row
 Cannot achieve this requirement using HIERARCHY
 Because SAME HIERARCHY cannot be used in ROWS and
COLUMN
 Achieve this ONLY using ATTRIBUTE

8/9/2018
Members() Function
 Gets all the Members in given attribute/hierarchy

SELECT [Measures].[Sales Amount] on COLUMNS,


[Dim Location].[Hierarchy].Members On ROWS
FROM [CubeProdcuctDW]

Note: All the data from each level is shown

8/9/2018
Members cannot have Members
 Requirement: All Cities of Andhra Pradesh
 Query gives ERROR, becoz Member cannot have member,
it will have Children
 Query: Get all the cities of Andhra Pradesh
SELECT [Measures].[Sales Amount] on COLUMNS,
([Dim Location].[Hierarchy].[Country].&[India].&[Andhara
Pradesh].Member) On ROWS
FROM [CubeProdcuctDW]
 Use Children instead of Member in above query
 Children Function CANNOT be used in Attribute since
Attribute will have ALL and Members… but no Child
8/9/2018
Descendants ()
 Syntax:
 Descendants(<Member>, <Level>)
 Gives Descendants of given data
 Must use same hierarchy
Get Sales Amt and
Sales Qty for all the
months in Year 2006

SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,


{Descendants ([Dim Time].[Hierarchy].[Year No].&[2006] , [Dim
Time].[Hierarchy].[English Month Name] )} ON ROWS
FROM [CubeProdcuctDW]
Descendants ()
 Number can be specified for Level

SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,

{Descendants ([Dim Time].[Hierarchy].[Year No].&[2006] , 0 )} ON


ROWS
FROM [CubeProdcuctDW]
 0 – Means Same Member Data
 1 – Below 1 Level
 2 – Below 2 Levels

8/9/2018
Descendants () Options
 Self
 Self_and_Before
 Self_and_after
 Before
 After

SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,

{Descendants ([Dim Time].[Hierarchy].[Year No].&[2006] , 0,


SELF )} ON ROWS
FROM [CubeProdcuctDW]

8/9/2018
Parent()
 Gives Parent of given Member

SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,


[Dim Time].[Hierarchy].[Year No].&[2006].&[2].&[3].&[August].Parent
ON ROWS
FROM [CubeProdcuctDW]

 Parent() is used calculate the share of given Branch from


using parent share

8/9/2018
Ancestors()
 Ancestors(<Member>, <Level>)
 Gives upper level from current level

 --3 Levels of upper level from Current Level


SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,
Ancestors([Dim Time].[Hierarchy].[Year
No].&[2006].&[2].&[3].&[August],3) ON ROWS
FROM [CubeProdcuctDW]

8/9/2018
Brothers and Sisters for a Member
– Use Siblings()
SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,
[Dim Time].[Hierarchy].[Year
No].&[2006].&[2].&[3].&[July].Parent.Children ON ROWS
FROM [CubeProdcuctDW]

OR

SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,


[Dim Time].[Hierarchy].[Year No].&[2006].&[2].&[3].&[July].Siblings
ON ROWS
FROM [CubeProdcuctDW]

8/9/2018
Sibling() Options
 Parent.FirstChild or FirstSibling
 Parent.LastChild or LastSibling
 Find Example Below:

8/9/2018
Get Range of Values
 Syntax:
 { Range Start Member : Range End Member}

Get Sales Amt , Sales


Qty from Year 2006 to
2010

SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,


{[Dim Time].[Hierarchy].[Year No].&[2005] : [Dim
Time].[Hierarchy].[Year No].&[2010]} ON ROWS
FROM [CubeProdcuctDW]

8/9/2018
Year-wise, Month-wise,
MDX Query Sales Count and Sales
Amt ONLY FOR year
2005 and 2006

8/9/2018
Get Range of Values
 Syntax:
 { NULL : Range End Member} -- Do not know Start Range
 {Start Range Member : NULL} -- Do not know End Range

SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,


{NULL : [Dim Time].[Hierarchy].[Year No].&[2010]} ON ROWS
FROM [CubeProdcuctDW]
To get Next Member…
SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,
{[Dim Time].[Hierarchy].[Year No].&[2005].NextMember} ON
ROWS
FROM [CubeProdcuctDW]

SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,


{[Dim Time].[Hierarchy].[Year
No].&[2005].NextMember.NextMember} ON ROWS
FROM [CubeProdcuctDW]

8/9/2018
To Get PrevMember()
SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON
COLUMNS,
{[Dim Time].[Hierarchy].[Year No].&[2006]. &[2].&[4].&[October].
PrevMember} ON ROWS
FROM [CubeProdcuctDW]

8/9/2018
Lead () and Lag()
 Lead( )
 Moves n number of positions forward from the current member
value
 Lag( )
 Moves n number of positions back from the current member
value

8/9/2018
Top (n)…
 Top n
 Head (<Member>, n)
 Bottom
 Tail (<Member>, n)

SELECT {[Measures].[Sales Amount], [Measures].[Sales Qty]} ON COLUMNS,


Head([Dim Product].[Product Name].[Product Name], 5)
ON ROWS
FROM [CubeProdcuctDW]

8/9/2018
Sort the Measure
 Syntax:
 Order (Level, Measure, ASC/DESC)

SELECT [Measures].[Sales Amount] on COLUMNS,


Order([Dim Customer].[Customer Name].[Customer
Name],[Measures].[Sales Amount], DESC) ON ROWS
FROM [CubeProdcuctDW]

8/9/2018
Sort using Hierarchy
SELECT [Measures].[Sales Amount] on COLUMNS,
Order([Dim Location].[Hierarchy].[City],[Measures].[Sales
Amount] , DESC) ON ROWS
FROM [CubeProdcuctDW]

Note: The above query does not sort the data… use Break DESC as
below…

SELECT [Measures].[Sales Amount] on COLUMNS,


Order([Dim Location].[Hierarchy].[City],[Measures].[Sales
Amount] , BDESC) ON ROWS
FROM [CubeProdcuctDW] 8/9/2018
Order()
 --Can keep any measure in Order clause, need not keep the
measure which is there in the Columns

SELECT [Measures].[Sales Amount] on COLUMNS,


Order([Dim Location].[Hierarchy].[City],
[Measures].[Fact Sales Count], BDESC) ON ROWS
FROM [CubeProdcuctDW]

Note: Both measures are different


Note: Sort the data in Columns and Rows

8/9/2018
More Functions…
 NonEmpty()
 Filter()
 Top 10 rows with Highest Sales
 TopCount()
 BottomCount()
 Syntax:
 TopCount(Level, 10, Measure)
 BotomCount(Level, 10, Measure)

8/9/2018
Purpose of KPIs
 Key performance indicator (KPI) is a type of performance
measurement
 The purpose is to provide to decision makers to measure or
judge the organizational performance against organizational
objectives.
 KPIs are used to take quick decisions to ensure efficient and
effective management of resources and to achieve the main
objective of any organization

 Note: KPIs are attached to facts


8/9/2018
Key Performance Indicator
 Value to be measured
 a physical measure such as Sales, a calculated measure such as Profit, or a
calculation that is defined within the KPI
 Goal for the value
 a value (or MDX expression that resolves to a value) that defines the target
for the measure,
 Status
 MDX expression to evaluate the current status of the value in the range -1
(very bad) to +1 (very good),
 Trend
 an MDX expression to evaluate the current trend of the value. Is the value
getting better or worse relative to its goal

AS / 109
KPI
KPI
 KPI Functions
 KPIValue()
 KPIGoal()
 Status Expression/Trend Expression:
CASE
WHEN KPIvalue("CustomerKPI")>=0.90*KPIGoal("CustomerKPI")
THEN 1
WHEN KPIvalue("CustomerKPI")>=0.70*KPIGoal("CustomerKPI")
AND
KPIvalue("CustomerKPI")<0.90*KPIGoal("CustomerKPI")
THEN 0
ELSE -1
END 8/9/2018
URLs
 http://www.youtube.com/watch?v=ymPDKnmreDI
 http://ssas-wiki.com/w/Articles#KPI
 http://www.virbusgame.eu/virbus/mediawiki/index.php/
Key_Performance_Indicators
 http://www.techbubbles.com/sql-server/sql-server-
reporting-with-analysis-services/

8/9/2018
Calculations
 Build Model  Build Dim Build Cube  Build
Calculations  Deploy SSAS
 Calculations also performed at cell level
 It stores formula..but it will not store the data…it will
perform on the fly
 We can use these formula any where in the dimensions
 Create Calculations means create formula and use any where
 These are dynamic in nature… that means we can use them
in any dimension
 Need not process the cube…only deploy the cube

8/9/2018
Calculations

 Calculation is always a measure by default


 Calculations are similar to computed columns
 There are 3 ways to create a Calculation
 Using WITH
 Using CREATE
 Using CUBE

8/9/2018
Calculations
 Calculations are created based on
 Calculated Member
 Named Sets
 Named Sets are of two types:
 Static Named Sets
 Dynamic Named Sets.
 Static Named Sets, when defined in cube, are evaluated
during cube processing process.
 Dynamic Named Sets are evaluated each time the query is
invoked by the user.

8/9/2018
Calculated Members/Measure
 These are members of a measure group and are defined based
on a combination of one or more base measures,
arithmetic/conditional operators, numeric values, and
functions, etc.
 For example, profit is a calculated member/calculate
measure, which is defined based on various base measures
like selling price, cost, price, tax amount etc.

8/9/2018
Calculations

8/9/2018
Demo1 - Calculations
 Click New Calculated Member
 Name = NetSales
 Parent Hierarchy = Measures
 Expression = [Measures].[SalesAmount ] – [Measures].[Tax
Amount]
 Save and Deploy
 Note: No need of process the cube

8/9/2018
Demo2 – Previous Period Sales
 Click New Calculated Member
 Name = PrevPeriodSales
 Parent Hierarchy = Measures
 Expression = ([Measures].[NetSales],
[Time].[YearHierarchy].CurrentMember.PrevMember)
 Save and Deploy
 Note: No need of process the cube

8/9/2018
Named Sets
 It is a set of dimension members (usually a subset of
dimension members) and is defined using MDX (a
Multidimensional Expression).
 Named Sets are defined for improved usability by the end
users and client applications. Apart from that, they can also
be used for various calculations at the cube level.
 Similar to calculated members/measures, named sets are
defined using a combination of cube/dimension data,
arithmetic operators, numeric values, functions, etc.
 Some of the examples of Named Sets are top 50 customers,
top 10 products, top 5 students, etc.
8/9/2018
Demo3 – Named Sets
 Click New Named Set
 Name = Top5Customers
 Expression =
TOPCOUNT([Customer]. [CustomerKey].[CustomerKey], 5,
[Measures],[Sales Amount])
 Type = Dynamic
Save and Deploy
 Note: No need of process the cube

8/9/2018
Perspective
 Creates a subset (view) of a cube.
 To provide a degree of personalization, a security role can be
associated with the set of perspectives applicable to that view

AS / 122
Persepectives
 Controls the visibility of objects contained by a cube,
 Read-only view of the cube
 Display or Hide
 Dimensions
 Attributes
 Hierarchies
 Measure groups
 Measures
 Key Performance Indicators (KPIs)
 Calculations (calculated members, named sets, and script commands)
 security for a given perspective is inherited from the underlying
cube.

AS / 123
Cube Partitions

8/9/2018
Partitions
 Partitions are made always to the fact table
 Points to note while creating partitions
 On which columns do we need to create partition (usually
more frequently used columns…)
 Must not leave any data
 No record is pulled more than once
 Volume per partition (Minimum 2 million records to be there
to create a partition)

8/9/2018
Storage Methods in Cube
 There are primarily two types of data in SSAS:
 Summary Data and
 Detail data
 To store above data, there are three standard storage modes
supported by Cube:
 MOLAP
 ROLAP
 HOLAP

8/9/2018
Storage Modes
MOLAP ROLAP HOLAP
Cube Slow No Medium
Process
Report Faster Slow Medium
Reading
Storage More No Medium

8/9/2018
MOLAP (default mode in SSAS)

8/9/2018
HOLAP

8/9/2018
ROLAP

8/9/2018
MOLAP with Proactive Caching
Steps
 Click  Partitions  Click Storage Settings  Click on
Options
 Check  Enable Proactive Caching

8/9/2018
Demo - Partition Steps
 Click on Partitions
 Source  Fact Sales  Click on Ellipse
 Binding Type = Query Binding
 Click on New Partition
 Available Tables  Check  Fact Sales
 Check  Specify Query to restrict values
 Processing Options  Current Server Instance
 Name = Sales2005

8/9/2018
Demo - Partition Steps

8/9/2018
After Create Partition

8/9/2018
8/9/2018
8/9/2018
Why MDX is slow…?
 MDX is not written properly..?
 Aggregations are missing for some Dimensions

8/9/2018
Why Aggregations…?
 When Dim Table Property  IsAggregatable = False
 When we have aggregations on Single Attribute level, but we
need aggregations on group of attributes

8/9/2018
Connect to Analysis Services

8/9/2018
Table to collect Sample Data

8/9/2018
Security
 There are 2types Security
 DB Driven Security
 User Defined Security

8/9/2018
Translation
 is a language-specific representation of the name of an
Analysis Services object
 such as an attribute or a member
 provide server support for client applications which can
support multiple languages

AS / 142
Actions
 Actions in SSAS allow us to extend the cube functionality and
enable the users to interact with the cube.
 An Action in simple terms is basically an event, which can be
initiated by a user/application and it can take various forms
depending upon the type of Action defined

8/9/2018
Types of Actions
 Drill through Actions

 Reporting Actions

 Standard Actions

8/9/2018
Action
 stored MDX statement
 client command that is defined and stored on the server
 Action Target = object to which the action is attached
 optional Multidimensional Expressions (MDX)
expression
 Action Content
 Report Action with parameters

AS / 145
Demo 1 - Actions
 Go to Actions
 Click on New Action
 Name = CustomerAction
 Target Type = Attribute Members
 Target Object = SalesTerritory.Hierarchy.SalesTerritoryRegion
 Condition = [Measures].[SalesAmount ]> 0
 Action Content = URL
 Action Expression = “http://www.google.co.in”
 Additional Properties
 Invocation = Interactive
 Application = Gmail
 Caption = “Open Gmail”
 Caption is MDX = False
 Save and Process the Cube
8/9/2018
URLs
 http://bimentalist.com/2011/09/07/msbi-34-ssas-10-
how-to-defining-actions-in-ssas/

8/9/2018
Cube Deployment
1. Generate XMLA Cube Script and Upload this in VSTF
 Go to Analysis DB Server  R/Click on Cube Database
 Script Database as  Create To  New Query Window
 This will have structure of the Cube
 Change the Connection String
 No Data in this Script
2. Generate Script to Process the Data (To load the data in Cube)
 Go to Analysis DB Server  R/Click on Cube Database 
Choose Process
 Click on Generate Script
3. Create Job in SQL Server Agent to process the Cube

8/9/2018
Generate XMLA Script

8/9/2018
Generate XMLA Script

8/9/2018
Generate Process Script

8/9/2018
Generate Process Script

 Sample Script given below


8/9/2018
Create SQL Server Agent Job
 Go to SQL Server Management Studio (SSMS)
 Go to SQL Server Agent  Expand it
 R/Click Jobs  New Job
 …
 Schedule the Cube Process
 Note: SQL Server Agent must be in Start mode to run SQL
Server Jobs

8/9/2018
Verification Steps after cube
deployment
 Check whether the job is running or not
 Open Analysis and check for Cube DB
 Write MDX query

8/9/2018
Data Warehouse Concepts
 http://www.kimballgroup.com/
 http://dattatreysindol.com/category/learning-resources/tech-videos/
 http://kferrier.blogspot.in/2009/12/introduction-to-ssas-2008-video.html
 http://www.1keydata.com/datawarehousing/datawarehouse.html
 Create Cube
 http://www.youtube.com/watch?v=yawq4SGoRoY&feature=related
 http://www.youtube.com/watch?v=bkXtKlUFs70
 http://www.youtube.com/watch?v=OQhZ4vEd3dQ&feature=related
 Must see
 http://www.youtube.com/user/sqlbi?feature=watch
 http://www.youtube.com/watch?v=FfbNRJijLCE&feature=related
 http://www.youtube.com/watch?v=Pl5tPbtY5eY
 http:/ /www.youtube.com/watch?v=6LntxG9tXUk&feature=context-cha
8/9/2018
Data Warehouse Concepts

 Data Mining
 http://www.youtube.com/watch?v=EtFQv_B7YA8&feature=related
 http://www.youtube.com/user/creativecommIT?feature=watch
 http://www.youtube.com/watch?v=tAMmciaSpvk
 http://www.youtube.com/watch?v=QriqjCNJ6qo&feature=fvwrel
 Performance Tuning
 http://www.youtube.com/watch?v=AaPaIVI-yyI&feature=related
 http://www.youtube.com/watch?v=hISdcezP7ik&feature=plcp

8/9/2018
Relationships b/w Facts & Dimensions
 Regular
 Primary key column of a dimension table is directly connected to the fact
table.
 This is used in start schema
 Referenced
 Primary key columns of a dimension table is indirectly connected to the fact
table through a key column in the intermediate dimension table.
 This is used in snowflake schema
 Fact : Self referential table
 Many to Many
 a dimension is indirectly connected to a Measure Group through an
intermediate fact table which joins with the dimension table.

8/9/2018
 two measures, Packages and Last
 three related dimensions, Route, Source, and Time.
 The smaller alphanumeric values around the cube are
the members of the dimensions. E.g.: ground,

Africa, and 1st quarter. AS / 158


Measure Groups
 On a physical level, partitions – analogous to Analysis
Services 2000 partitions – are defined on Measure Groups.
 A single physical cube can contain one or more Measure
Groups

AS / 159
Must Watch
 https://www.youtube.com/watch?v=StoWu2A8Ufs
 Build Data Warehouse
 https://www.youtube.com/watch?v=wRSbgEke7kM

8/9/2018

You might also like