SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
Drive your life.




Einführung in MDX

                Matthias Gessenay
                Matthias.gessenay@corporatesoftware.ch
Was ist MDX
 «SQL» für multidimensionale Datenbanken
 Sehr kurze Abfragen mit relativ komplexen Ergebnissen
   YTD
   Rolling Average
   Net Performance
 Beispiel:
SELECT
    {
         ([Measures].[Reseller Sales Amount]),
         ([Measures].[Reseller Transaction Count]),
         ([Measures].[Reseller Order Count])
        } ON COLUMNS,
    TopCount(
        {[Product].[Subcategory].[Subcategory].Members},
        5,
        ([Measures].[Reseller Sales Amount])
        ) +
        {([Product].[Subcategory].[All Products])} ON ROWS
FROM [Step-by-Step]
;


 SQL Day 2012                                                2
Ergebnis
/*
                  Reseller Sales Amount   Reseller Transaction Count   Reseller Order Count
Road Bikes               $29,358,206.96                       12,850                  1,460
Mountain Bikes           $26,492,684.38                        7,487                  1,215
Touring Bikes            $10,451,490.22                        4,463                    478
Mountain Frames           $4,713,672.15                        4,476                    860
Road Frames               $3,849,853.34                        4,708                  1,013
All Products             $80,450,596.98                       60,855                  3,796


 Liegt immer als Pivot vor




 SQL Day 2012                                                                                 3
CUBE: EINFÜHRUNG


 SQL Day 2012      4
Der Microsoft BI Solution Stack




                                  Data Infrastructure & BI
                                  Platform
                                    Analysis Services
                                    Reporting Services
                                    Master Data Services
                                    Integration Services
                                    Data Mining
                                    Data Warehousing
Business Productivity
Infrastructure
  Dashboards &
  Scorecards
  Excel Services
  Web based forms &
  workflow
  Collaboration
  Search
  Content Management
  LOB data integration
  PowerPivot for
  SharePoint
Delivered through a
Familiar Interface
  Self-Service access &
  insight
  Data exploration & analysis
  Predictive analysis
  Data visualization
  Contextual visualization
  PowerPivot for Excel 2010
OLTP vs. Cube
 OLTP
   Optimiert für Write
   Normalisierung
   NICHT optimiert für Reporting
 Cube
   De-Normalisiert
   Optimiert für Reporting




SQL Day 2012                        8
SQL Day 2012   9
Tuple
 SQL
   Wenn ich nichts auswähle, kommen alle Datensätze (Rows)
 MDX
   Wenn ich nichts auswähle, kommt das default Measure als
     Summe
 Die Schnittmenge von den Cube-Kanten nennt man Tuple
 Der Cube ist gefüllt mit Measures (Zahlen)




SQL Day 2012                                                  10
SELECT
    {
        ([Measures].[Reseller Sales Amount]),
        ([Measures].[Reseller Transaction Count]),
        ([Measures].[Reseller Order Count])
        } ON COLUMNS,
    TopCount(

{[Product].[Subcategory].[Subcategory].Members},
        5,
        ([Measures].[Reseller Sales Amount])
        ) +
        {([Product].[Subcategory].[All Products])} ON
ROWS
FROM [Step-by-Step]

SQL Day 2012                                         11
SELECT
    {
        ([Measures].[Reseller Sales Amount]),
        ([Measures].[Reseller Transaction Count]),
        ([Measures].[Reseller Order Count])
        } ON COLUMNS,
    TopCount(

{[Product].[Subcategory].[Subcategory].Members},
        5,
        ([Measures].[Reseller Sales Amount])
        ) +
        {([Product].[Subcategory].[All Products])} ON
ROWS
FROM [Step-by-Step]

SQL Day 2012                                         12
DEMO: CUBE


 SQL Day 2012   13
MDX SCHRITT FÜR SCHRITT


 SQL Day 2012             14
Wir möchten gerne dies:
/*
EnglishProductName      TotalSalesAmount
Mountain-200 Black, 38      1327957.4077
Mountain-200 Black, 42      1139429.4872
Mountain-200 Silver, 38     1136622.4928
Mountain-200 Black, 46      1011074.3685
Mountain-200 Black, 38              NULL
Mountain-200 Silver, 42     1011486.1762
Touring-1000 Blue, 60        835290.1559
Road-350-W Yellow, 48        897217.9635
Mountain-200 Silver, 46     1029170.7639
Road-350-W Yellow, 40        840970.6467
*/


SQL Day 2012                               15
Variante SQL:


USE MdxStepByStep                                               ON m.ProductKey=n.ProductKey
                                                                LEFT OUTER JOIN ( --PRODUCT SALES IN 2004
SELECT                                                              SELECT
    m.EnglishProductName, o.TotalSalesAmount                            a.ProductKey, SUM(a.SalesAmount) AS TotalSalesAmount
FROM dbo.DimProduct m                                               FROM (
INNER JOIN ( -- TOP 10 PRODUCTS OF 2003                                 SELECT
    SELECT TOP 10                                                           x.productkey, x.salesamount
         a.ProductKey, SUM(a.SalesAmount) AS TotalSalesAmount           FROM dbo.FactInternetSales x
    FROM (                                                              INNER JOIN dbo.DimDate y
         SELECT                                                             ON x.OrderDateKey=y.DateKey
             x.productkey, x.salesamount                                WHERE y.CalendarYear=2004
         FROM dbo.FactInternetSales x                                   UNION ALL
         INNER JOIN dbo.DimDate y                                       SELECT
             ON x.OrderDateKey=y.DateKey                                    x.productkey, x.salesamount
         WHERE y.CalendarYear=2003                                      FROM dbo.FactResellerSales x
         UNION ALL                                                      INNER JOIN dbo.DimDate y
         SELECT                                                             ON x.OrderDateKey=y.DateKey
             x.productkey, x.salesamount                                WHERE y.CalendarYear=2004
         FROM dbo.FactResellerSales x                                   ) a
         INNER JOIN dbo.DimDate y                                   GROUP BY a.ProductKey
             ON x.OrderDateKey=y.DateKey                            ) o
         WHERE y.CalendarYear=2003                                  ON m.ProductKey=o.productkey
        ) a                                                     ORDER BY n.TotalSalesAmount DESC
    GROUP BY a.ProductKey
    ORDER BY TotalSalesAmount DESC
    ) n




            SQL Day 2012                                                                                                   16
Variante MDX:
WITH
MEMBER [Measures].[Total Sales Amount] AS
    ([Measures].[Internet Sales Amount]) + ([Measures].[Reseller Sales
Amount])
SET [Top 10 Products of 2003] AS
    TOPCOUNT(
        {[Product].[Product].[Product].Members},
        10,
        ([Measures].[Total Sales Amount], [Date].[Calendar Year].[CY
2003])
        )
SELECT
    {([Measures].[Total Sales Amount])} ON COLUMNS,
    {[Top 10 Products of 2003]} ON ROWS
FROM [Step-by-Step]
WHERE ([Date].[Calendar Year].[CY 2004])
;



 SQL Day 2012                                                       17
DEMO


 SQL Day 2012   18
Funktionen & With
1. WITH
2. MEMBER [Measures].[Total Sales Amount] AS
3. [Measures].[Internet Sales Amount]+[Measures].[Reseller Sales
   Amount]
4. SET [Top 10 Products of 2003] AS
5. TOPCOUNT( [Product].[Product].[Product].Members, 10,
   ([Measures].[Total Sales Amount], [Date].[Calendar Year].[CY
   2003]))
6. SELECT
7.   {([Measures].[Total Sales Amount])} ON COLUMNS,
8.   {[Top 10 Products of 2003]} ON ROWS
9. FROM [Step-by-Step]
10.WHERE [Date].[Calendar Year].&[2004]



 SQL Day 2012                                                      19
Where
 Schränkt den Cube ein (Slicing)
 Verändert damit die Resultate




 SQL Day 2012                       20
WHERE: DEMO


 SQL Day 2012   21
MDX Anwendungsbereiche
   Reporting Services
   Excel
   PerformancePoint
   Eigene Apps ...
   SSIS




SQL Day 2012             22
FRAGEN?


 SQL Day 2012   23

Weitere ähnliche Inhalte

Ähnlich wie Einführung in mdx

William Berth Bi Portfolio
William Berth Bi PortfolioWilliam Berth Bi Portfolio
William Berth Bi Portfolio
newberth
 
Database Development Replication Security Maintenance Report
Database Development Replication Security Maintenance ReportDatabase Development Replication Security Maintenance Report
Database Development Replication Security Maintenance Report
nyin27
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
skymusic
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
eileensauer
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
eileensauer
 
Reporting Tips
Reporting TipsReporting Tips
Reporting Tips
lkurriger
 
New Features of SQL Server 2016
New Features of SQL Server 2016New Features of SQL Server 2016
New Features of SQL Server 2016
Mir Mahmood
 
Mdx 2nddraft
Mdx 2nddraftMdx 2nddraft
Mdx 2nddraft
edarsoft
 
SSAS Project Profile
SSAS Project ProfileSSAS Project Profile
SSAS Project Profile
tthompson0421
 

Ähnlich wie Einführung in mdx (20)

Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
Microsoft SQL Server Analysis Services (SSAS) - A Practical Introduction
 
William Berth Bi Portfolio
William Berth Bi PortfolioWilliam Berth Bi Portfolio
William Berth Bi Portfolio
 
Database Development Replication Security Maintenance Report
Database Development Replication Security Maintenance ReportDatabase Development Replication Security Maintenance Report
Database Development Replication Security Maintenance Report
 
70433 Dumps DB
70433 Dumps DB70433 Dumps DB
70433 Dumps DB
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Uncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony DavisUncovering SQL Server query problems with execution plans - Tony Davis
Uncovering SQL Server query problems with execution plans - Tony Davis
 
Analyst View of Data Virtualization: Conversations with Boulder Business Inte...
Analyst View of Data Virtualization: Conversations with Boulder Business Inte...Analyst View of Data Virtualization: Conversations with Boulder Business Inte...
Analyst View of Data Virtualization: Conversations with Boulder Business Inte...
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Reporting Tips
Reporting TipsReporting Tips
Reporting Tips
 
Data Virtualization for Data Architects (New Zealand)
Data Virtualization for Data Architects (New Zealand)Data Virtualization for Data Architects (New Zealand)
Data Virtualization for Data Architects (New Zealand)
 
Aggregation Strategies
Aggregation StrategiesAggregation Strategies
Aggregation Strategies
 
New Features of SQL Server 2016
New Features of SQL Server 2016New Features of SQL Server 2016
New Features of SQL Server 2016
 
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...
Smarter Together - Bringing Relational Algebra, Powered by Apache Calcite, in...
 
DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...
DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...
DataSaturday #1 - PBI Modeling At Warp Speed With Tabular Editor Advanced Scr...
 
Mdx 2nddraft
Mdx 2nddraftMdx 2nddraft
Mdx 2nddraft
 
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave ClubJoining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club
Joining the Club: Using Spark to Accelerate Big Data at Dollar Shave Club
 
IT301-Datawarehousing (1) and its sub topics.pptx
IT301-Datawarehousing (1) and its sub topics.pptxIT301-Datawarehousing (1) and its sub topics.pptx
IT301-Datawarehousing (1) and its sub topics.pptx
 
SSAS Project Profile
SSAS Project ProfileSSAS Project Profile
SSAS Project Profile
 
Effective Android Data Binding
Effective Android Data BindingEffective Android Data Binding
Effective Android Data Binding
 

Mehr von Digicomp Academy AG

Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
Digicomp Academy AG
 

Mehr von Digicomp Academy AG (20)

Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
Becoming Agile von Christian Botta – Personal Swiss Vortrag 2019
 
Swiss IPv6 Council – Case Study - Deployment von IPv6 in einer Container Plat...
Swiss IPv6 Council – Case Study - Deployment von IPv6 in einer Container Plat...Swiss IPv6 Council – Case Study - Deployment von IPv6 in einer Container Plat...
Swiss IPv6 Council – Case Study - Deployment von IPv6 in einer Container Plat...
 
Innovation durch kollaboration gennex 2018
Innovation durch kollaboration gennex 2018Innovation durch kollaboration gennex 2018
Innovation durch kollaboration gennex 2018
 
Roger basler meetup_digitale-geschaeftsmodelle-entwickeln_handout
Roger basler meetup_digitale-geschaeftsmodelle-entwickeln_handoutRoger basler meetup_digitale-geschaeftsmodelle-entwickeln_handout
Roger basler meetup_digitale-geschaeftsmodelle-entwickeln_handout
 
Roger basler meetup_21082018_work-smarter-not-harder_handout
Roger basler meetup_21082018_work-smarter-not-harder_handoutRoger basler meetup_21082018_work-smarter-not-harder_handout
Roger basler meetup_21082018_work-smarter-not-harder_handout
 
Xing expertendialog zu nudge unit x
Xing expertendialog zu nudge unit xXing expertendialog zu nudge unit x
Xing expertendialog zu nudge unit x
 
Responsive Organisation auf Basis der Holacracy – nur ein Hype oder die Zukunft?
Responsive Organisation auf Basis der Holacracy – nur ein Hype oder die Zukunft?Responsive Organisation auf Basis der Holacracy – nur ein Hype oder die Zukunft?
Responsive Organisation auf Basis der Holacracy – nur ein Hype oder die Zukunft?
 
IPv6 Security Talk mit Joe Klein
IPv6 Security Talk mit Joe KleinIPv6 Security Talk mit Joe Klein
IPv6 Security Talk mit Joe Klein
 
Agiles Management - Wie geht das?
Agiles Management - Wie geht das?Agiles Management - Wie geht das?
Agiles Management - Wie geht das?
 
Gewinnen Sie Menschen und Ziele - Referat von Andi Odermatt
Gewinnen Sie Menschen und Ziele - Referat von Andi OdermattGewinnen Sie Menschen und Ziele - Referat von Andi Odermatt
Gewinnen Sie Menschen und Ziele - Referat von Andi Odermatt
 
Querdenken mit Kreativitätsmethoden – XING Expertendialog
Querdenken mit Kreativitätsmethoden – XING ExpertendialogQuerdenken mit Kreativitätsmethoden – XING Expertendialog
Querdenken mit Kreativitätsmethoden – XING Expertendialog
 
Xing LearningZ: Digitale Geschäftsmodelle entwickeln
Xing LearningZ: Digitale Geschäftsmodelle entwickelnXing LearningZ: Digitale Geschäftsmodelle entwickeln
Xing LearningZ: Digitale Geschäftsmodelle entwickeln
 
Swiss IPv6 Council: The Cisco-Journey to an IPv6-only Building
Swiss IPv6 Council: The Cisco-Journey to an IPv6-only BuildingSwiss IPv6 Council: The Cisco-Journey to an IPv6-only Building
Swiss IPv6 Council: The Cisco-Journey to an IPv6-only Building
 
UX – Schlüssel zum Erfolg im Digital Business
UX – Schlüssel zum Erfolg im Digital BusinessUX – Schlüssel zum Erfolg im Digital Business
UX – Schlüssel zum Erfolg im Digital Business
 
Minenfeld IPv6
Minenfeld IPv6Minenfeld IPv6
Minenfeld IPv6
 
Was ist design thinking
Was ist design thinkingWas ist design thinking
Was ist design thinking
 
Die IPv6 Journey der ETH Zürich
Die IPv6 Journey der ETH Zürich Die IPv6 Journey der ETH Zürich
Die IPv6 Journey der ETH Zürich
 
Xing LearningZ: Die 10 + 1 Trends im (E-)Commerce
Xing LearningZ: Die 10 + 1 Trends im (E-)CommerceXing LearningZ: Die 10 + 1 Trends im (E-)Commerce
Xing LearningZ: Die 10 + 1 Trends im (E-)Commerce
 
Zahlen Battle: klassische werbung vs.online-werbung-somexcloud
Zahlen Battle: klassische werbung vs.online-werbung-somexcloudZahlen Battle: klassische werbung vs.online-werbung-somexcloud
Zahlen Battle: klassische werbung vs.online-werbung-somexcloud
 
General data protection regulation-slides
General data protection regulation-slidesGeneral data protection regulation-slides
General data protection regulation-slides
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Einführung in mdx

  • 1. Drive your life. Einführung in MDX Matthias Gessenay Matthias.gessenay@corporatesoftware.ch
  • 2. Was ist MDX  «SQL» für multidimensionale Datenbanken  Sehr kurze Abfragen mit relativ komplexen Ergebnissen  YTD  Rolling Average  Net Performance  Beispiel: SELECT { ([Measures].[Reseller Sales Amount]), ([Measures].[Reseller Transaction Count]), ([Measures].[Reseller Order Count]) } ON COLUMNS, TopCount( {[Product].[Subcategory].[Subcategory].Members}, 5, ([Measures].[Reseller Sales Amount]) ) + {([Product].[Subcategory].[All Products])} ON ROWS FROM [Step-by-Step] ; SQL Day 2012 2
  • 3. Ergebnis /* Reseller Sales Amount Reseller Transaction Count Reseller Order Count Road Bikes $29,358,206.96 12,850 1,460 Mountain Bikes $26,492,684.38 7,487 1,215 Touring Bikes $10,451,490.22 4,463 478 Mountain Frames $4,713,672.15 4,476 860 Road Frames $3,849,853.34 4,708 1,013 All Products $80,450,596.98 60,855 3,796  Liegt immer als Pivot vor SQL Day 2012 3
  • 5. Der Microsoft BI Solution Stack Data Infrastructure & BI Platform Analysis Services Reporting Services Master Data Services Integration Services Data Mining Data Warehousing
  • 6. Business Productivity Infrastructure Dashboards & Scorecards Excel Services Web based forms & workflow Collaboration Search Content Management LOB data integration PowerPivot for SharePoint
  • 7. Delivered through a Familiar Interface Self-Service access & insight Data exploration & analysis Predictive analysis Data visualization Contextual visualization PowerPivot for Excel 2010
  • 8. OLTP vs. Cube  OLTP  Optimiert für Write  Normalisierung  NICHT optimiert für Reporting  Cube  De-Normalisiert  Optimiert für Reporting SQL Day 2012 8
  • 10. Tuple  SQL  Wenn ich nichts auswähle, kommen alle Datensätze (Rows)  MDX  Wenn ich nichts auswähle, kommt das default Measure als Summe  Die Schnittmenge von den Cube-Kanten nennt man Tuple  Der Cube ist gefüllt mit Measures (Zahlen) SQL Day 2012 10
  • 11. SELECT { ([Measures].[Reseller Sales Amount]), ([Measures].[Reseller Transaction Count]), ([Measures].[Reseller Order Count]) } ON COLUMNS, TopCount( {[Product].[Subcategory].[Subcategory].Members}, 5, ([Measures].[Reseller Sales Amount]) ) + {([Product].[Subcategory].[All Products])} ON ROWS FROM [Step-by-Step] SQL Day 2012 11
  • 12. SELECT { ([Measures].[Reseller Sales Amount]), ([Measures].[Reseller Transaction Count]), ([Measures].[Reseller Order Count]) } ON COLUMNS, TopCount( {[Product].[Subcategory].[Subcategory].Members}, 5, ([Measures].[Reseller Sales Amount]) ) + {([Product].[Subcategory].[All Products])} ON ROWS FROM [Step-by-Step] SQL Day 2012 12
  • 13. DEMO: CUBE SQL Day 2012 13
  • 14. MDX SCHRITT FÜR SCHRITT SQL Day 2012 14
  • 15. Wir möchten gerne dies: /* EnglishProductName TotalSalesAmount Mountain-200 Black, 38 1327957.4077 Mountain-200 Black, 42 1139429.4872 Mountain-200 Silver, 38 1136622.4928 Mountain-200 Black, 46 1011074.3685 Mountain-200 Black, 38 NULL Mountain-200 Silver, 42 1011486.1762 Touring-1000 Blue, 60 835290.1559 Road-350-W Yellow, 48 897217.9635 Mountain-200 Silver, 46 1029170.7639 Road-350-W Yellow, 40 840970.6467 */ SQL Day 2012 15
  • 16. Variante SQL: USE MdxStepByStep ON m.ProductKey=n.ProductKey LEFT OUTER JOIN ( --PRODUCT SALES IN 2004 SELECT SELECT m.EnglishProductName, o.TotalSalesAmount a.ProductKey, SUM(a.SalesAmount) AS TotalSalesAmount FROM dbo.DimProduct m FROM ( INNER JOIN ( -- TOP 10 PRODUCTS OF 2003 SELECT SELECT TOP 10 x.productkey, x.salesamount a.ProductKey, SUM(a.SalesAmount) AS TotalSalesAmount FROM dbo.FactInternetSales x FROM ( INNER JOIN dbo.DimDate y SELECT ON x.OrderDateKey=y.DateKey x.productkey, x.salesamount WHERE y.CalendarYear=2004 FROM dbo.FactInternetSales x UNION ALL INNER JOIN dbo.DimDate y SELECT ON x.OrderDateKey=y.DateKey x.productkey, x.salesamount WHERE y.CalendarYear=2003 FROM dbo.FactResellerSales x UNION ALL INNER JOIN dbo.DimDate y SELECT ON x.OrderDateKey=y.DateKey x.productkey, x.salesamount WHERE y.CalendarYear=2004 FROM dbo.FactResellerSales x ) a INNER JOIN dbo.DimDate y GROUP BY a.ProductKey ON x.OrderDateKey=y.DateKey ) o WHERE y.CalendarYear=2003 ON m.ProductKey=o.productkey ) a ORDER BY n.TotalSalesAmount DESC GROUP BY a.ProductKey ORDER BY TotalSalesAmount DESC ) n SQL Day 2012 16
  • 17. Variante MDX: WITH MEMBER [Measures].[Total Sales Amount] AS ([Measures].[Internet Sales Amount]) + ([Measures].[Reseller Sales Amount]) SET [Top 10 Products of 2003] AS TOPCOUNT( {[Product].[Product].[Product].Members}, 10, ([Measures].[Total Sales Amount], [Date].[Calendar Year].[CY 2003]) ) SELECT {([Measures].[Total Sales Amount])} ON COLUMNS, {[Top 10 Products of 2003]} ON ROWS FROM [Step-by-Step] WHERE ([Date].[Calendar Year].[CY 2004]) ; SQL Day 2012 17
  • 18. DEMO SQL Day 2012 18
  • 19. Funktionen & With 1. WITH 2. MEMBER [Measures].[Total Sales Amount] AS 3. [Measures].[Internet Sales Amount]+[Measures].[Reseller Sales Amount] 4. SET [Top 10 Products of 2003] AS 5. TOPCOUNT( [Product].[Product].[Product].Members, 10, ([Measures].[Total Sales Amount], [Date].[Calendar Year].[CY 2003])) 6. SELECT 7. {([Measures].[Total Sales Amount])} ON COLUMNS, 8. {[Top 10 Products of 2003]} ON ROWS 9. FROM [Step-by-Step] 10.WHERE [Date].[Calendar Year].&[2004] SQL Day 2012 19
  • 20. Where  Schränkt den Cube ein (Slicing)  Verändert damit die Resultate SQL Day 2012 20
  • 21. WHERE: DEMO SQL Day 2012 21
  • 22. MDX Anwendungsbereiche  Reporting Services  Excel  PerformancePoint  Eigene Apps ...  SSIS SQL Day 2012 22
  • 23. FRAGEN? SQL Day 2012 23