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

Creating Dax Formula to Sum the Average at different levels and display in a matrix

Hi,

 

I am currently running into a wall quite severely with two measures I am trying to create. The source table looks like follows. PersonId, which indicates a person, brand which indicates a brand, category which indicates a question for a category for the brand, and score which is 1 for agree or 0 for disagree.

PersonIdBrandCategoryScore
1111
1120
1131
1140
1150
1211
1221
1230
1241
1250
2111
2120
2131
2140
2151
2210
2221
2231
2240
2250

 

What I am trying to do is create a matrix which has on the y axis the category and x axis the brand, with the average score for that category, the sum of the average scores for all brands, and the sum of the average for all categories, the output would look as follows:

 BrandId111222
Category Actual AverageSum of Average all BrandsSum of Average All Categories   
1 11 (Brand 1) + 0.5 (Brand 2) = 1.51 (Cat 1) + 0 (Cat 2) + 1 (Cat 3) + 0 (Cat 4) + 0 (Cat 5) = 2   
2  2 (Brand 1) + 0.5 (Brand 2) = 1.52 (Cat 1) + 0 (Cat 2) + 1 (Cat 3) + 0 (Cat 4) + 0 (Cat 5) = 2   
3  3 (Brand 1) + 0.5 (Brand 2) = 1.53 (Cat 1) + 0 (Cat 2) + 1 (Cat 3) + 0 (Cat 4) + 0 (Cat 5) = 2   
4  4 (Brand 1) + 0.5 (Brand 2) = 1.54 (Cat 1) + 0 (Cat 2) + 1 (Cat 3) + 0 (Cat 4) + 0 (Cat 5) = 2   
5  5 (Brand 1) + 0.5 (Brand 2) = 1.55 (Cat 1) + 0 (Cat 2) + 1 (Cat 3) + 0 (Cat 4) + 0 (Cat 5) = 2   

 

I have tried a lot of different things, such as group by, but summarizecolumns/group by is not allowed at a row level context (not sure why) but have not been able to find a work around to do this without group by (see code for group by which i tried below) - if someone could help me translate this into measures which do not use summarize and allow me to put it into a row level context I would be very grateful!

 

attemped code using summarize which does not work at row level in tables:

VAR ScoreByAttribute = SUMMARIZECOLUMNS (
Table[Category],
"AttributeScore", AVERAGE(Table[Score]))

RETURN
SUMX( ScoreByAttribute , [AttributeScore])

 

Cheers,

 

Deniz

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , try a measure like

 

Sumx(summarize(Table, Table[Brand], Table[Category], "_avg", Average(Table[Score])),[_avg])

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , try a measure like

 

Sumx(summarize(Table, Table[Brand], Table[Category], "_avg", Average(Table[Score])),[_avg])

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

Hi Amit, thanks for the response. Unfortunatel this does not provide the solution, as it still shows an average when the measure is thrown into a matrix, i would like for the total shown at the subtotal level to appear at all levels of the row. See below screenshot. Would you be able to help with that? Please see image below

DenizOzerBI_0-1636560256113.png

 

Anonymous
Not applicable

Figured it out:

measuretestcategory = CALCULATE(Sumx(summarize(Table, BrandImageAttributes[BrandId], Table[Category], "_avg", Average(Table[Score])),[_avg]),ALLEXCEPT(Table,Table[Brand]))

I'll mark your solution as solved as it helped me in the right direction! thanks 🙂

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

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.