Head

Returns the first n members or tuples present in a set.

Syntax

Head ( set [,numeric value expression ] )
ParameterDescription

set

The set from which to take items.

numeric value expression

The count of items to take from the beginning of the set. If omitted, the default is 1. If less than 1, an empty set is returned. If the value exceeds the number of tuples in the input set, the original set is returned.

Example

Example 1

This example uses the following part of the Sample Basic outline:

Outline section showing member "Product" and its children, "100", "200", "300," "400", and "Diet."

The following expression

[Product].children

returns the set:

{ [100], [200], [300], [400], [Diet] }

Therefore, the following expression

 Head (
  [Product].children, 2) 

returns the first two members of the previous result set:

{ [100], [200] }

Example 2

This example uses the following parts of the Sample Basic outline:

Outline section showing member "100" and its children, "100-10", "100-20", and "100-30."
Outline section showing member "South" and its children, "Texas", "Oklahoma", "Louisiana," and "New Mexico."
Outline section showing member "Year" and its children, "Qtr1", "Qtr2", "Qtr3," and "Qtr4."

The following expression

 CrossJoin ( [100].children, [South].children )

returns the set:

{ ([100-10], Texas), ([100-10], Oklahoma), ([100-10], Louisiana), ([100-10], [New Mexico]),
  ([100-20], Texas), ([100-20], Oklahoma), ([100-20], Louisiana), ([100-20], [New Mexico]),
  ([100-30], Texas), ([100-30], Oklahoma), ([100-30], Louisiana), ([100-30], [New Mexico]) }

And the following expression

Head ( CrossJoin ([100].children, [South].children), 8 )

returns the first 8 tuples of the previous result set:

{ ([100-10], Texas), ([100-10], Oklahoma), ([100-10], Louisiana), ([100-10], [New Mexico]),
  ([100-20], Texas), ([100-20], Oklahoma), ([100-20], Louisiana), ([100-20], [New Mexico]) } 

Additionally, the following expression

([Year].generations(2).members)

returns the set of members comprising the second generation of the Year dimension:

{ [Qtr1], [Qtr2], [Qtr3], [Qtr4] }

Therefore, the following query

SELECT
  {([Year].generations(2).members)}
ON COLUMNS,
Head (
 CrossJoin (
  [100].children, [South].children), 8
     ) 
ON ROWS
FROM Sample.Basic 

returns the grid:

(axis)Qtr1Qtr2Qtr3Qtr4
100–10Texas489536653547
Oklahoma8792128211
Louisiana93106128137
New Mexico7610112270
100–20Texas20619915282
Oklahoma84665579
Louisiana119158171104
New Mexico–103–60–98–18

See Also

  • Tail