Count dot function (MDX)

The Count dot function returns the number of members in a specified set or the count of levels in a hierarchy.

Returns: A number.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-+-SetExpression--------------+--.--Count--------------------><
   '-HierarchyExpression.Levels-'             

Parameters

SetExpression
Specifies the set whose members are to be counted.
HierarchyExpression
Specifies the hierarchy whose levels are to be counted.

Description

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.

Example 1

The following example uses the Count dot function to return the number of levels in the Store hierarchy.

Query
WITH 

MEMBER [Price Analysis].[Measures].[HierarchyLevelCount] 

	AS [Price Analysis].[Store].Hierarchy.Levels.Count 

SELECT {[Price Analysis].[Measures].[HierarchyLevelCount]} ON AXIS(0)

FROM [Price Analysis]
Result
HierarchyLevelCount
5

Example 2

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.

Query
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]
Result
SetCount
3

Related functions

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.



Feedback | Information roadmap