cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BMltc
Helper I
Helper I

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
Community Champion
Community Champion

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 accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

1 REPLY 1
Jihwan_Kim
Community Champion
Community Champion

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 accept it as the solution to help other members find it faster, and give a big thumbs up.

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

View solution in original post

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Top Solution Authors
Top Kudoed Authors