Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.59 KB

count-hierarchy-levels-mdx.md

File metadata and controls

51 lines (38 loc) · 1.59 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic ms.custom
Count (Hierarchy Levels) (MDX)
Count (Hierarchy Levels) (MDX)
kfollis
kfollis
kfollis
02/17/2022
sql
analysis-services
reference
mdx

Count (Hierarchy Levels) (MDX)

Returns the number of levels in hierarchy.

Syntax

  
Hierarchy_Expression.Levels.Count  

Arguments

Hierarchy_Expression
A valid Multidimensional Expressions (MDX) expression that returns a hierarchy.

Remarks

Returns the number of levels in a hierarchy, including the [All] level, if applicable.

Important

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.

Example

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]  

See Also

Count (Dimension) (MDX)
Count (Tuple) (MDX)
Count (Set) (MDX)
MDX Function Reference (MDX)