Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SCOPE Statement (MDX)

Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).

Limits the scope of specified Multidimensional Expressions (MDX) statements to a specified subcube.

   [ MDX_Statement ]

Subcube_Expression ::=(Auxiliary_Subcube [, Auxiliary_Subcube,...n])

Auxiliary_Subcube ::= 
    | Root([dimension_name]) 
    | Leaves([dimension_name])

Limited_Set ::= 
    | member 
    | Common_Grain_Members 
    | hierarchy.members 
    | level.members 
    | {} 
    | Descendants
         , [level
            , SELF 
             | AFTER 
                          | BEFORE 
                          | SELF_AND_AFTER 
                          | SELF_AND_BEFORE 
                          | SELF_BEFORE_AFTER 
                          | LEAVES
[* <limited set>]


A valid MDX subcube expression.


A valid MDX statement.


A valid MDX statement that evaluates to members that have the same grain.


A single tuple.

The SCOPE statement determines the subcube that will be affected by the running of one or more MDX statements. Unless an MDX statement is framed within a SCOPE statement, the implicit scope of an MDX statement is the entire cube.

Note Note

Hidden members are exposed in SCOPE statements.

SCOPE statements will create subcubes that expose "holes" regardless of the MDX Compatibility setting. For example, the statement, Scope( Customer.State.members ), can include the states in countries or regions that do not contain states, but for which otherwise invisible placeholder members were inserted.

Calculated members and named sets created within a SCOPE statement are unaffected by the SCOPE statement.


The following example, from the MDX calculation script in the Adventure Works sample solution, defines the current scope as fiscal quarter in fiscal year 2005 and the sales amount quota measure, and then assigns a value to the cells in the current scope by using the ParallelPeriod function. The example then modifies the scope using another SCOPE statement, and then performs another assignment using the This (MDX) function.

    [Date].[Fiscal Year].&[2005],
    [Date].[Fiscal].[Fiscal Quarter].Members,
    [Measures].[Sales Amount Quota]
 ) ;   
   This = ParallelPeriod                             
             [Date].[Fiscal].[Fiscal Year], 1,
          ) * 1.35 ;

/*-- Allocate equally to months in FY 2002 -----------------------------*/

     [Date].[Fiscal Year].&[2002],
  ) ;   

    This = [Date].[Fiscal].CurrentMember.Parent / 3 ;   

  End Scope ;   
End Scope ;   
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft