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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
jd_87
Frequent Visitor

Hierarchical calculation of averages

I'm working with some hierarchical data and am running into issues in my tables when calculating the average values at higher levels, since the higher level seems to only average the values of lower levels rather than calculating it separately (i.e., it doesn't account for differences in denominators between groups). I think I've seen similar questions (e.g., here) - but that example was from many years ago and I'm not sure if there are solutions now. As an example:

 

I have two tables:

  • Table 1: describes the hierarchical relationship (in this example, 2 levels each with unique sublevels)

jd_87_0-1723831805171.png

 

  • Table 2 contains the data for each of the sublevels:

jd_87_1-1723831907638.png

 

The tables are connected in a 1-to-many relationship (Table 1 [1] : Table 2 [*]).

 

When I look at all the full data in a table in the report view, the results are what I want (i.e., the Value column = Numerator / Denominator):

jd_87_2-1723832077664.png

BUT, when I want to look at the data aggregated by Level 1, the Values are not what I want (i.e., the Value column does NOT equal Numerator/Denominator; the Values should be 0.095 and 0.012):

jd_87_3-1723833217564.png

 

This is a simplistic example, but the issue arises in a few different contexts. Are there DAX formulae to help with this? Or other workarounds that people use?

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@jd_87 For your example, you would create a measure like this:

 

Measure = DIVIDE( SUM( 'Table'[Numerator] ), SUM( 'Table'[Denominator] ) )

 

For more explicit control over your values at different hierarchy levels, refer to this: Matrix Measure Total Triple Threat Rock & Roll - Microsoft Fabric Community



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

@jd_87 For your example, you would create a measure like this:

 

Measure = DIVIDE( SUM( 'Table'[Numerator] ), SUM( 'Table'[Denominator] ) )

 

For more explicit control over your values at different hierarchy levels, refer to this: Matrix Measure Total Triple Threat Rock & Roll - Microsoft Fabric Community



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thanks @Greg_Deckler , that does answer the question I posed, but I'm now realizing it doesn't solve the actual crux of my problem, since my problem is a bit more complex. Not sure if you have the time to think about this, but:

 

We have an additional column, Metrics, and for each of our lowest categories (i.e., Level 2) we're collecting a range of different metrics (call them "XX", "YY", "ZZ" - so Level 2 "A" will have three rows corresponding to each of those three metrics, "B" will have the same and so on). My desired outcome is to have a slicer where the user can select the metric their interested in, and the table will update accordingly. I believe with that DAX formula you gave, it averages the result for each of the three metrics for each Level 2. So I guess I would need a way to specify - perform that calculation only on the selected metric, and leave out the others. Does that make sense?

 

(Also, that link you provided will be very helpful, as our hierarchy is much bigger than the example I gave)

@jd_87 If you can provide a sample file or better sample data, happy to take a look. I like to solve these kinds of problems.



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thanks @Greg_Deckler - upon closer examination, it appears the fault is entirely mine! Your solution worked with extra sample data I created, which then prompted me to look closer at my data model and I found some issues there. So I think I'm good to go - thanks for your help 🙂 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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