SlideShare ist ein Scribd-Unternehmen logo
1 von 5
Downloaden Sie, um offline zu lesen
MDX tutorial
MDX (Multidimensional Expressions) is a query language for OLAP databases, much like
SQL is a query language for relational databases. It is also a calculation language, with
syntax similar to spreadsheet formulas. MDX is used to interact with data in Microsoft SQL
Server Analysis Services cubes. It is a versatile and powerful language but one that
requires you to approach data in a whole new way.
With relational databases, the SQL language is used to assemble sets of data. With
Analysis Services, the MDX language is used to assemble tuples identifying points of data
within an n-dimensional space.
The Data Warehouse layer is the heart of the business intelligence environment. In this
layer, data from across the enterprise is presented as a unifi ed whole and in a manner
focused more on business processes and less on the source systems from which the data
originates. The dimensional model has been widely embraced as the data model of choice
within the Data Warehouse layer. Within the dimensional model, business processes and
events are presented as facts.
Measurements associated with these facts, known as fact measures, provide a means of
evaluating the represented business process or event. Facts and their fact measures are
of little value without their associated descriptive details. These details, referred to as
attributes, provide the means by which facts are sliced (filtered) and diced (grouped).
Attributes are organized in dimensions with closely related attributes residing in the same
dimension.
Within Analysis Services, the dimensional model is presented as an object referred to as a
cube. Within the cube, facts are translated into measure groups. Measure groups contain
one or more measures, corresponding to fact measures in the dimensional model.
Through the cube, dimensions are presented as cube dimensions. Relationships between
the measure groups and cube dimensions are maintained as metadata within the cube
and are automatically employed as users interact with it.
Within a cube dimension, attributes are presented as either attribute-hierarchies or
properties. An attribute is presented as an attribute-hierarchy when the attribute is
intended to be used to slice and dice the data. When an attribute is intended to provide
supplemental information or to be used for simply filtering other attributes, it is best
employed as a property.
Relationships between attributes within a dimension are explicitly defined. As with the
relationships between measure groups and cube dimensions, this information is
maintained within the multidimensional database and automatically employed as users
interact with the cube
Here is the sample cube schema.

http://www.learn-with-video-tutorials.com/mdx-video-tutorial
MDX tutorial

SELECT
[Measures].[Amount] ON COLUMNS
FROM
[Car Transactions]
Number of cars sold.
The SELECT clause defines which dimension members to include on each exis of the
reprot and the FROM clause names the cube that is being queried. The query contains no
dimension members.
To display the number of transactions we should execute the following query.
SELECT
[Measures].[Transactions Facts Table Count] ON COLUMNS
FROM
[Car Transactions]
If we create a query that has only one axis, it must be the column axis.

http://www.learn-with-video-tutorials.com/mdx-video-tutorial
MDX tutorial

SELECT
[Measures].[Price] ON COLUMNS,
[Cars].[Category].MEMBERS ON ROWS
FROM
[Car Transactions]
Total price of cars sold by category
The MEMBERS() function returns the set of members in a dimension, level or hierarchy.
The query returns the total sales price in each category.
SELECT
[Cars].[Category].MEMBERS ON ROWS,
[Measures].[Price] ON COLUMNS
FROM
[Car Transactions]
If we create two axes, one must be the column axis and one must be the row axis,
although it doesn't matter in which order they appear within the query.
SELECT
Cars.Category.MEMBERS ON ROWS,
Measures.Price ON COLUMNS
FROM
[Car Transactions]
The square brackets around a particular object identifier are optional as long as the object
identifier is not one of reserver words and does not otherwise contain any characters
other than letters, numbers or underscores.
SELECT
Cars.Category.MEMBERS ON ROWS,
Measures.Price ON COLUMNS

http://www.learn-with-video-tutorials.com/mdx-video-tutorial
MDX tutorial
FROM
Car Transactions
Cube name contains a space, so it have to be enclosed by square brackets.
SELECT
[Cars].[Category].MEMBERS ON AXIS(0),
[Measures].[Price] ON AXIS(1)
FROM
[Car Transactions]
The terms COLUMNS and ROWS are simply aliases for the true names of the axes:
Axis(0) and Axis(1) respectively. Technically, an MDX query can have up to 128 axes, with
aliases for the first five: Columns, Rows, Pages, Sections and Chapters. This fact make it
clearer to understand why a single-axis report must have a COLUMNS axis (Axis(0)) but
not a ROW axis (Axis(1)). Although our query may be correct with three axes, SQL Server
Management Studio can only render bidimensional results.
SELECT
[Cars].[Category].MEMBERS ON COLUMNS,
[Cars].[Country].[Country] ON ROWS,
[Measures].[Price] ON PAGES
FROM
[Car Transactions]
If we want do display 3D results we need to find software that can present cube data more
elaborately.
SELECT
[Measures].[Price] ON COLUMNS,
NONEMPTY([Cars].[Category].MEMBERS) ON ROWS
FROM
[Car Transactions]
The NONEMPTY() function returns the tuples that are non-empty.

http://www.learn-with-video-tutorials.com/mdx-video-tutorial
MDX tutorial
SELECT
[Measures].MEMBERS ON COLUMNS,
NONEMPTY([Cars].[Category].MEMBERS) ON ROWS
FROM
[Car Transactions]
The MEMBERS() function can be used with measures dimension: returns only measures
defined directly on the cube - calculated members are not displayed.
SELECT
ADDCALCULATEDMEMBERS([Measures].MEMBERS) ON COLUMNS,
NONEMPTY([Cars].[Category].MEMBERS) ON ROWS
FROM
[Car Transactions]
The ADDCALCULATEDMEMBERS() function returns all measures, even calculated
members, from the measures dimension when the calculated members have not been
explicitly specified in the query.
SELECT
[Measures].ALLMEMBERS ON COLUMNS,
NONEMPTY([Cars].[Category].MEMBERS) ON ROWS
FROM
[Car Transactions]
The ALLMEMBERS() function returns a set that consists of all members of the supplied
level.
Watch video lesson, visit http://www.learn-with-video-tutorials.com/mdx-video-tutorial

http://www.learn-with-video-tutorials.com/mdx-video-tutorial

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Kürzlich hochgeladen (20)

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 

Empfohlen

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Empfohlen (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

MDX introduction

  • 1. MDX tutorial MDX (Multidimensional Expressions) is a query language for OLAP databases, much like SQL is a query language for relational databases. It is also a calculation language, with syntax similar to spreadsheet formulas. MDX is used to interact with data in Microsoft SQL Server Analysis Services cubes. It is a versatile and powerful language but one that requires you to approach data in a whole new way. With relational databases, the SQL language is used to assemble sets of data. With Analysis Services, the MDX language is used to assemble tuples identifying points of data within an n-dimensional space. The Data Warehouse layer is the heart of the business intelligence environment. In this layer, data from across the enterprise is presented as a unifi ed whole and in a manner focused more on business processes and less on the source systems from which the data originates. The dimensional model has been widely embraced as the data model of choice within the Data Warehouse layer. Within the dimensional model, business processes and events are presented as facts. Measurements associated with these facts, known as fact measures, provide a means of evaluating the represented business process or event. Facts and their fact measures are of little value without their associated descriptive details. These details, referred to as attributes, provide the means by which facts are sliced (filtered) and diced (grouped). Attributes are organized in dimensions with closely related attributes residing in the same dimension. Within Analysis Services, the dimensional model is presented as an object referred to as a cube. Within the cube, facts are translated into measure groups. Measure groups contain one or more measures, corresponding to fact measures in the dimensional model. Through the cube, dimensions are presented as cube dimensions. Relationships between the measure groups and cube dimensions are maintained as metadata within the cube and are automatically employed as users interact with it. Within a cube dimension, attributes are presented as either attribute-hierarchies or properties. An attribute is presented as an attribute-hierarchy when the attribute is intended to be used to slice and dice the data. When an attribute is intended to provide supplemental information or to be used for simply filtering other attributes, it is best employed as a property. Relationships between attributes within a dimension are explicitly defined. As with the relationships between measure groups and cube dimensions, this information is maintained within the multidimensional database and automatically employed as users interact with the cube Here is the sample cube schema. http://www.learn-with-video-tutorials.com/mdx-video-tutorial
  • 2. MDX tutorial SELECT [Measures].[Amount] ON COLUMNS FROM [Car Transactions] Number of cars sold. The SELECT clause defines which dimension members to include on each exis of the reprot and the FROM clause names the cube that is being queried. The query contains no dimension members. To display the number of transactions we should execute the following query. SELECT [Measures].[Transactions Facts Table Count] ON COLUMNS FROM [Car Transactions] If we create a query that has only one axis, it must be the column axis. http://www.learn-with-video-tutorials.com/mdx-video-tutorial
  • 3. MDX tutorial SELECT [Measures].[Price] ON COLUMNS, [Cars].[Category].MEMBERS ON ROWS FROM [Car Transactions] Total price of cars sold by category The MEMBERS() function returns the set of members in a dimension, level or hierarchy. The query returns the total sales price in each category. SELECT [Cars].[Category].MEMBERS ON ROWS, [Measures].[Price] ON COLUMNS FROM [Car Transactions] If we create two axes, one must be the column axis and one must be the row axis, although it doesn't matter in which order they appear within the query. SELECT Cars.Category.MEMBERS ON ROWS, Measures.Price ON COLUMNS FROM [Car Transactions] The square brackets around a particular object identifier are optional as long as the object identifier is not one of reserver words and does not otherwise contain any characters other than letters, numbers or underscores. SELECT Cars.Category.MEMBERS ON ROWS, Measures.Price ON COLUMNS http://www.learn-with-video-tutorials.com/mdx-video-tutorial
  • 4. MDX tutorial FROM Car Transactions Cube name contains a space, so it have to be enclosed by square brackets. SELECT [Cars].[Category].MEMBERS ON AXIS(0), [Measures].[Price] ON AXIS(1) FROM [Car Transactions] The terms COLUMNS and ROWS are simply aliases for the true names of the axes: Axis(0) and Axis(1) respectively. Technically, an MDX query can have up to 128 axes, with aliases for the first five: Columns, Rows, Pages, Sections and Chapters. This fact make it clearer to understand why a single-axis report must have a COLUMNS axis (Axis(0)) but not a ROW axis (Axis(1)). Although our query may be correct with three axes, SQL Server Management Studio can only render bidimensional results. SELECT [Cars].[Category].MEMBERS ON COLUMNS, [Cars].[Country].[Country] ON ROWS, [Measures].[Price] ON PAGES FROM [Car Transactions] If we want do display 3D results we need to find software that can present cube data more elaborately. SELECT [Measures].[Price] ON COLUMNS, NONEMPTY([Cars].[Category].MEMBERS) ON ROWS FROM [Car Transactions] The NONEMPTY() function returns the tuples that are non-empty. http://www.learn-with-video-tutorials.com/mdx-video-tutorial
  • 5. MDX tutorial SELECT [Measures].MEMBERS ON COLUMNS, NONEMPTY([Cars].[Category].MEMBERS) ON ROWS FROM [Car Transactions] The MEMBERS() function can be used with measures dimension: returns only measures defined directly on the cube - calculated members are not displayed. SELECT ADDCALCULATEDMEMBERS([Measures].MEMBERS) ON COLUMNS, NONEMPTY([Cars].[Category].MEMBERS) ON ROWS FROM [Car Transactions] The ADDCALCULATEDMEMBERS() function returns all measures, even calculated members, from the measures dimension when the calculated members have not been explicitly specified in the query. SELECT [Measures].ALLMEMBERS ON COLUMNS, NONEMPTY([Cars].[Category].MEMBERS) ON ROWS FROM [Car Transactions] The ALLMEMBERS() function returns a set that consists of all members of the supplied level. Watch video lesson, visit http://www.learn-with-video-tutorials.com/mdx-video-tutorial http://www.learn-with-video-tutorials.com/mdx-video-tutorial