Skip to main content

HEAD (MDX)

Returns a subset from the start of a set, using the current order of the set.

Returned Type

This function returns a set.

Syntax and Details

HEAD(set_expression, optional_integer_expression, optional_sample_flag)
  • set_expression is an expression that evaluates to a set.

    Important:

    When set_expression is a CROSSJOIN or NONEMPTYCROSSJOIN expression and the slicer axis contains related cube terms, HEAD may return inaccurate results. This is because under these conditions the HEAD subset is evaluated before the join indexes have been computed.

  • optional_integer_expression is an integer literal.

    The default value for this argument is 1.

    The function uses this argument to determine the number of elements to return in the subset.

  • optional_sample_flag, if included, is SAMPLE

    This optional flag has an effect only in the case where the set_expression contains multiple nested CROSSJOIN expressions. In such cases, by default, the system does not attempt to determine the subset until set_expression has been fully evaluated and all the set elements are known. If you include the optional_sample_flag, the system truncates the results as each CROSSJOIN is evaluated; this approach can be considerably faster but can result in a subset that contains fewer elements than given by the optional_integer_expression.

    Note that when you use drag and drop actions in the Analyzer to create queries that use the HEAD function for a set that contains multiple nested CROSSJOIN expressions, the Analyzer automatically adds this flag.

This function returns a set that consists of the specified number of elements from the start of the given set (considering the current order of the set). If integer_expression is less than 1, the function returns the empty set. If integer_expression is greater than the number of elements of the set, the function returns the original set.

The elements of the subset are returned in the same order specified by the original set.

Example

SELECT MEASURES.[%COUNT] ON 0, HEAD(birthd.decade.MEMBERS, 3) ON 1 
FROM patients
                             Patient Count
1 1910s                                  71
2 1920s                                 223
3 1930s                                 572

See Also

FeedbackOpens in a new tab