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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Exclude counting the parent in a hierarchy

Hi All,

I have the below data structure. I have created the hierarchy and determined the paths as well.

SmithaKMurthy_0-1657008001100.png


I am trying to build a visual where in I can see the count of work items at each drill down level. However, as you can see in the below screenshot, I also get the parent counted in when I simply use the ISFILTERED and DISTINCTCOUNT. Here, there are 7 items that are linked to the Epic1 but I get the count as 8 (the one additional record is of the Epic1 itself). Similarly for Epic2, there is only one record (Capability3), but I get the count as 2. 

SmithaKMurthy_3-1657008469246.png

 



How do I make sure that I exclude this self-reference in the count? Or is this counting approach fundamentally wrong? Thanks in advance!

SmithaKMurthy_1-1657008070031.png

 



1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please try:

Measure = 
var level1=CALCULATE(COUNTROWS('Table'),FILTER('Table',[Work Item Name]<>MAX('Table'[Level1])))
var level2=CALCULATE(COUNTROWS('Table'),FILTER('Table',[Work Item Name]<>MAX('Table'[Level2])))
var level3=CALCULATE(COUNTROWS('Table'),FILTER('Table',[Work Item Name]<>MAX('Table'[Level3])))
var level4=CALCULATE(COUNTROWS('Table'),FILTER('Table',[Work Item Name]<>MAX('Table'[Level4])))
return IF(HASONEVALUE('Table'[Level4]),level4,IF(HASONEVALUE('Table'[Level3]),level3,IF(HASONEVALUE('Table'[Level2]),level2,IF(HASONEVALUE('Table'[Level1]),level1))))

Output:

Eyelyn9_0-1657250330377.png

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

 

Please try:

Measure = 
var level1=CALCULATE(COUNTROWS('Table'),FILTER('Table',[Work Item Name]<>MAX('Table'[Level1])))
var level2=CALCULATE(COUNTROWS('Table'),FILTER('Table',[Work Item Name]<>MAX('Table'[Level2])))
var level3=CALCULATE(COUNTROWS('Table'),FILTER('Table',[Work Item Name]<>MAX('Table'[Level3])))
var level4=CALCULATE(COUNTROWS('Table'),FILTER('Table',[Work Item Name]<>MAX('Table'[Level4])))
return IF(HASONEVALUE('Table'[Level4]),level4,IF(HASONEVALUE('Table'[Level3]),level3,IF(HASONEVALUE('Table'[Level2]),level2,IF(HASONEVALUE('Table'[Level1]),level1))))

Output:

Eyelyn9_0-1657250330377.png

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.