MDX Function Reference (MDX)
In this article
Microsoft SQL Server 2005 Analysis Services (SSAS) provides for the use of functions in Multidimensional Expressions (MDX) syntax. Functions can be used in any valid MDX statement, and are frequently used in queries, custom rollup definitions, and other calculations. This section provides information about the MDX functions included with Analysis Services.
You can use the following tables to find functions by their category of return value, or you can select a function by name from the alphabetical list in the table of contents.
Array Functions
Function  Description 

Converts one or more sets to an array for use in a userdefined function. 
Hierarchy Functions
Function  Description 

Returns the hierarchy that contains a specified member or level. 

Returns the dimension that contains a specified member, level, or hierarchy. 

Returns a hierarchy specified by a numeric or string expression. 
Level Functions
Function  Description 

Returns the level of a member. 

Returns the level whose position in a dimension or hierarchy is specified by a numeric expression or whose name is specified by a string expression. 
Logical Functions
Function  Description 

Returns whether a specified member is an ancestor of another specified member. 

Returns whether the evaluated expression is the empty cell value. 

Returns whether a specified member is in a specified generation. 

Returns whether a specified member is a leaf member. 

Returns whether a specified member is a sibling of another specified member. 
Member Functions
Function  Description 

Returns the ancestor of a member at a specified level or distance. 

Returns the last sibling among the descendants of a member at a specified level. 

Returns the child member with the same relative position under a parent member as the specified child member. 

Returns the current member along a specified dimension or hierarchy during iteration. 

Returns the systemgenerated data member that is associated with a nonleaf member of a dimension. 

Returns the default member of a dimension or hierarchy. 

Returns the first child of a member. 

Returns the first child of the parent of a member. 

Returns a member from a specified tuple. 

Returns the member that is a specified number of positions before a specified member along the member's dimension. 

Returns the last child of a specified member. 

Returns the last child of the parent of a specified member. 

Returns the member that is a specified number of positions following a specified member along the member's dimension. 

Returns the member equivalent to a specified member in a specified hierarchy. 

Returns a member specified by a string expression. 

Returns the next member in the level that contains a specified member. 

Returns the first sibling among the descendants of a specified level, optionally at a specified member. 

Returns a member from a prior period in the same relative position as a specified member. 

Returns the parent of a member. 

Returns the previous member in the level that contains a specified member. 

Returns the member specified by an MDX–formatted string. 

Returns the unknown member associated with a level or member. 

Returns a valid measure in a virtual cube by forcing inapplicable dimensions to their top level. 
Numeric Functions
Function  Description 

Returns a scalar value calculated by aggregating either measures or an optionally specified numeric expression over the tuples of a specified set. 

Returns the average value of measures or the average value of an optional numeric expression, evaluated over a specified set. 

Returns the current calculation pass of a cube for the specified query context. 

Returns the value of a MDX expression evaluated over the specified calculation pass of a cube. 

Coalesces an empty cell value to a number or string and returns the coalesced value. 

Returns the correlation coefficient of two series evaluated over a set. 

Returns the number of dimensions in a cube. 

Returns the number of levels in a dimension or hierarchy. 

Returns the number of cells in a set. 

Returns the number of dimensions in a tuple. 

Returns the population covariance of two series evaluated over a set, using the biased population formula. 

Returns the sample covariance of two series evaluated over a set, using the unbiased population formula. 

Returns the number of distinct, nonempty tuples in a set. 

Returns one of two values determined by a logical test. 

Calculates the linear regression of a set and returns the value of the intercept in the regression line, y = ax + b. 

Calculates the linear regression of a set and returns the value of y in the regression line, y = ax + b. 

Calculates the linear regression of a set and returns the coefficient of determination, R2. 

Calculates the linear regression of a set, and returns the value of the slope in the regression line, y = ax + b. 

Calculates the linear regression of a set, and returns the variance associated with the regression line, y = ax + b. 

Returns the value of an MDX expression evaluated over another specified cube in the same database. 

Returns the maximum value of a numeric expression that is evaluated over a set. 

Returns the median value of a numeric expression that is evaluated over a set. 

Returns the minimum value of a numeric expression that is evaluated over a set. 

Returns the zerobased ordinal value associated with a level. 

Returns a value of a numeric expression evaluated over a data mining model. 

Returns the onebased rank of a specified tuple in a specified set. 

Returns a value generated by rolling up the values of the children of a specified member using the specified unary operator. 

Alias for Stdev (MDX). 

Alias for StdevP (MDX). 

Returns the sample standard deviation of a numeric expression evaluated over a set, using the unbiased population formula. 

Returns the population standard deviation of a numeric expression evaluated over a set, using the biased population formula. 

Returns the value specified by an MDX–formatted string. 

Returns the sum of a numeric expression evaluated over a set. 

Returns the value of a measure. 

Returns the sample variance of a numeric expression evaluated over a set, using the unbiased population formula. 

Alias for Var (MDX). 

Alias for VarP (MDX). 

Returns the population variance of a numeric expression evaluated over a set, using the biased population formula. 
Set Functions
Function  Description 

Returns a set generated by adding calculated members to a specified set. 

Returns a set that contains all members, including calculated members, of the specified dimension, hierarchy, or level. 

Returns a set of all ancestors of a member at a specified level or distance. 

Returns the set of the ascendants of a specified member, including the member itself. 

Returns a set defined in an axis. 

Sorts a set in ascending order, and returns the specified number of tuples with the lowest values. 

Sorts a set in ascending order, and returns a set of tuples with the lowest values whose cumulative total is equal to or less than a specified percentage. 

Sorts a set in ascending order, and returns a set of tuples with the lowest values whose total is equal to or less than a specified value. 

Returns the children of a specified member. 

Returns the cross product of one or more sets. 

Returns the current iteration number within a set during iteration. 

Returns the set of descendants of a member at a specified level or distance, optionally including or excluding descendants in other levels. 

Returns a set, removing duplicate tuples from a specified set. 

Drills down the members of a set to one level below the lowest level represented in the set, or to one level below an optionally specified level of a member represented in the set. 

Drills down the bottommost members of a set, at a specified level, to one level below. 

Drills down the topmost members of a set, at a specified level, to one level below. 

Drills down the members in a specified set that are present in a second specified set. Alternatively, the function drills down on a set of tuples. 

Drills down the members in a specified set that are present in a second specified set, limiting the result set to a specified number of members. Alternatively, this function also drills down on a set of tuples. 

Drills down the members in a specified set that are present in a second specified set, limiting the result set to a specified number of members. Alternatively, this function drills down on a set of tuples. 

Drills up the members of a set that are below a specified level. 

Drills up the members in a specified set that are present in a second specified set. 

Finds the difference between two sets, optionally retaining duplicates. 

Returns the set of members of one set that exist with one or more tuples of one or more other sets. 

Returns a set of tuples from extracted dimension elements. 

Returns the set that results from filtering a specified set based on a search condition. 

Applies a set to each member of another set, and then joins the resulting sets by union. Alternatively, this function returns a concatenated string created by evaluating a string expression over a set. 

Returns the first specified number of elements in a set, while retaining duplicates. 

Orders the members of a set in a hierarchy. 

Returns the intersection of two input sets, optionally retaining duplicates. 

Returns a set of members up to and including a specified member. 

Returns the set of members in a dimension, level, or hierarchy. 

Returns a set of sibling members from the same level as a given member, starting with the first sibling and ending with the given member, as constrained by the Year level in the Time dimension. 

Returns a set that contains the member specified by an MDX–formatted string. 

Returns the cross product of one or more sets as a set, excluding empty tuples and tuples without associated fact table data. 

Arranges members of a specified set, optionally preserving or breaking the hierarchy. 

Returns a set of sibling members from the same level as a given member, starting with the first sibling and ending with the given member, as constrained by a specified level in the Time dimension. 

Returns a set of sibling members from the same level as a given member, starting with the first sibling and ending with the given member, as constrained by the Quarter level in the Time dimension. 

Returns the siblings of a specified member, including the member itself. 

Returns a set generated by removing calculated members from a specified set. 

Returns the set specified by an MDX–formatted string. 

Returns a subset of tuples from a specified set. 

Returns a subset from the end of a set. 

Toggles the drill state of members. 

Sorts a set in descending order and returns the specified number of elements with the highest values. 

Sorts a set in descending order, and returns a set of tuples with the highest values whose cumulative total is equal to or less than a specified percentage. 

Sorts a set and returns the topmost elements whose cumulative total is at least a specified value. 

Returns the union of two sets, optionally retaining duplicates. 

Removes any enforced ordering from a specified set. 

Returns a set generated by dynamically totaling child members in a specified set, optionally using a pattern for the name of the parent member in the resulting cellset. 

Returns a set of sibling members from the same level as a given member, starting with the first sibling and ending with the given member, as constrained by the Week level in the Time dimension. 

Returns a set of sibling members from the same level as a given member, starting with the first sibling and ending with the given member, as constrained by the Year level in the Time dimension. 
String Functions
Function  Description 

Returns the value of an MDX expression evaluated over the specified calculation pass of a cube. 

Coalesces an empty cell value to a number or string and returns the coalesced value. 

Applies a set to each member of another set, and then joins the resulting sets by union. Alternatively, this function returns a concatenated string created by evaluating a string expression over a set. 

Returns one of two values determined by a logical test. 

Returns the value of an MDX expression evaluated over another specified cube in the same database. 

Returns an MDX–formatted string that corresponds to a specified member. 

Returns the name of a dimension, hierarchy, level, or member. 

Returns a string, or a stronglytyped value, that contains a member property value. 

Returns an MDXformatted string of that corresponds to a specified set. 

Returns an MDX–formatted string that corresponds to specified tuple. 

Returns the unique name of a specified dimension, hierarchy, level, or member. 

Returns the domain name and user name of the current connection. 
Subcube Functions
Function  Description 

Returns the current subcube. 

Returns the set of leaf members in the specified dimension, member, or tuple. 
Tuple Functions
Function  Description 

Returns the current tuple from a set during iteration. 

Returns a tuple from a set. 

Returns a tuple that consists of the All members from each attribute hierarchy in a cube, dimension, or tuple. 

Returns the tuple specified by an MDX–formatted string. 
Other Functions
Function  Description 

Raises an error, optionally providing a specified error message. 