Friday, 2 August 2013

Filtering Data in MDX Query

We can filter data in MDX by using Slicer Axis or Using Filter Function.

Filtering data using Slicer Axis (Where Clause)

  Query 1: Query to get "Reseller Order Count" for "United Kingdom".

    SELECT
            [Measures].[Reseller Order Count] ON COLUMNS
    FROM [Adventure Works]
    WHERE [Geography].[Geography].[Country].&[United Kingdom]


 
Filtering Data using Filter Function

     Syntax: FILTER( «Set», «Search Condition» )
  • Filter function is very useful in situation where we have already used  a Hierarcy on some axes.

   Query 2: Query to get "Reseller Order Count" for all countries where "Reseller Order Count" > 100

     SELECT
        FILTER
             (
                 (
                     [Geography].[Geography].[Country]
                     ,[Measures].[Reseller Order Count]
                 )
                 , [Measures].[Reseller Order Count] > 100
             )ON COLUMNS
      FROM [Adventure Works];



No comments:

Post a Comment