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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
BMltc
Helper II
Helper II

weighted average at the subgroup & group level while keeping the value at the row level

Hi team,

 

I have a dataset like this

CategorySub CategoryWeightValue
AA10,25
AA20,13
BB10,32
BB20,14
BB30,35

 

and i want to create a matrix with categories & sub categories and with the weighted average while keeping the value at the row level as seen in the "desired output" column

CategorySub CategoryWeightValueWeight x ValueDesired output
A    4,33
 A10,2515
 A20,130,33
B    3,57
 B10,320,62
 B20,140,44
 B30,351,55
TOTAL    3,8

 

with 4.33 = (3*0.1+5*0.2)/(0.1+0.2)

 

many thanks

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @BMltc 

Please check the below picture and the sample pbix file's link down below.

 

Picture1.png

 

Desired Output measure =
IF (
ISINSCOPE ( 'Table'[Sub Category] ),
SUMX ( 'Table', 'Table'[Value] ),
CALCULATE (
SUMX ( 'Table', 'Table'[Weight] * 'Table'[Value] ),
ALLEXCEPT ( 'Table', 'Table'[Category] )
)
/ CALCULATE (
SUMX ( 'Table', 'Table'[Weight] ),
ALLEXCEPT ( 'Table', 'Table'[Category] )
)
)

 

 

https://www.dropbox.com/s/o2flu2oirbhk9d7/bmltc.pbix?dl=0 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi, @BMltc 

Please check the below picture and the sample pbix file's link down below.

 

Picture1.png

 

Desired Output measure =
IF (
ISINSCOPE ( 'Table'[Sub Category] ),
SUMX ( 'Table', 'Table'[Value] ),
CALCULATE (
SUMX ( 'Table', 'Table'[Weight] * 'Table'[Value] ),
ALLEXCEPT ( 'Table', 'Table'[Category] )
)
/ CALCULATE (
SUMX ( 'Table', 'Table'[Weight] ),
ALLEXCEPT ( 'Table', 'Table'[Category] )
)
)

 

 

https://www.dropbox.com/s/o2flu2oirbhk9d7/bmltc.pbix?dl=0 

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.