Forum Discussion
JeremyCooper
10 years agoNew Member
Calculating the sum of dynamically weighted values
When calculating weighted values for a weighted average, how can we calculate a value which is the sum of those weighted values? In the example below: Total Quantity = SUM(Sheet1[Quantity]) ...
- 10 years ago
JeremyCooper we need to know how your data is set up in the source
Here's another Measure which also worked for me - but again I don't know how your data is set up so... don't know if will work for you
Quantity Weighted Average NEW = IF ( COUNTROWS ( VALUES ( 'Sheet1'[Name] ) ) = 1, [Proportion of Total Selected Quantity] * [Avg X], SUMX ( VALUES ( 'Sheet1'[Name] ), [Proportion of Total Selected Quantity] * [Avg X] ) )See Picture...
Sean
Community Champion
10 years agoJeremyCooper we need to know how your data is set up in the source
Here's another Measure which also worked for me - but again I don't know how your data is set up so... don't know if will work for you
Quantity Weighted Average NEW =
IF (
COUNTROWS ( VALUES ( 'Sheet1'[Name] ) ) = 1,
[Proportion of Total Selected Quantity] * [Avg X],
SUMX (
VALUES ( 'Sheet1'[Name] ),
[Proportion of Total Selected Quantity] * [Avg X]
)
)
See Picture...
JeremyCooper
10 years agoNew Member
This does it, thanks Sean! I've tweaked it for the real data and it's perfect.
The source data for the example at hand looks like this: