Returns: A set.
If you do not specify a numeric expression, the default value is 1. If you specify a number that is greater than the number of elements in a set, the complete original set is returned. If you specify a numeric expression that is less than 1, an empty set is returned.
Use the Head function to return a specific number of elements starting from the beginning of a set. The order of elements that are returned is maintained within the new set.
In this example, you want to see which stores are the most profitable. The following query uses the Head function to return the profit amount of the three stores that have the largest profit amounts.
SELECT {[Price Analysis].[Measures].[Profit Amount]}
ON AXIS(0),
{Head(Order(Descendants([Price Analysis].[Store].[All Stores], -1, LEAVES),
[Price Analysis].[Measures].[Profit Amount], BDESC), 3)}
ON AXIS(1)
FROM [Price Analysis]
| Store | Profit amount |
|---|---|
| ValueTrend Store 1199 | 84813.24 |
| ValueTrend Store 116 | 81950.42 |
| ValueTrend Store 1095 | 81673.1 |