Returns: A number.
>>-+-SetExpression--------------+--.--Count-------------------->< '-HierarchyExpression.Levels-'
The Count dot function includes empty members in the count.
A typical use of the Count dot function is in an MDX expression where some element of the expression returns a set and another element of the expression needs to know the number of members in the set.
The following example uses the Count dot function to return the number of levels in the Store hierarchy.
WITH
MEMBER [Price Analysis].[Measures].[HierarchyLevelCount]
AS [Price Analysis].[Store].Hierarchy.Levels.Count
SELECT {[Price Analysis].[Measures].[HierarchyLevelCount]} ON AXIS(0)
FROM [Price Analysis]
| HierarchyLevelCount |
|---|
| 5 |
In the next example you want to see how many years are represented in a particular cube. The following example uses the Count dot function to return the number of members of a set that consist of the children of the All Time (Calendar) member of the Time hierarchy.
WITH
MEMBER [Price Analysis].[Measures].[SetCount]
AS [Price Analysis].[Time].[All Time (Calendar)].Children.Count
SELECT {[Price Analysis].[Measures].[SetCount]} ON AXIS(0)
FROM [Price Analysis]
| SetCount |
|---|
| 3 |
The Count function is similar, but it can be applied only to a set, and it offers an option to exclude the empty members from the result.