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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
bwanRPD
Frequent Visitor

Average the averages within a Matrix?

Is there a way to have the Matrix visualization average all the rows, but have the grand total average the averages? Please see screenshot below.

bwanRPD_0-1658871602255.png

 

I have "elements" which you see all begin with "Cleanliness", all of those elements are averaged up to the feature, which are the 4 groups: Buildings & General Amenities, Hardscape, Ornamental Beds, and Trees. I then have the grand total at the bottom, which does what the Matrix usually does and averages all the records associated which becomes 0.92.

What I want to do instead is have the grand total average all of the 4 different feature groups, which is: 0.86, 0.88, 1.00, and 1.00 which would average to 0.935 instead of 0.92.

5 REPLIES 5
Anonymous
Not applicable

Hi  @bwanRPD ,

Here are the steps you can follow:

1. Create measure.

Flag1 =
IF(
   MAX('Table'[Group2])="Cleanliness",
AVERAGEX(FILTER(ALL('Table'),'Table'[Group1]=MAX('Table'[Group1])),[Amount1]),0)
Flag2 =
DIVIDE(
SUMX(ALL('Table'),[Flag1]),
COUNTX(FILTER(ALL('Table'),[Flag1]<>BLANK()),[Flag1]))
VALUE =
IF(
    HASONEVALUE('Table'[Group1]),AVERAGE('Table'[Amount1]),[Flag2])

2. Result:

vyangliumsft_0-1659074565420.png

 

If you need pbix, please click here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Hi @Anonymous 

Thanks for the response! I copied exactly what you had and for some reason not getting the same results...I'm wondering is it because I have more data than what you have in your pbix example? The one that you have in your code is all the scores for quarter 1. In my dataset, there are 4 quarters. Please see below screenshot and also the code that I used that mirrored yours. I would need to be able to separate the calculations based on another criteria that is another column in my table called "Quarter", and possibly also another column called "Year", is that possible? Thanks again for your help.

bwanRPD_0-1659120431240.png

 

Flag1 = IF(
    MAX('Scores'[Element])="Cleanliness",
    AVERAGEX(FILTER(ALL('Scores'),'Scores'[Feature]=MAX('Scores'[Feature])),[Element_Score]),0)
Flag2 = DIVIDE(
    SUMX(ALL('Scores'),[Flag1]),
    COUNTX(FILTER(ALL('Scores'),[Flag1]<>BLANK()),[Flag1]))
AvgAvg = IF(
    HASONEVALUE('Scores'[Feature]),AVERAGE('Scores'[Element_Score]),[Flag2])

 

amitchandak
Super User
Super User

@bwanRPD , Using the columns in the matrix

 

Averagex(Addcolumns(Summarize(Table, Table[Buliding], Table[Element]), "_1", [Avg]), [_1])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Sorry, one more question, if your DAX, what is [Avg]? is that a different table that you are referencing?

Hi, sorry I am not as familiar with writing DAX in PBI. Am I adding this in as a measure within the Matrix, or a separate column in the data table?

The DAX you provided gives a couple tables in the parameter, but the "Building" and "Element" is all part of the same 1 table.

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.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors