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
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
v-yuezhe-msft
Employee
Employee

@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

Community Support Team _ Lydia Zhang
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

@v-yuezhe-msft

 

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
v-yuezhe-msft
Employee
Employee

@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

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yuezhe-msft

 

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
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.