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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Gazi
Frequent Visitor

Recursive DAX for Hierarchy

Hi everyone!

 

I have the following DAX statement to calculate AVG count for one level below (Thanks to Lydia! @v-yuezhe-msft)

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

 

large.png

 

But problem is I have 9 levels in hierarchy. Any ideas how to extend this DAX statement??

 

Many many thanks!!

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Well, I can tell you that you can't do recursion in DAX, DAX hates it. 

 

Can you refer back to the original problem perhaps? Need the data in a copy and paste format to recreate and need to better understand what you want to do. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

Well, I can tell you that you can't do recursion in DAX, DAX hates it. 

 

Can you refer back to the original problem perhaps? Need the data in a copy and paste format to recreate and need to better understand what you want to do. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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