Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Kappa
Frequent Visitor

Count of total number of elements at each level in the hierarchy.

Hello!

 

The hierarchy is Sector > Subsector > Industrygroup > Industry > CanadianIndustries.

 

How to find the the total count values of elements at each level in the hierarchy?

 

For example, If we expand Finance and insurance :- 

 

There are:-

  • 5 elements in the subsector, therefore besides Finance and insurance it shows the value 5.
  • 3 elements in the industrygroups, therefore besides Credit intermediation and related activities,  it shows the value 3.
  • 3 elements in the Industry, therefore besides Activities related to credit intermediation, it shows the value 3.
  • 2 elements in the Canadian Industry, therefore besides Financial transaction .... activities it shows 2.
  • And for the last level, it is the individual therefore the value is 1.

 

Kappa_0-1653647254938.png

 

Please find the .pbix file for the reference.

https://we.tl/t-3QvT9ot3CV

 

Thanks

1 ACCEPTED SOLUTION
SpartaBI
Community Champion
Community Champion

@Kappa write this measure:

 

Elements = 
SWITCH(
    TRUE(),
    ISINSCOPE('Hierarchical Data'[Canadian industry]), COUNTROWS('Hierarchical Data'),
    ISINSCOPE('Hierarchical Data'[Industry]), COUNTROWS('Hierarchical Data'),
    ISINSCOPE('Hierarchical Data'[IG]), DISTINCTCOUNT('Hierarchical Data'[Industry]),
    ISINSCOPE('Hierarchical Data'[Subsectors]), DISTINCTCOUNT('Hierarchical Data'[IG]),
    ISINSCOPE('Hierarchical Data'[Sectors]), DISTINCTCOUNT('Hierarchical Data'[Subsectors]),
    DISTINCTCOUNT('Hierarchical Data'[Sectors])
)

 

SpartaBI_0-1653648576713.png

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

View solution in original post

1 REPLY 1
SpartaBI
Community Champion
Community Champion

@Kappa write this measure:

 

Elements = 
SWITCH(
    TRUE(),
    ISINSCOPE('Hierarchical Data'[Canadian industry]), COUNTROWS('Hierarchical Data'),
    ISINSCOPE('Hierarchical Data'[Industry]), COUNTROWS('Hierarchical Data'),
    ISINSCOPE('Hierarchical Data'[IG]), DISTINCTCOUNT('Hierarchical Data'[Industry]),
    ISINSCOPE('Hierarchical Data'[Subsectors]), DISTINCTCOUNT('Hierarchical Data'[IG]),
    ISINSCOPE('Hierarchical Data'[Sectors]), DISTINCTCOUNT('Hierarchical Data'[Subsectors]),
    DISTINCTCOUNT('Hierarchical Data'[Sectors])
)

 

SpartaBI_0-1653648576713.png

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors