Wednesday, 20 November 2013

Filters in MDX

We can filter data in MDX using following ways.

  •  By using Filter Function.
    • Used for filtering data based on numeric expression.
                      SELECT [Measures].[Internet Sales Amount] ON 0,
                      FILTER(
                                      [Date].[Date].[Date].MEMBERS
                                    , [Measures].[Internet Sales Amount]>10000
                                  ) ON 1
                      FROM [Adventure Works] 


  • By using Slicer Axis
    • This method can be used only if dimension on which we are trying to filer data is not already used on any other axis.
                    SELECT [Measures].[Internet Sales Amount] ON 0
                   , FILTER(
                                   [Date].[Date].[Date].MEMBERS
                                 , [Measures].[Internet Sales Amount] > 10000
                                 ) ON 1
                     FROM [Adventure Works]
                     WHERE [Geography].[City].&[Atlanta]&[GA]

  • By means of Sub Query 
    • This method of filtering data is particularly useful, when we have to filter data based on a dimension which is already used on any one of the axis other then slicer axis.

                    SELECT [Measures].[Internet Sales Amount] ON 0
                   , FILTER(
                             [Date].[Date].[Date].MEMBERS
                           , [Measures].[Internet Sales Amount] > 10000
                     ) ON 1
                    FROM
                    (
                        SELECT {[Geography].[City].&[Atlanta]&[GA]} ON 0
                        FROM [Adventure Works]
                    )

No comments:

Post a Comment