Applies To: SQL Server 2016
The calculation context is the known subspace of the cube where an expression is evaluated and all coordinates are either explicitly known or can be derived from the expression.
Every set, member, tuple, or numeric function executes in the context of the entire MDX expression or statement. When an argument, such as a tuple, is passed to a function, only some of the coordinates in the cube space are explicitly provided. The other coordinates are obtained based on the current calculation context.
The calculation context for unspecified cell coordinates and attribute members is determined in the following order:
The FROM clause (if applicable) - this clause can either specify an entire cube or can specify a subcube in the form of a SELECT statement.
The WHERE clause (if applicable) - this clause, which is also known as the slicer axis, on which you specify a set, tuple, or member that restricts the members returned on the column and row axis by a query. Conceptually, the default member of every attribute hierarchy that is not explicitly specified on column or row axis is part of the slicer axis.
When cell coordinates for a particular attribute are specified on both the slicer axis and on another axis, the coordinates specified in the function may take precedence in determining the members of the set on the axis. The Filter (MDX) and Order (MDX) functions are examples of such functions - you can filter or order a result by attribute members that are excluded from the calculation context by the WHERE clause, or by a SELECT statement in the FROM clause.
The named sets and calculated members defined in the query or expression.
The tuples and sets specified on the row and column axes, utilizing the default member for attributes that do not appear on the row, column, or slicer axis.
The cube or subcube cells on each axis, eliminating empty tuples on the axis and applying the HAVING clause.
For more information, see Establishing Cube Context in a Query (MDX).
In the following query, the calculation context for the row axis is restricted by the Country attribute member and the Calendar Year attribute member that are specified in the WHERE clause.
SELECT Customer.City.City.Members ON 0 FROM [Adventure Works] WHERE (Customer.Country.France, [Date].[Calendar].[Calendar Year].[CY 2004], Measures.[Internet Sales Amount])
However, if you modify this query by specifying the FILTER function on the row axis, and utilize a Calendar Year attribute hierarchy member in the FILTER function, then the attribute member from the Calendar Year attribute hierarchy that is used to provide the calculation context for the members of the set on the column axis can be modified.
SELECT FILTER ( Customer.City.City.Members, ([Date].[Calendar].[Calendar Year].[CY 2003], Measures.[Internet Order Quantity]) > 75 ) ON 0 FROM [Adventure Works] WHERE (Customer.Country.France, [Date].[Calendar].[Calendar Year].[CY 2004], Measures.[Internet Sales Amount])
In the previous query, the calculation context for the cells in the tuples that appear on the column axis is filtered by the CY 2003 member of the Calendar Year attribute hierarchy, even though the nominal calculation context for the Calendar Year attribute hierarchy is CY 2004. Furthermore, it is filtered by the Internet Order Quantity measure. However, once the members of the set on the column axis is set, the calculation context for the values for the members that appear on the axis is again determined by the WHERE clause.