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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-eqin-msft
Community Support
Community Support

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
v-eqin-msft
Community Support
Community Support

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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