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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Gazi
Frequent Visitor

Calculate AVG count of children elements in herarchy

Hi everyone!

 

I am having a hard time calculating average of children count in hierarchy.

 

For example: 

 

Parent Product A has 2 children: B and C.

B has 3 items and C has 5 items assigned (count). Total count is 8, but how to get the average count for A? which is 4.

 

Many thanks!

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@Gazi,

Please check if the following measure returns your expected result. If not, please share sample data of your table.

average = CALCULATE(COUNTA(Table[Item]),ALLEXCEPT(Table,Table[Product],Table[Item]))/CALCULATE(DISTINCTCOUNT(Table[Children]),ALLEXCEPT(Table,Table[Product]))

1.PNG

Regards,
Lydia

View solution in original post

@Anonymous

 

Hi Lydia!

 

Awesome!! It seems to be working! Sorry I forgot to mention - my hierarchy has 9 levels, not just 2 like in this example. So do you think I could extend your measure with a parameter or?

 

Many thanks!!!

  

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Gazi,

Please check if the following measure returns your expected result. If not, please share sample data of your table.

average = CALCULATE(COUNTA(Table[Item]),ALLEXCEPT(Table,Table[Product],Table[Item]))/CALCULATE(DISTINCTCOUNT(Table[Children]),ALLEXCEPT(Table,Table[Product]))

1.PNG

Regards,
Lydia

@Anonymous

 

Hi Lydia!

 

Awesome!! It seems to be working! Sorry I forgot to mention - my hierarchy has 9 levels, not just 2 like in this example. So do you think I could extend your measure with a parameter or?

 

Many thanks!!!

  

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors