Count (Hierarchy Levels) (MDX)
Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
Returns the number of levels in hierarchy.
Returns the number of levels in a hierarchy, including the [All] level, if applicable.
When a dimension contains only a single visible hierarchy, the hierarchy can be referred to either by the dimension name or by the hierarchy name, because the dimension name is resolved to its only visible hierarchy. For example, Measures.Levels.Count is a valid MDX expression because it resolves to the only hierarchy in the Measures dimension.
The following example returns a count of the number of levels in the Product Categories user-defined hierarchy in the Adventure Works cube.
WITH MEMBER measures.X AS [Product].[Product Categories].Levels.Count Select Measures.X ON 0 FROM [Adventure Works]