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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Weighted average - help needed

Hello everyone,

 

I am learning PowerBI and am trying to calculate an average value.

 

I have the population size for a series of cities, across a number of years, and the population age

 

CityYearPopulation agePopulation size (for each age)
London20081100
London20082140
London2008398
London20091102
London20092130
London2009399
London20102118
Manchester2008158
Manchester2008360
Manchester2009261
Manchester2009355
Manchester2009470

 

I would like to calculate the average age for each city, keeping into account the population size (i.e. weighted average).

E.g. if in a city in a year there are: 100 5yr old people and 100 3yr old people, the average population age will be 4yr old. However, it there are 100 5yr and 200 3yr old people, the average population age will be lower.

 

I have tried to look at existing responses but I am totally lost 😞

Any help would be much appreciated, thank you in advance!

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

Weighted average can be computed like this:

AvgAge =
DIVIDE (
    SUMX ( Table1, Table1[Age] * Table1[Size] ),
    SUMX ( Table1, Table1[Size] )
)

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Here is another way.  Create a calculated column formula

Numerator = Data[Population age]*Data[Population size]

Write this measure

Ratio = divide([numerator],SUM(Data[Population size]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

You'll need a SUM around the [numerator] in the Ratio.

Yes, that is correct.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
AlexisOlson
Super User
Super User

Weighted average can be computed like this:

AvgAge =
DIVIDE (
    SUMX ( Table1, Table1[Age] * Table1[Size] ),
    SUMX ( Table1, Table1[Size] )
)
Anonymous
Not applicable

Thank you @AlexisOlson !

 

Would it be the same if I wrote:

AveAge = DIVIDE(SUMX (Table1, Table1[Age] * Table1[Size]), SUM(Table1[Size])) ?

 

I don't understand why you are using the SUMX within the DIVIDE function....

 

Thank you!

 

AvgAge =
DIVIDE (
    SUMX ( Table1, Table1[Age] * Table1[Size] ),
    SUMX ( Table1, Table1[Size] )
)

 

Yeah, it should be the same.

 

I kept the SUMX in the denominator only for aesthetic reasons to emphasize the parallel with the numerator.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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