SlideShare une entreprise Scribd logo
1  sur  51
Télécharger pour lire hors ligne
What All Microsoft BI Developers
  Need to Know About MDX
         Speaker: Nathan Peterson
           Solid Quality Mentors


      Silicon Valley SQL Server User Group
                January 19, 2009




         Mark Ginnebaugh, User Group Leader,
               mark@designmind.com
Nathan Peterson

 Solid Quality Mentors
   Currently working on an Analysis Services project
   for the US Army

 Lead developer of a local cube generating utility
 called CubeSlice
What do all developers need to know about
MDX?

 You should be able to:
   Create and debug Calculated Members.
   Create and debug Named Sets.
 What you need to know to accomplish this:
   Understand MDX Concepts.
   Learn MDX Syntax.
   Learn some MDX functions.
   Learn some practical applications of MDX.
What Is MDX?

 Multi-Dimensional eXpressions
 SQL is used for relational queries, while MDX is used
 for multidimensional queries.
 Calculated members allow you to incorporate
 multidimensional logic into your cube.
 Named sets allow you to pre-define dynamic groups
 of members to be displayed on columns or rows.
Sample calculated member

with member
measures.[Last Year Sales Amount]
as
(
measures.[Sales Amount],
ParallelPeriod
   (
   [Date].[Calendar].[Calendar Year],
   1,
   [Date].[Calendar].CurrentMember
   )
)
Sample named set


with
set [Top 5 Products]
as
topcount
   (
   [Product].[Product].Members,
   5,
   Measures.[Internet Sales Amount]
   )
Comparing MDX to SQL

 From
   SQL selects from a table.
   MDX selects from a cube.
 Dimensionality
   SQL returns one or more columns and 0 or more rows.
   MDX can return data for 0, 1, 2, 3 or more axes.
 Where
   SQL has a filter.
   MDX has a slicer.
MDX query with two axes and two slicers


select
Measures.AllMembers on columns,
[Date].[Calendar].&[2003].Children on rows
from [Adventure Works]
where
(
[Customer].[Customer Geography].[France],
[Product].[Product Categories].[Bikes]
)
Dimensions and Measures
Same query, using axis numbers instead of axis
names


select
Measures.AllMembers on 0,
[Date].[Calendar].&[2003].Children on 1
from [Adventure Works]
where
(
[Customer].[Customer Geography].[France],
[Product].[Product Categories].[Bikes]
)
Using MDX requires multidimensional thinking

 In a cube
   Dimensions have hierarchies
   Hierarchies have levels
   Levels have members
 In a cellset
   Each axis contains a set
   Each set consists of a group of members or a group of
   tuples
   Tuples have members from different hierarchies
Multidimensional thinking – Where are you?

 Every member is in a level.
 Every level is in a hierarchy.
 Every hierarchy is a part of a dimension.
 For every cell of the cellset, there’s (almost) always
 a Current Member for each hierarchy.
 The Current Member may be set from the column,
 the row, the slicer, or the default member.
Create a set by listing members

 The simplest set is a list of members.
 The boundaries of the set are indicated with curly
 braces {}.
  select
  {
  [Product].[Category].[All Products],
  [Product].[Category].[Accessories],
  [Product].[Category].[Bikes],
  [Product].[Category].[Clothing],
  [Product].[Category].[Components]
  } on 0
  from [Adventure Works]
Create a set with a function

 There are many MDX functions that create sets.
 This query uses the .Members function to return all
 the members from a hierarchy – and gives the same
 result as the previous query.
 You don’t have to use {} when you create a set with
 a function.
  select
  [Product].[Category].Members on 0
  from [Adventure Works]
Tuples

 Each cell in a cellset shows data for one particular
 member from each hierarchy.
 A tuple is a way of specifying which member should
 be used from each of the hierarchies.
 Tuples are written like points in a geometric grid:
   (6,3) identifies point 6 on the x-axis and point 3 on the
   y-axis.
   ([2009],[US],[Bikes],[Internet Sales Amount]) identifies
   Internet Sales for Bikes in the US in 2009.
2 Dimensional Tuple


        6
        5       2 Dimensional Tuple
        4
        3
        2                           (6, 2)
        1



            1   2   3   4   5   6     7      8
Create a set by listing tuples

   select
   {
     (
     [Date].[Calendar Year].&[2002],
     [Product].[Category].[Accessories]
       ),
       (
       [Date].[Calendar Year].&[2002],
       [Product].[Category].[Bikes]
       ),
       (
       [Date].[Calendar Year].&[2003],
       [Product].[Category].[Accessories]
       ),
       (
       [Date].[Calendar Year].&[2003],
       [Product].[Category].[Bikes]
       )
   }
   on 0
   from [Adventure Works]
Listing Tuples


          [Accessories]
             [Clothing]         2 Dimensional Tuple
        [Touring Bikes]
          [Road Bikes]
                                ([2006], [Mountain Bikes])
       [Mountain Bikes]
         [All Products]



                          2     2     2     2     2     2     2     2
                          0     0     0     0     0     0     0     0
                           0     0     0     0     0     0     0     0
                            1     2     3     4     5     6     7     8
Create a set of tuples by multiplying two sets of
members

 select
 {
   [Date].[Calendar Year].&[2002],
   [Date].[Calendar Year].&[2003]
 }
 *
 {
   [Product].[Category].[Accessories],
   [Product].[Category].[Bikes]
 }
 on 0
 from [Adventure Works]
3 Dimensional Tuple


       [Accessories]
          [Clothing]         3 Dimensional Tuple
                             Difficult to Show in 3 Axes –
     [Touring Bikes]         Where to place the point?
       [Road Bikes]
                        ([2006], [Mountain Bikes], [Red])
    [Mountain Bikes]
      [All Products]


               [Red]
           [Blue]
                       2     2     2     2     2     2     2     2
       [Pink]          0     0     0     0     0     0     0     0
                        0     0     0     0     0     0     0     0
                         1     2     3     4     5     6     7     8
3 Dimensional Tuple
Combining 2 Hierarchies on 1 Axis


        ([Blue], [Road Bikes])
        ([Red], [Road Bikes])           3 Dimensional Tuple
    ([Blue], [Mountain Bikes])
    ([Red], [Mountain Bikes])

       ([Blue], [All Products])
                                  ([2006], [Mountain Bikes], [Red])
       ([Red], [All Products])



                                  2     2     2     2     2     2     2     2
                                  0     0     0     0     0     0     0     0
                                   0     0     0     0     0     0     0     0
                                    1     2     3     4     5     6     7     8
The Where clause

 The Where clause is an optional part of an MDX
 query.
 The Where clause is a slicer, not a filter.
   You can’t use the Where clause for limiting the value to
   a threshold (Sales over $10,000).
   Use the Filter function for filtering.
 The Where clause often looks like a tuple and
 actually is a tuple – but it doesn’t have to be.
Where clause using a tuple – one member from
each referenced hierarchy


  select
  Measures.[Internet Sales Amount] on 0
  from [Adventure Works]
  where
  (
  [Customer].[Customer Geography].[France],
  [Product].[Product Categories].[Bikes]
  )
Where clause with slicing on multiple members
from one hierarchy


select
Measures.[Internet Sales Amount] on 0
from [Adventure Works]
where
(
[Customer].[Customer Geography].[France],
  {
  [Product].[Product Categories].[Bikes],
  [Product].[Product Categories].[Clothing]
  }
)
The With clause

 The With clause is used for creating both calculated
 members and named sets.
 These calculated members and named sets are only
 valid for the life of the query.
 You can also create calculated members and named
 sets that are persistent:
   Lasting for the life of a session.
   Created permanently in the cube.
Creating calculated member in the With clause


with
member Measures.[Average Internet Sales]
as
[Measures].[Internet Sales Amount]
/
[Measures].[Internet Order Count],
format_string = "currency"
select
{Measures.[Average Internet Sales]} on 0
from [Adventure Works]
Members, Sets, Tuples


                ([Blue], [Road Bikes])
                ([Red], [Road Bikes])              Members, Sets, Tuples
            ([Blue], [Mountain Bikes])
Set of
(Partial)   ([Red], [Mountain Bikes])
Tuples
               ([Blue], [All Products])
                                              ([2006], [Mountain Bikes], [Red])
               ([Red], [All Products])
                                                               (Partial) Tuple
              Member

                                             2     2     2      2     2     2     2     2
                                             0     0     0      0     0     0     0     0
                                              0     0     0      0     0     0     0     0
                                               1     2     3      4     5     6     7     8


                                          Set of Members
Creating named set in the With clause

with
set [Products - High Selling on Internet]
as
filter
   (
   [Product].[Product].[Product].Members,
   [Measures].[Internet Sales Amount]
      > 50000
   )
select
{Measures.[Internet Sales Amount]} on 0,
[Products - High Selling on Internet] on 1
from [Adventure Works]
Full Tuple


       ([Blue], [Road Bikes])    ([2006], [Mountain Bikes], [Red], [All
        ([Red], [Road Bikes])    Promotions], [All Gender],
                                 [Measures].[Reseller Sales Amount],
   ([Blue], [Mountain Bikes])
                                 etc…)
    ([Red], [Mountain Bikes])
      ([Blue], [All Products])
      ([Red], [All Products])



                                 2     2     2     2     2     2     2     2
                                 0     0     0     0     0     0     0     0
                                  0     0     0     0     0     0     0     0
                                   1     2     3     4     5     6     7     8
MDX Punctuation


 Use {} for sets.
 Use () for tuples.
 Use [] for names of cubes, dimensions, hierarchies,
 levels, and members.
 Use commas all over the place (except not between
 multiple calculated members or named sets defined
 in the same query).
Where to write your MDX

 In a client application like PerformancePoint, which
 allows you to write code for calculated measures
 and sets.
 In a query editor like the SQL Server Management
 Studio.
 In the MDX Script of a cube.
 TIP: It’s often easier to write the code in a query editor
   first and then put it into the MDX Script.
Writing MDX for a KPI


 You can write MDX to create the values for a KPI,
 whether you’re working with Analysis Services KPIs
 or PerformancePoint Services KPIs.
 For both tools, it’s easier to create calculated
 members in the MDX script for the values first.
 TIP: When building KPIs in the BIDS, use a template
 for assigning the Status and the Trend.
Functions – Navigating within a level


 PrevMember
 NextMember
 Lag()
 Lead()
Examples of navigating in a level

 Navigation functions are often used with Dates.
 Note: PrevMember, Lag(1), and Lead(-1) all return
 the same member.
 [1997].PrevMember
                [1996]
 [March 2010].NextMember [April 2010]
 [10 April 2009].Lag(2)        [8 April
 2009]
 [December 2009].Lead(12) [December 2010]
Functions – All in the Family


  Parent
  Children, FirstChild, LastChild
  Descendants
  Ancestor, Ascendants
  Siblings, FirstSibling, LastSibling
  Cousin
Examples of family functions

  Some of the family functions return individual
  members, while other return sets.
  If a function returns an individual member, you can
  use another function with it.
[Mar 1997].Parent                   [1997]
[Q1 2009].Children             [Jan 09]:[Mar
09]
[2009].FirstChild                   [Q1 2009]
Descendants([2009], 2)    [Jan 09]:[Dec 09]
Descendants([2009],[Date])[1Jan09]:[31Dec09]
Ancestor([Mar 2008], 3)   [2008]
FirstSibling([Mar 2007]) [Jan 2007]
Functions – Multiplying, adding, subtracting,
intersecting sets

  Set multiplication, addition, and subtractions can
  be indicated with mathematical symbols or with
  functions.

  Multiplication         *            Crossjoin
  Addition               +            Union
  Subtraction            -            Except
  Intersection                        Intersect
Example of set multiplication

 These two sets are equivalent.

  [Date].[Fiscal].[Month].members
  *
  [Product].[Product].members

  Crossjoin
    (
    [Date].[Fiscal].[Month].members,
    [Product].[Product].members
    )
Practical Applications of MDX


 Comparing with a previous time period.
 Comparing with the same time period in the
 previous year.
 Year-To-Date.
 Rolling Average.
 Percent contribution.
Comparing with a previous time period

with member Measures.[Last Month Sales]
as
(
Measures.[Internet Sales Amount],
[Date].[Calendar].PrevMember
)
select
{
Measures.[Internet Sales Amount],
Measures.[Last Month Sales]
} on 0,
[Date].[Calendar].[Month].members on 1
from [Adventure Works]
Comparing with the same period in the previous
year

with member
measures.[Last Year Sales Amount]
as
(
measures.[Sales Amount],
ParallelPeriod
   (
   [Date].[Calendar].[Calendar Year],
   1,
   [Date].[Calendar].CurrentMember
   )
)
Year-To-
Year-To-Date

 with
 member measures.[YTD Sales]
 as
 sum
   (
   ytd([Date].[Calendar].CurrentMember),
   Measures.[Internet Sales Amount]
   )
 select
 {
 Measures.[Internet Sales Amount],
 Measures.[YTD Sales]
 } on 0,
 [Date].[Calendar].[Month].members on 1
 from [Adventure Works]
Rolling Average

With
member measures.[Previous 6 Month Rolling AVG]
as
sum
  (
    [Date].[Calendar].lag(6):
    [Date].[Calendar].lag(1),
  Measures.[Internet Sales Amount]
  ) / 6
select
{
Measures.[Internet Sales Amount],
Measures.[Previous 6 Month Rolling AVG]
} on 0,
[Date].[Calendar].[Month].members on 1
from [Adventure Works]
Percent Contribution

With member Measures.[Percent of Parent Sales]
as
Measures.[Internet Sales Amount]
/
  (
  Measures.[Internet Sales Amount],
  [Product].[Product Categories].Parent
  )
select
{
Measures.[Internet Sales Amount],
Measures.[Percent of Parent Sales]
} on 0,
[Product].[Product Categories]. members on 1
from [Adventure Works]
Additional topics – if there’s time


   Dealing with exceptions
   String manipulation
   Generate
   Recursion
Dealing with exceptions

  A calculation needs to be valid everywhere
 with
 member [Measures].[% Change # of Customers]
 as
 case
   when [Date].[Fiscal].CurrentMember.Level.Ordinal = 0 then "NA”
   when [Date].[Fiscal].CurrentMember.Level.Ordinal = 5 then Null
   when isempty
        (
          ([Date].[Fiscal].CurrentMember.PrevMember, [Measures].[Customer Count])
        ) then null
   else
 (
   ([Date].[Fiscal].CurrentMember, [Measures].[Customer Count])
   -
   ([Date].[Fiscal].PrevMember, [Measures].[Customer Count])
 )
 /
   ([Date].[Fiscal].PrevMember,[Measures].[Customer Count])
 end
Functions - String manipulation

 Turning the current date into a member reference

Strtomember
  (
    "[Date].[Fiscal].[Date].&["
    + cstr(year(now()) - 6)
    + right("0" + cstr(month(now())), 2)
    + right("0" + cstr(day(now())), 2)
    + "]"
  )
The Generate function

 What are the five top products most purchased by
 people living in my top five cities?
  generate
    (
    topcount
      (
      [Customer].[Customer Geography].[City].members,
      5,
      [Measures].[Internet Sales Amount]
      ),
    crossjoin
      (
      [Customer].[Customer Geography].CurrentMember,
      topcount
        (
        [Product].[Product].[Product].members,
        5,
        [Measures].[Internet Sales Amount]
    ) ) )
Recursion

 Finding the most recent purchase

with
member measures.[Most Recent Purchase]
as
iif
   (
   [Measures].[Internet Sales Amount] > 0,
   [Measures].[Internet Sales Amount],
   [Date].[Calendar].PrevMember
   )
Thank you
npeterson@solidq.com

http://www.databasejournal.com/article.php/1459531/

http://msdn.microsoft.com/en-us/library/ms145970.aspx

http://www.sqlserveranalysisservices.com

http://www.ssas-info.com/analysis-services-faq/27-mdx

http://www.mosha.com/msolap/mdx.htm

http://cwebbbi.spaces.live.com
To learn more or inquire about speaking opportunities, please contact:

                Mark Ginnebaugh, User Group Leader
                      mark@designmind.com

Contenu connexe

En vedette

Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence PortfolioDoug Armantrout
 
Ssis sql ssrs_sp_ssas_mdx_hb_li
Ssis sql ssrs_sp_ssas_mdx_hb_liSsis sql ssrs_sp_ssas_mdx_hb_li
Ssis sql ssrs_sp_ssas_mdx_hb_liHong-Bing Li
 
Multidimensional expressions mdx - reference
Multidimensional expressions   mdx - referenceMultidimensional expressions   mdx - reference
Multidimensional expressions mdx - referenceSteve Xu
 
Mdx university dubai courses
Mdx university dubai coursesMdx university dubai courses
Mdx university dubai coursesanjam tm
 
SQL Server Analysis Services and MDX
SQL Server Analysis Services and MDXSQL Server Analysis Services and MDX
SQL Server Analysis Services and MDXMark Ginnebaugh
 
Enhancing Dashboard Visuals with Multi-Dimensional Expressions (MDX)
Enhancing Dashboard Visuals with Multi-Dimensional Expressions (MDX)Enhancing Dashboard Visuals with Multi-Dimensional Expressions (MDX)
Enhancing Dashboard Visuals with Multi-Dimensional Expressions (MDX)Daniel Upton
 
2012 Acura MDX Brochure | DCH Acura of Temecula
2012 Acura MDX Brochure | DCH Acura of Temecula2012 Acura MDX Brochure | DCH Acura of Temecula
2012 Acura MDX Brochure | DCH Acura of TemeculaDCH Acura of Temecula
 
Citrix MDX Technologies Feature Brief
Citrix MDX Technologies Feature BriefCitrix MDX Technologies Feature Brief
Citrix MDX Technologies Feature BriefNuno Alves
 
IBM Cognos Dimensional Dashboarding Techniques
IBM Cognos Dimensional Dashboarding TechniquesIBM Cognos Dimensional Dashboarding Techniques
IBM Cognos Dimensional Dashboarding TechniquesSenturus
 
rmoore.smartquery KScope15
rmoore.smartquery KScope15rmoore.smartquery KScope15
rmoore.smartquery KScope15Ron Moore
 
Moore Advanced Calculations in Calc Manager OW 20151015
Moore Advanced Calculations in Calc Manager  OW 20151015Moore Advanced Calculations in Calc Manager  OW 20151015
Moore Advanced Calculations in Calc Manager OW 20151015Ron Moore
 
Ssis sql ssrs_ssas_sp_mdx_hb_li
Ssis sql ssrs_ssas_sp_mdx_hb_liSsis sql ssrs_ssas_sp_mdx_hb_li
Ssis sql ssrs_ssas_sp_mdx_hb_liHong-Bing Li
 
Big Data MDX with Mondrian and Apache Kylin
Big Data MDX with Mondrian and Apache KylinBig Data MDX with Mondrian and Apache Kylin
Big Data MDX with Mondrian and Apache Kylininovex GmbH
 
Essbase Calculations A Visual Approach KScope 2010
Essbase Calculations A Visual Approach KScope 2010Essbase Calculations A Visual Approach KScope 2010
Essbase Calculations A Visual Approach KScope 2010Ron Moore
 

En vedette (20)

Introduction to mdx query ppt
Introduction to mdx query pptIntroduction to mdx query ppt
Introduction to mdx query ppt
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Ssis sql ssrs_sp_ssas_mdx_hb_li
Ssis sql ssrs_sp_ssas_mdx_hb_liSsis sql ssrs_sp_ssas_mdx_hb_li
Ssis sql ssrs_sp_ssas_mdx_hb_li
 
Multidimensional expressions mdx - reference
Multidimensional expressions   mdx - referenceMultidimensional expressions   mdx - reference
Multidimensional expressions mdx - reference
 
Mdx university dubai courses
Mdx university dubai coursesMdx university dubai courses
Mdx university dubai courses
 
SQL Server Analysis Services and MDX
SQL Server Analysis Services and MDXSQL Server Analysis Services and MDX
SQL Server Analysis Services and MDX
 
Mdx complex-queries-130019
Mdx complex-queries-130019Mdx complex-queries-130019
Mdx complex-queries-130019
 
Enhancing Dashboard Visuals with Multi-Dimensional Expressions (MDX)
Enhancing Dashboard Visuals with Multi-Dimensional Expressions (MDX)Enhancing Dashboard Visuals with Multi-Dimensional Expressions (MDX)
Enhancing Dashboard Visuals with Multi-Dimensional Expressions (MDX)
 
2012 Acura MDX Brochure | DCH Acura of Temecula
2012 Acura MDX Brochure | DCH Acura of Temecula2012 Acura MDX Brochure | DCH Acura of Temecula
2012 Acura MDX Brochure | DCH Acura of Temecula
 
Citrix MDX Technologies Feature Brief
Citrix MDX Technologies Feature BriefCitrix MDX Technologies Feature Brief
Citrix MDX Technologies Feature Brief
 
MDX 2015-2019 Work Program Overview presentation, October 22, 2014
MDX 2015-2019 Work Program Overview presentation, October 22, 2014MDX 2015-2019 Work Program Overview presentation, October 22, 2014
MDX 2015-2019 Work Program Overview presentation, October 22, 2014
 
IBM Cognos Dimensional Dashboarding Techniques
IBM Cognos Dimensional Dashboarding TechniquesIBM Cognos Dimensional Dashboarding Techniques
IBM Cognos Dimensional Dashboarding Techniques
 
rmoore.smartquery KScope15
rmoore.smartquery KScope15rmoore.smartquery KScope15
rmoore.smartquery KScope15
 
Moore Advanced Calculations in Calc Manager OW 20151015
Moore Advanced Calculations in Calc Manager  OW 20151015Moore Advanced Calculations in Calc Manager  OW 20151015
Moore Advanced Calculations in Calc Manager OW 20151015
 
Ssis sql ssrs_ssas_sp_mdx_hb_li
Ssis sql ssrs_ssas_sp_mdx_hb_liSsis sql ssrs_ssas_sp_mdx_hb_li
Ssis sql ssrs_ssas_sp_mdx_hb_li
 
Tutorial olap4j
Tutorial olap4jTutorial olap4j
Tutorial olap4j
 
SSRS for DBA's
SSRS for DBA'sSSRS for DBA's
SSRS for DBA's
 
Big Data MDX with Mondrian and Apache Kylin
Big Data MDX with Mondrian and Apache KylinBig Data MDX with Mondrian and Apache Kylin
Big Data MDX with Mondrian and Apache Kylin
 
Essbase Calculations A Visual Approach KScope 2010
Essbase Calculations A Visual Approach KScope 2010Essbase Calculations A Visual Approach KScope 2010
Essbase Calculations A Visual Approach KScope 2010
 
SSAS and MDX
SSAS and MDXSSAS and MDX
SSAS and MDX
 

Similaire à What All Microsoft BI Developers Need to Know About MDX

R graphics260809
R graphics260809R graphics260809
R graphics260809lizbethfdz
 
3D Design with OpenSCAD
3D Design with OpenSCAD3D Design with OpenSCAD
3D Design with OpenSCADVickyTGAW
 
Python simplecv
Python simplecvPython simplecv
Python simplecvUFPA
 
Oracle SQL Model Clause
Oracle SQL Model ClauseOracle SQL Model Clause
Oracle SQL Model ClauseScott Wesley
 
3D_AutoCAD.pdf
3D_AutoCAD.pdf3D_AutoCAD.pdf
3D_AutoCAD.pdfazliana33k
 
AutoCAD - 3D Notes
AutoCAD - 3D NotesAutoCAD - 3D Notes
AutoCAD - 3D NotesVj NiroSh
 
Calculation Groups - color 1 slide per page.pdf
Calculation Groups - color 1 slide per page.pdfCalculation Groups - color 1 slide per page.pdf
Calculation Groups - color 1 slide per page.pdfPBIMINERADC
 
DMDW Lesson 02 - Basics with Adventure Works
DMDW Lesson 02 - Basics with Adventure WorksDMDW Lesson 02 - Basics with Adventure Works
DMDW Lesson 02 - Basics with Adventure WorksJohannes Hoppe
 
The art of querying – newest and advanced SQL techniques
The art of querying – newest and advanced SQL techniquesThe art of querying – newest and advanced SQL techniques
The art of querying – newest and advanced SQL techniquesZohar Elkayam
 
Oracle Database Advanced Querying
Oracle Database Advanced QueryingOracle Database Advanced Querying
Oracle Database Advanced QueryingZohar Elkayam
 
Oracle Database Advanced Querying (2016)
Oracle Database Advanced Querying (2016)Oracle Database Advanced Querying (2016)
Oracle Database Advanced Querying (2016)Zohar Elkayam
 
With big data comes big responsibility
With big data comes big responsibilityWith big data comes big responsibility
With big data comes big responsibilityERPScan
 

Similaire à What All Microsoft BI Developers Need to Know About MDX (20)

Einführung in mdx
Einführung in mdxEinführung in mdx
Einführung in mdx
 
Mdx basics
Mdx basicsMdx basics
Mdx basics
 
R graphics260809
R graphics260809R graphics260809
R graphics260809
 
3D Design with OpenSCAD
3D Design with OpenSCAD3D Design with OpenSCAD
3D Design with OpenSCAD
 
Python simplecv
Python simplecvPython simplecv
Python simplecv
 
Oracle SQL Model Clause
Oracle SQL Model ClauseOracle SQL Model Clause
Oracle SQL Model Clause
 
340project Final
340project Final340project Final
340project Final
 
3 d autocad
3 d autocad3 d autocad
3 d autocad
 
3D_AutoCAD.pdf
3D_AutoCAD.pdf3D_AutoCAD.pdf
3D_AutoCAD.pdf
 
3 d autocad
3 d autocad3 d autocad
3 d autocad
 
AutoCAD - 3D Notes
AutoCAD - 3D NotesAutoCAD - 3D Notes
AutoCAD - 3D Notes
 
TUTORIAL AUTO CAD 3D
TUTORIAL AUTO CAD 3DTUTORIAL AUTO CAD 3D
TUTORIAL AUTO CAD 3D
 
Calculation Groups - color 1 slide per page.pdf
Calculation Groups - color 1 slide per page.pdfCalculation Groups - color 1 slide per page.pdf
Calculation Groups - color 1 slide per page.pdf
 
DMDW Lesson 02 - Basics with Adventure Works
DMDW Lesson 02 - Basics with Adventure WorksDMDW Lesson 02 - Basics with Adventure Works
DMDW Lesson 02 - Basics with Adventure Works
 
The art of querying – newest and advanced SQL techniques
The art of querying – newest and advanced SQL techniquesThe art of querying – newest and advanced SQL techniques
The art of querying – newest and advanced SQL techniques
 
Oracle Database Advanced Querying
Oracle Database Advanced QueryingOracle Database Advanced Querying
Oracle Database Advanced Querying
 
VDC
VDC VDC
VDC
 
Oracle Database Advanced Querying (2016)
Oracle Database Advanced Querying (2016)Oracle Database Advanced Querying (2016)
Oracle Database Advanced Querying (2016)
 
It ready dw_day4_rev00
It ready dw_day4_rev00It ready dw_day4_rev00
It ready dw_day4_rev00
 
With big data comes big responsibility
With big data comes big responsibilityWith big data comes big responsibility
With big data comes big responsibility
 

Plus de Mark Ginnebaugh

Automating Microsoft Power BI Creations 2015
Automating Microsoft Power BI Creations 2015Automating Microsoft Power BI Creations 2015
Automating Microsoft Power BI Creations 2015Mark Ginnebaugh
 
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 Mark Ginnebaugh
 
Platfora - An Analytics Sandbox In A World Of Big Data
Platfora - An Analytics Sandbox In A World Of Big DataPlatfora - An Analytics Sandbox In A World Of Big Data
Platfora - An Analytics Sandbox In A World Of Big DataMark Ginnebaugh
 
Microsoft SQL Server Relational Databases and Primary Keys
Microsoft SQL Server Relational Databases and Primary KeysMicrosoft SQL Server Relational Databases and Primary Keys
Microsoft SQL Server Relational Databases and Primary KeysMark Ginnebaugh
 
DesignMind Microsoft Business Intelligence SQL Server
DesignMind Microsoft Business Intelligence SQL ServerDesignMind Microsoft Business Intelligence SQL Server
DesignMind Microsoft Business Intelligence SQL ServerMark Ginnebaugh
 
San Francisco Bay Area SQL Server July 2013 meetings
San Francisco Bay Area SQL Server July 2013 meetingsSan Francisco Bay Area SQL Server July 2013 meetings
San Francisco Bay Area SQL Server July 2013 meetingsMark Ginnebaugh
 
Silicon Valley SQL Server User Group June 2013
Silicon Valley SQL Server User Group June 2013Silicon Valley SQL Server User Group June 2013
Silicon Valley SQL Server User Group June 2013Mark Ginnebaugh
 
Microsoft SQL Server Continuous Integration
Microsoft SQL Server Continuous IntegrationMicrosoft SQL Server Continuous Integration
Microsoft SQL Server Continuous IntegrationMark Ginnebaugh
 
Hortonworks Big Data & Hadoop
Hortonworks Big Data & HadoopHortonworks Big Data & Hadoop
Hortonworks Big Data & HadoopMark Ginnebaugh
 
Microsoft SQL Server Physical Join Operators
Microsoft SQL Server Physical Join OperatorsMicrosoft SQL Server Physical Join Operators
Microsoft SQL Server Physical Join OperatorsMark Ginnebaugh
 
Microsoft PowerPivot & Power View in Excel 2013
Microsoft PowerPivot & Power View in Excel 2013Microsoft PowerPivot & Power View in Excel 2013
Microsoft PowerPivot & Power View in Excel 2013Mark Ginnebaugh
 
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball Approach
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball ApproachMicrosoft Data Warehouse Business Intelligence Lifecycle - The Kimball Approach
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball ApproachMark Ginnebaugh
 
Fusion-io Memory Flash for Microsoft SQL Server 2012
Fusion-io Memory Flash for Microsoft SQL Server 2012Fusion-io Memory Flash for Microsoft SQL Server 2012
Fusion-io Memory Flash for Microsoft SQL Server 2012Mark Ginnebaugh
 
Microsoft Data Mining 2012
Microsoft Data Mining 2012Microsoft Data Mining 2012
Microsoft Data Mining 2012Mark Ginnebaugh
 
Microsoft SQL Server PASS News August 2012
Microsoft SQL Server PASS News August 2012Microsoft SQL Server PASS News August 2012
Microsoft SQL Server PASS News August 2012Mark Ginnebaugh
 
Business Intelligence Dashboard Design Best Practices
Business Intelligence Dashboard Design Best PracticesBusiness Intelligence Dashboard Design Best Practices
Business Intelligence Dashboard Design Best PracticesMark Ginnebaugh
 
Microsoft Mobile Business Intelligence
Microsoft Mobile Business Intelligence Microsoft Mobile Business Intelligence
Microsoft Mobile Business Intelligence Mark Ginnebaugh
 
Microsoft SQL Server 2012 Cloud Ready
Microsoft SQL Server 2012 Cloud ReadyMicrosoft SQL Server 2012 Cloud Ready
Microsoft SQL Server 2012 Cloud ReadyMark Ginnebaugh
 
Microsoft SQL Server 2012 Master Data Services
Microsoft SQL Server 2012 Master Data ServicesMicrosoft SQL Server 2012 Master Data Services
Microsoft SQL Server 2012 Master Data ServicesMark Ginnebaugh
 
Microsoft SQL Server PowerPivot
Microsoft SQL Server PowerPivotMicrosoft SQL Server PowerPivot
Microsoft SQL Server PowerPivotMark Ginnebaugh
 

Plus de Mark Ginnebaugh (20)

Automating Microsoft Power BI Creations 2015
Automating Microsoft Power BI Creations 2015Automating Microsoft Power BI Creations 2015
Automating Microsoft Power BI Creations 2015
 
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
 
Platfora - An Analytics Sandbox In A World Of Big Data
Platfora - An Analytics Sandbox In A World Of Big DataPlatfora - An Analytics Sandbox In A World Of Big Data
Platfora - An Analytics Sandbox In A World Of Big Data
 
Microsoft SQL Server Relational Databases and Primary Keys
Microsoft SQL Server Relational Databases and Primary KeysMicrosoft SQL Server Relational Databases and Primary Keys
Microsoft SQL Server Relational Databases and Primary Keys
 
DesignMind Microsoft Business Intelligence SQL Server
DesignMind Microsoft Business Intelligence SQL ServerDesignMind Microsoft Business Intelligence SQL Server
DesignMind Microsoft Business Intelligence SQL Server
 
San Francisco Bay Area SQL Server July 2013 meetings
San Francisco Bay Area SQL Server July 2013 meetingsSan Francisco Bay Area SQL Server July 2013 meetings
San Francisco Bay Area SQL Server July 2013 meetings
 
Silicon Valley SQL Server User Group June 2013
Silicon Valley SQL Server User Group June 2013Silicon Valley SQL Server User Group June 2013
Silicon Valley SQL Server User Group June 2013
 
Microsoft SQL Server Continuous Integration
Microsoft SQL Server Continuous IntegrationMicrosoft SQL Server Continuous Integration
Microsoft SQL Server Continuous Integration
 
Hortonworks Big Data & Hadoop
Hortonworks Big Data & HadoopHortonworks Big Data & Hadoop
Hortonworks Big Data & Hadoop
 
Microsoft SQL Server Physical Join Operators
Microsoft SQL Server Physical Join OperatorsMicrosoft SQL Server Physical Join Operators
Microsoft SQL Server Physical Join Operators
 
Microsoft PowerPivot & Power View in Excel 2013
Microsoft PowerPivot & Power View in Excel 2013Microsoft PowerPivot & Power View in Excel 2013
Microsoft PowerPivot & Power View in Excel 2013
 
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball Approach
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball ApproachMicrosoft Data Warehouse Business Intelligence Lifecycle - The Kimball Approach
Microsoft Data Warehouse Business Intelligence Lifecycle - The Kimball Approach
 
Fusion-io Memory Flash for Microsoft SQL Server 2012
Fusion-io Memory Flash for Microsoft SQL Server 2012Fusion-io Memory Flash for Microsoft SQL Server 2012
Fusion-io Memory Flash for Microsoft SQL Server 2012
 
Microsoft Data Mining 2012
Microsoft Data Mining 2012Microsoft Data Mining 2012
Microsoft Data Mining 2012
 
Microsoft SQL Server PASS News August 2012
Microsoft SQL Server PASS News August 2012Microsoft SQL Server PASS News August 2012
Microsoft SQL Server PASS News August 2012
 
Business Intelligence Dashboard Design Best Practices
Business Intelligence Dashboard Design Best PracticesBusiness Intelligence Dashboard Design Best Practices
Business Intelligence Dashboard Design Best Practices
 
Microsoft Mobile Business Intelligence
Microsoft Mobile Business Intelligence Microsoft Mobile Business Intelligence
Microsoft Mobile Business Intelligence
 
Microsoft SQL Server 2012 Cloud Ready
Microsoft SQL Server 2012 Cloud ReadyMicrosoft SQL Server 2012 Cloud Ready
Microsoft SQL Server 2012 Cloud Ready
 
Microsoft SQL Server 2012 Master Data Services
Microsoft SQL Server 2012 Master Data ServicesMicrosoft SQL Server 2012 Master Data Services
Microsoft SQL Server 2012 Master Data Services
 
Microsoft SQL Server PowerPivot
Microsoft SQL Server PowerPivotMicrosoft SQL Server PowerPivot
Microsoft SQL Server PowerPivot
 

Dernier

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingSelcen Ozturkcan
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 

Dernier (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 

What All Microsoft BI Developers Need to Know About MDX

  • 1. What All Microsoft BI Developers Need to Know About MDX Speaker: Nathan Peterson Solid Quality Mentors Silicon Valley SQL Server User Group January 19, 2009 Mark Ginnebaugh, User Group Leader, mark@designmind.com
  • 2. Nathan Peterson Solid Quality Mentors Currently working on an Analysis Services project for the US Army Lead developer of a local cube generating utility called CubeSlice
  • 3. What do all developers need to know about MDX? You should be able to: Create and debug Calculated Members. Create and debug Named Sets. What you need to know to accomplish this: Understand MDX Concepts. Learn MDX Syntax. Learn some MDX functions. Learn some practical applications of MDX.
  • 4. What Is MDX? Multi-Dimensional eXpressions SQL is used for relational queries, while MDX is used for multidimensional queries. Calculated members allow you to incorporate multidimensional logic into your cube. Named sets allow you to pre-define dynamic groups of members to be displayed on columns or rows.
  • 5. Sample calculated member with member measures.[Last Year Sales Amount] as ( measures.[Sales Amount], ParallelPeriod ( [Date].[Calendar].[Calendar Year], 1, [Date].[Calendar].CurrentMember ) )
  • 6. Sample named set with set [Top 5 Products] as topcount ( [Product].[Product].Members, 5, Measures.[Internet Sales Amount] )
  • 7. Comparing MDX to SQL From SQL selects from a table. MDX selects from a cube. Dimensionality SQL returns one or more columns and 0 or more rows. MDX can return data for 0, 1, 2, 3 or more axes. Where SQL has a filter. MDX has a slicer.
  • 8. MDX query with two axes and two slicers select Measures.AllMembers on columns, [Date].[Calendar].&[2003].Children on rows from [Adventure Works] where ( [Customer].[Customer Geography].[France], [Product].[Product Categories].[Bikes] )
  • 10. Same query, using axis numbers instead of axis names select Measures.AllMembers on 0, [Date].[Calendar].&[2003].Children on 1 from [Adventure Works] where ( [Customer].[Customer Geography].[France], [Product].[Product Categories].[Bikes] )
  • 11. Using MDX requires multidimensional thinking In a cube Dimensions have hierarchies Hierarchies have levels Levels have members In a cellset Each axis contains a set Each set consists of a group of members or a group of tuples Tuples have members from different hierarchies
  • 12. Multidimensional thinking – Where are you? Every member is in a level. Every level is in a hierarchy. Every hierarchy is a part of a dimension. For every cell of the cellset, there’s (almost) always a Current Member for each hierarchy. The Current Member may be set from the column, the row, the slicer, or the default member.
  • 13. Create a set by listing members The simplest set is a list of members. The boundaries of the set are indicated with curly braces {}. select { [Product].[Category].[All Products], [Product].[Category].[Accessories], [Product].[Category].[Bikes], [Product].[Category].[Clothing], [Product].[Category].[Components] } on 0 from [Adventure Works]
  • 14. Create a set with a function There are many MDX functions that create sets. This query uses the .Members function to return all the members from a hierarchy – and gives the same result as the previous query. You don’t have to use {} when you create a set with a function. select [Product].[Category].Members on 0 from [Adventure Works]
  • 15. Tuples Each cell in a cellset shows data for one particular member from each hierarchy. A tuple is a way of specifying which member should be used from each of the hierarchies. Tuples are written like points in a geometric grid: (6,3) identifies point 6 on the x-axis and point 3 on the y-axis. ([2009],[US],[Bikes],[Internet Sales Amount]) identifies Internet Sales for Bikes in the US in 2009.
  • 16. 2 Dimensional Tuple 6 5 2 Dimensional Tuple 4 3 2 (6, 2) 1 1 2 3 4 5 6 7 8
  • 17. Create a set by listing tuples select { ( [Date].[Calendar Year].&[2002], [Product].[Category].[Accessories] ), ( [Date].[Calendar Year].&[2002], [Product].[Category].[Bikes] ), ( [Date].[Calendar Year].&[2003], [Product].[Category].[Accessories] ), ( [Date].[Calendar Year].&[2003], [Product].[Category].[Bikes] ) } on 0 from [Adventure Works]
  • 18. Listing Tuples [Accessories] [Clothing] 2 Dimensional Tuple [Touring Bikes] [Road Bikes] ([2006], [Mountain Bikes]) [Mountain Bikes] [All Products] 2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8
  • 19. Create a set of tuples by multiplying two sets of members select { [Date].[Calendar Year].&[2002], [Date].[Calendar Year].&[2003] } * { [Product].[Category].[Accessories], [Product].[Category].[Bikes] } on 0 from [Adventure Works]
  • 20. 3 Dimensional Tuple [Accessories] [Clothing] 3 Dimensional Tuple Difficult to Show in 3 Axes – [Touring Bikes] Where to place the point? [Road Bikes] ([2006], [Mountain Bikes], [Red]) [Mountain Bikes] [All Products] [Red] [Blue] 2 2 2 2 2 2 2 2 [Pink] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8
  • 21. 3 Dimensional Tuple Combining 2 Hierarchies on 1 Axis ([Blue], [Road Bikes]) ([Red], [Road Bikes]) 3 Dimensional Tuple ([Blue], [Mountain Bikes]) ([Red], [Mountain Bikes]) ([Blue], [All Products]) ([2006], [Mountain Bikes], [Red]) ([Red], [All Products]) 2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8
  • 22. The Where clause The Where clause is an optional part of an MDX query. The Where clause is a slicer, not a filter. You can’t use the Where clause for limiting the value to a threshold (Sales over $10,000). Use the Filter function for filtering. The Where clause often looks like a tuple and actually is a tuple – but it doesn’t have to be.
  • 23. Where clause using a tuple – one member from each referenced hierarchy select Measures.[Internet Sales Amount] on 0 from [Adventure Works] where ( [Customer].[Customer Geography].[France], [Product].[Product Categories].[Bikes] )
  • 24. Where clause with slicing on multiple members from one hierarchy select Measures.[Internet Sales Amount] on 0 from [Adventure Works] where ( [Customer].[Customer Geography].[France], { [Product].[Product Categories].[Bikes], [Product].[Product Categories].[Clothing] } )
  • 25. The With clause The With clause is used for creating both calculated members and named sets. These calculated members and named sets are only valid for the life of the query. You can also create calculated members and named sets that are persistent: Lasting for the life of a session. Created permanently in the cube.
  • 26. Creating calculated member in the With clause with member Measures.[Average Internet Sales] as [Measures].[Internet Sales Amount] / [Measures].[Internet Order Count], format_string = "currency" select {Measures.[Average Internet Sales]} on 0 from [Adventure Works]
  • 27. Members, Sets, Tuples ([Blue], [Road Bikes]) ([Red], [Road Bikes]) Members, Sets, Tuples ([Blue], [Mountain Bikes]) Set of (Partial) ([Red], [Mountain Bikes]) Tuples ([Blue], [All Products]) ([2006], [Mountain Bikes], [Red]) ([Red], [All Products]) (Partial) Tuple Member 2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8 Set of Members
  • 28. Creating named set in the With clause with set [Products - High Selling on Internet] as filter ( [Product].[Product].[Product].Members, [Measures].[Internet Sales Amount] > 50000 ) select {Measures.[Internet Sales Amount]} on 0, [Products - High Selling on Internet] on 1 from [Adventure Works]
  • 29. Full Tuple ([Blue], [Road Bikes]) ([2006], [Mountain Bikes], [Red], [All ([Red], [Road Bikes]) Promotions], [All Gender], [Measures].[Reseller Sales Amount], ([Blue], [Mountain Bikes]) etc…) ([Red], [Mountain Bikes]) ([Blue], [All Products]) ([Red], [All Products]) 2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 7 8
  • 30. MDX Punctuation Use {} for sets. Use () for tuples. Use [] for names of cubes, dimensions, hierarchies, levels, and members. Use commas all over the place (except not between multiple calculated members or named sets defined in the same query).
  • 31. Where to write your MDX In a client application like PerformancePoint, which allows you to write code for calculated measures and sets. In a query editor like the SQL Server Management Studio. In the MDX Script of a cube. TIP: It’s often easier to write the code in a query editor first and then put it into the MDX Script.
  • 32. Writing MDX for a KPI You can write MDX to create the values for a KPI, whether you’re working with Analysis Services KPIs or PerformancePoint Services KPIs. For both tools, it’s easier to create calculated members in the MDX script for the values first. TIP: When building KPIs in the BIDS, use a template for assigning the Status and the Trend.
  • 33. Functions – Navigating within a level PrevMember NextMember Lag() Lead()
  • 34. Examples of navigating in a level Navigation functions are often used with Dates. Note: PrevMember, Lag(1), and Lead(-1) all return the same member. [1997].PrevMember [1996] [March 2010].NextMember [April 2010] [10 April 2009].Lag(2) [8 April 2009] [December 2009].Lead(12) [December 2010]
  • 35. Functions – All in the Family Parent Children, FirstChild, LastChild Descendants Ancestor, Ascendants Siblings, FirstSibling, LastSibling Cousin
  • 36. Examples of family functions Some of the family functions return individual members, while other return sets. If a function returns an individual member, you can use another function with it. [Mar 1997].Parent [1997] [Q1 2009].Children [Jan 09]:[Mar 09] [2009].FirstChild [Q1 2009] Descendants([2009], 2) [Jan 09]:[Dec 09] Descendants([2009],[Date])[1Jan09]:[31Dec09] Ancestor([Mar 2008], 3) [2008] FirstSibling([Mar 2007]) [Jan 2007]
  • 37. Functions – Multiplying, adding, subtracting, intersecting sets Set multiplication, addition, and subtractions can be indicated with mathematical symbols or with functions. Multiplication * Crossjoin Addition + Union Subtraction - Except Intersection Intersect
  • 38. Example of set multiplication These two sets are equivalent. [Date].[Fiscal].[Month].members * [Product].[Product].members Crossjoin ( [Date].[Fiscal].[Month].members, [Product].[Product].members )
  • 39. Practical Applications of MDX Comparing with a previous time period. Comparing with the same time period in the previous year. Year-To-Date. Rolling Average. Percent contribution.
  • 40. Comparing with a previous time period with member Measures.[Last Month Sales] as ( Measures.[Internet Sales Amount], [Date].[Calendar].PrevMember ) select { Measures.[Internet Sales Amount], Measures.[Last Month Sales] } on 0, [Date].[Calendar].[Month].members on 1 from [Adventure Works]
  • 41. Comparing with the same period in the previous year with member measures.[Last Year Sales Amount] as ( measures.[Sales Amount], ParallelPeriod ( [Date].[Calendar].[Calendar Year], 1, [Date].[Calendar].CurrentMember ) )
  • 42. Year-To- Year-To-Date with member measures.[YTD Sales] as sum ( ytd([Date].[Calendar].CurrentMember), Measures.[Internet Sales Amount] ) select { Measures.[Internet Sales Amount], Measures.[YTD Sales] } on 0, [Date].[Calendar].[Month].members on 1 from [Adventure Works]
  • 43. Rolling Average With member measures.[Previous 6 Month Rolling AVG] as sum ( [Date].[Calendar].lag(6): [Date].[Calendar].lag(1), Measures.[Internet Sales Amount] ) / 6 select { Measures.[Internet Sales Amount], Measures.[Previous 6 Month Rolling AVG] } on 0, [Date].[Calendar].[Month].members on 1 from [Adventure Works]
  • 44. Percent Contribution With member Measures.[Percent of Parent Sales] as Measures.[Internet Sales Amount] / ( Measures.[Internet Sales Amount], [Product].[Product Categories].Parent ) select { Measures.[Internet Sales Amount], Measures.[Percent of Parent Sales] } on 0, [Product].[Product Categories]. members on 1 from [Adventure Works]
  • 45. Additional topics – if there’s time Dealing with exceptions String manipulation Generate Recursion
  • 46. Dealing with exceptions A calculation needs to be valid everywhere with member [Measures].[% Change # of Customers] as case when [Date].[Fiscal].CurrentMember.Level.Ordinal = 0 then "NA” when [Date].[Fiscal].CurrentMember.Level.Ordinal = 5 then Null when isempty ( ([Date].[Fiscal].CurrentMember.PrevMember, [Measures].[Customer Count]) ) then null else ( ([Date].[Fiscal].CurrentMember, [Measures].[Customer Count]) - ([Date].[Fiscal].PrevMember, [Measures].[Customer Count]) ) / ([Date].[Fiscal].PrevMember,[Measures].[Customer Count]) end
  • 47. Functions - String manipulation Turning the current date into a member reference Strtomember ( "[Date].[Fiscal].[Date].&[" + cstr(year(now()) - 6) + right("0" + cstr(month(now())), 2) + right("0" + cstr(day(now())), 2) + "]" )
  • 48. The Generate function What are the five top products most purchased by people living in my top five cities? generate ( topcount ( [Customer].[Customer Geography].[City].members, 5, [Measures].[Internet Sales Amount] ), crossjoin ( [Customer].[Customer Geography].CurrentMember, topcount ( [Product].[Product].[Product].members, 5, [Measures].[Internet Sales Amount] ) ) )
  • 49. Recursion Finding the most recent purchase with member measures.[Most Recent Purchase] as iif ( [Measures].[Internet Sales Amount] > 0, [Measures].[Internet Sales Amount], [Date].[Calendar].PrevMember )
  • 51. To learn more or inquire about speaking opportunities, please contact: Mark Ginnebaugh, User Group Leader mark@designmind.com