Redigera

Dela via


MDX Function Reference (MDX)

Analysis Services 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.

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
SetToArray (MDX) Converts one or more sets to an array for use in a user-defined function.

Hierarchy Functions

Function Description
Hierarchy (MDX) Returns the hierarchy that contains a specified member or level.
Dimension (MDX) Returns the dimension that contains a specified member, level, or hierarchy.
Dimensions (MDX) Returns a hierarchy specified by a numeric or string expression.

Level Functions

Function Description
Level (MDX) Returns the level of a member.
Levels (MDX) 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
IsAncestor (MDX) Returns whether a specified member is an ancestor of another specified member.
IsEmpty (MDX) Returns whether the evaluated expression is the empty cell value.
IsGeneration (MDX) Returns whether a specified member is in a specified generation.
IsLeaf (MDX) Returns whether a specified member is a leaf member.
IsSibling (MDX) Returns whether a specified member is a sibling of another specified member.

Member Functions

Function Description
Ancestor (MDX) Returns the ancestor of a member at a specified level or distance.
ClosingPeriod (MDX) Returns the last sibling among the descendants of a member at a specified level.
Cousin (MDX) Returns the child member with the same relative position under a parent member as the specified child member.
CurrentMember (MDX) Returns the current member along a specified dimension or hierarchy during iteration.
DataMember (MDX) Returns the system-generated data member that is associated with a nonleaf member of a dimension.
DefaultMember (MDX) Returns the default member of a dimension or hierarchy.
FirstChild (MDX) Returns the first child of a member.
FirstSibling (MDX) Returns the first child of the parent of a member.
Item (Member) (MDX) Returns a member from a specified tuple.
Lag (MDX) Returns the member that is a specified number of positions before a specified member along the member's dimension.
LastChild (MDX) Returns the last child of a specified member.
LastSibling (MDX) Returns the last child of the parent of a specified member.
Lead (MDX) Returns the member that is a specified number of positions following a specified member along the member's dimension.
LinkMember (MDX) Returns the member equivalent to a specified member in a specified hierarchy.
Members (String) (MDX) Returns a member specified by a string expression.
NextMember (MDX) Returns the next member in the level that contains a specified member.
OpeningPeriod (MDX) Returns the first sibling among the descendants of a specified level, optionally at a specified member.
ParallelPeriod (MDX) Returns a member from a prior period in the same relative position as a specified member.
Parent (MDX) Returns the parent of a member.
PrevMember (MDX) Returns the previous member in the level that contains a specified member.
StrToMember (MDX) Returns the member specified by an MDX-formatted string.
UnknownMember (MDX) Returns the unknown member associated with a level or member.
ValidMeasure (MDX) Returns a valid measure in a virtual cube by forcing inapplicable dimensions to their top level.

Numeric Functions

Function Description
Aggregate (MDX) Returns a scalar value calculated by aggregating either measures or an optionally specified numeric expression over the tuples of a specified set.
Avg (MDX) Returns the average value of measures or the average value of an optional numeric expression, evaluated over a specified set.
CalculationCurrentPass (MDX) Returns the current calculation pass of a cube for the specified query context.
CalculationPassValue (MDX) Returns the value of a MDX expression evaluated over the specified calculation pass of a cube.
CoalesceEmpty (MDX) Coalesces an empty cell value to a number or string and returns the coalesced value.
Correlation (MDX) Returns the correlation coefficient of two series evaluated over a set.
Count (Dimension) (MDX) Returns the number of dimensions in a cube.
Count (Hierarchy Levels) (MDX) Returns the number of levels in a dimension or hierarchy.
Count (Set) (MDX) Returns the number of cells in a set.
Count (Tuple) (MDX) Returns the number of dimensions in a tuple.
Covariance (MDX) Returns the population covariance of two series evaluated over a set, using the biased population formula.
CovarianceN (MDX) Returns the sample covariance of two series evaluated over a set, using the unbiased population formula.
DistinctCount (MDX) Returns the number of distinct, nonempty tuples in a set.
IIf (MDX) Returns one of two values determined by a logical test.
LinRegIntercept (MDX) Calculates the linear regression of a set and returns the value of the intercept in the regression line, y = ax + b.
LinRegPoint (MDX) Calculates the linear regression of a set and returns the value of y in the regression line, y = ax + b.
LinRegR2 (MDX) Calculates the linear regression of a set and returns the coefficient of determination, R2.
LinRegSlope (MDX) Calculates the linear regression of a set, and returns the value of the slope in the regression line, y = ax + b.
LinRegVariance (MDX) Calculates the linear regression of a set, and returns the variance associated with the regression line, y = ax + b.
LookupCube (MDX) Returns the value of an MDX expression evaluated over another specified cube in the same database.
Max (MDX) Returns the maximum value of a numeric expression that is evaluated over a set.
Median (MDX) Returns the median value of a numeric expression that is evaluated over a set.
Min (MDX) Returns the minimum value of a numeric expression that is evaluated over a set.
Ordinal (MDX) Returns the zero-based ordinal value associated with a level.
Predict (MDX) Returns a value of a numeric expression evaluated over a data mining model.
Rank (MDX) Returns the one-based rank of a specified tuple in a specified set.
RollupChildren (MDX) Returns a value generated by rolling up the values of the children of a specified member using the specified unary operator.
Stddev (MDX) Alias for Stdev (MDX).
StddevP (MDX) Alias for StdevP (MDX).
Stdev (MDX) Returns the sample standard deviation of a numeric expression evaluated over a set, using the unbiased population formula.
StdevP (MDX) Returns the population standard deviation of a numeric expression evaluated over a set, using the biased population formula.
StrToValue (MDX) Returns the value specified by an MDX-formatted string.
Sum (MDX) Returns the sum of a numeric expression evaluated over a set.
Value (MDX) Returns the value of a measure.
Var (MDX) Returns the sample variance of a numeric expression evaluated over a set, using the unbiased population formula.
Variance (MDX) Alias for Var (MDX).
VarianceP (MDX) Alias for VarP (MDX).
VarP (MDX) Returns the population variance of a numeric expression evaluated over a set, using the biased population formula.

Set Functions

Function Description
AddCalculatedMembers (MDX) Returns a set generated by adding calculated members to a specified set.
AllMembers (MDX) Returns a set that contains all members, including calculated members, of the specified dimension, hierarchy, or level.
Ancestors (MDX) Returns a set of all ancestors of a member at a specified level or distance.
Ascendants (MDX) Returns the set of the ascendants of a specified member, including the member itself.
Axis (MDX) Returns a set defined in an axis.
BottomCount (MDX) Sorts a set in ascending order, and returns the specified number of tuples with the lowest values.
BottomPercent (MDX) 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.
BottomSum (MDX) 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.
Children (MDX) Returns the children of a specified member.
Crossjoin (MDX) Returns the cross product of one or more sets.
CurrentOrdinal (MDX) Returns the current iteration number within a set during iteration.
Descendants (MDX) Returns the set of descendants of a member at a specified level or distance, optionally including or excluding descendants in other levels.
Distinct (MDX) Returns a set, removing duplicate tuples from a specified set.
DrilldownLevel (MDX) 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.
DrilldownLevelBottom (MDX) Drills down the bottommost members of a set, at a specified level, to one level below.
DrilldownLevelTop (MDX) Drills down the topmost members of a set, at a specified level, to one level below.
DrilldownMember (MDX) 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.
DrilldownMemberBottom (MDX) 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.
DrilldownMemberTop (MDX) 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.
DrillupLevel (MDX) Drills up the members of a set that are below a specified level.
DrillupMember (MDX) Drills up the members in a specified set that are present in a second specified set.
Except (MDX) Finds the difference between two sets, optionally retaining duplicates.
Exists (MDX) Returns the set of members of one set that exist with one or more tuples of one or more other sets.
Extract (MDX) Returns a set of tuples from extracted dimension elements.
Filter (MDX) Returns the set that results from filtering a specified set based on a search condition.
Generate (MDX) 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.
Head (MDX) Returns the first specified number of elements in a set, while retaining duplicates.
Hierarchize (MDX) Orders the members of a set in a hierarchy.
Intersect (MDX) Returns the intersection of two input sets, optionally retaining duplicates.
LastPeriods (MDX) Returns a set of members up to and including a specified member.
Members (Set) (MDX) Returns the set of members in a dimension, level, or hierarchy.
Mtd (MDX) 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.
NameToSet (MDX) Returns a set that contains the member specified by an MDX-formatted string.
NonEmptyCrossjoin (MDX) Returns the cross product of one or more sets as a set, excluding empty tuples and tuples without associated fact table data.
Order (MDX) Arranges members of a specified set, optionally preserving or breaking the hierarchy.
PeriodsToDate (MDX) 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.
Qtd (MDX) 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.
Siblings (MDX) Returns the siblings of a specified member, including the member itself.
StripCalculatedMembers (MDX) Returns a set generated by removing calculated members from a specified set.
StrToSet (MDX) Returns the set specified by an MDX-formatted string.
Subset (MDX) Returns a subset of tuples from a specified set.
Tail (MDX) Returns a subset from the end of a set.
ToggleDrillState (MDX) Toggles the drill state of members.
TopCount (MDX) Sorts a set in descending order and returns the specified number of elements with the highest values.
TopPercent (MDX) 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.
TopSum (MDX) Sorts a set and returns the topmost elements whose cumulative total is at least a specified value.
Union (MDX) Returns the union of two sets, optionally retaining duplicates.
Unorder (MDX) Removes any enforced ordering from a specified set.
VisualTotals (MDX) 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.
Wtd (MDX) 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.
Ytd (MDX) 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
CalculationPassValue (MDX) Returns the value of an MDX expression evaluated over the specified calculation pass of a cube.
CoalesceEmpty (MDX) Coalesces an empty cell value to a number or string and returns the coalesced value.
Generate (MDX) 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.
IIf (MDX) Returns one of two values determined by a logical test.
LookupCube (MDX) Returns the value of an MDX expression evaluated over another specified cube in the same database.
MemberToStr (MDX) Returns an MDX-formatted string that corresponds to a specified member.
Name (MDX) Returns the name of a dimension, hierarchy, level, or member.
Properties (MDX) Returns a string, or a strongly-typed value, that contains a member property value.
SetToStr (MDX) Returns an MDX-formatted string of that corresponds to a specified set.
TupleToStr (MDX) Returns an MDX-formatted string that corresponds to specified tuple.
UniqueName (MDX) Returns the unique name of a specified dimension, hierarchy, level, or member.
UserName (MDX) Returns the domain name and user name of the current connection.

Subcube Functions

Function Description
This (MDX) Returns the current subcube.
Leaves (MDX) Returns the set of leaf members in the specified dimension, member, or tuple.

Tuple Functions

Function Description
Current (MDX) Returns the current tuple from a set during iteration.
Item (Tuple) (MDX) Returns a tuple from a set.
Root (MDX) Returns a tuple that consists of the All members from each attribute hierarchy in a cube, dimension, or tuple.
StrToTuple (MDX) Returns the tuple specified by an MDX-formatted string.

Other Functions

Function Description
Error (MDX) Raises an error, optionally providing a specified error message.

See Also

MDX Language Reference (MDX)