MDX Built-in Functions - Dimension Functions

From SQLServerPedia

Jump to: navigation, search

See Also: Main_Page - Database Administration - Analysis Services - MDX with Analysis Services - MDX Built-In Functions

Dimension Functions allow retrieval of dimension, hierarchy and level metadata.

Contents

Dimension

Dimension function returns the dimension that contains the specified member, hierarchy or level. Syntax is hierarchy.dimension, member.dimension, or level.dimension. For example, "[cy 2001].dimension" would return date dimension.

Dimensions

Dimensions function returns a hierarchy that is identified by the specified number or string. The syntax is Dimensions(number OR string). For example, the following returns product categories' hierarchy because that is the parent hierarchy of [category] level:

SELECT  dimensions('category') ON COLUMNS  FROM [adventure works]

The following retrieves customers dimension:

SELECT  dimensions('country') ON COLUMNS  FROM [adventure works]

Measures dimension is identified by number zero.

Hierarchy

Hierarchy returns the hierarchy to which the specified member or level belongs. The syntax is member.hierarchy or level.hierarchy. For example, the following returns customers' hierarchy:

SELECT  country.hierarchy ON COLUMNS  FROM [adventure works]

Level

Level returns the level of a given member. The syntax is member.level. For example, the following returns "category" level:

SELECT  [bikes].level ON COLUMNS  FROM [adventure works]

Levels

Levels function returns the level specified by the string or number. The syntax is dimension.hierarchy.Levels(string or number). The number argument is zero based identifier for the level. For example, [date].[calendar].levels(3) will return quarters. The string argument is the level name, for example [date].[calendar].levels('month') will return months.