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
Anonymous
Not applicable

Averages for grouped data between a range

Hello,

 

We have a data warehouse that connects via direct query. We have dimension tables that contains ranges of data. For example, dates ranges, income ranges, gender.

 

The following image contain an example Matrix visulaisation, related to an age of a person. We would like to work the overall average age value?  

 

 

totals-by-age-range.PNG

 

Selecting, the display value as an average option (the last column), gives an incorrect result.

 

Using excel I can work out an an average by:

 

  • adding the two range value foreach row together and then dividing by 2 to get a mid value,
  • then multiplying this by a freqency values (no. of people) foreach row to get a mid * freqency values,  
  • then sum the mid * freqency value and divide this by the sum of the freqency values

 

average-excel.PNG

 

How would I appraoch this within power bi desktop. This the an inbuilt option that can work out an average or would we need to use DAX to create a measure or extra column

 

Thanks

 

 

 

 

 

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

Perhaps a measure like:

 

m_MyAverage = ((SUM([AgeRangeLow])+SUM([AgeRangeHigh]/2) * COUNT([Id]))/COUNT([AgeRange])


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...
Anonymous
Not applicable

Hi smoupre,

 

Your measure was useful. But, I wasn't able to get this to work.

 

I tried the following measure:

 

Mid = 
VAR     
    AgeRangeMidPoint = DIVIDE(
        (SUM('dim AgeRanges'[Minimum]) + SUM('dim AgeRanges'[Maximum])),2
    )
RETURN
    (AgeRangeMidPoint * COUNT('fact Calculations'[Id]))

Then used it as the last column of the following matrix visualisation:

 

age-range-averages.PNG

 

What I would need to do is to:

 

  • Get the Sum of the measure value Mid (note that overal total in the attached image is incorrect),
  • Get the Sum of Id,
  • Then divide by the Sum of the measure values by the Sum of the Id total

 

Thanks

Hi @Anonymous,

 

According to your description above, you should be able to use the formula below to get the Sum of the measure value Mid. Smiley Happy

TotalMid =
SUMX (
    SUMMARIZE ( 'dim AgeRanges', 'dim AgeRanges'[AgeRange], "abc", [Mid] ),
    [abc]
)

 

Regards

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors