The Basic MDX Script (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).
A Multidimensional Expressions (MDX) script defines the calculation process for a cube in Microsoft SQL Server Analysis Services. There are two types of MDX scripts:
The default MDX script that Analysis Services creates when you define a cube contains a single CALCULATE statement. This single CALCULATE statement is at the beginning of the default MDX script, and indicates that the entire cube should be calculated during the first calculation pass.
The default MDX script also contains the script commands that create named sets, assignments, and calculated members created in Cube Designer:
Analysis Services directly adds script commands to the default MDX script.
For each named set in the cube, a corresponding CREATE SET statement exists in the default MDX script.
For each calculated member defined in the cube, a corresponding CREATE MEMBER statement exists in the default MDX script.
You can control the order of script commands, named sets, and calculated members in the default MDX script by using the Calculations tab of Cube Designer. For more information on defining calculations stored in the default MDX script, see Calculations in Multidimensional Models.
If there is no MDX script associated with a cube, the cube assumes the default MDX script. A cube needs to be associated with at least one MDX script because a cube relies on the MDX script to determine calculation behavior. In other words, a cube that was not associated with an MDX script or was associated with an empty MDX script could not and would not be able to calculate any cells. If you programmatically create cubes, either by using Analysis Services Scripting Language (ASSL) commands or by using Analysis Management Objects (AMO), it is recommended that you create a default MDX script containing a single CALCULATE statement for the cube.