Forum Discussion
Calculation of weighted average by multiple groups
- 8 years ago
You just need to use measure below.
Measure = DIVIDE ( SUMX ( Table1, Table1[count] * Table1[price] ), SUMX ( Table1, Table1[count] ) )
You just need to use measure below.
Measure =
DIVIDE (
SUMX ( Table1, Table1[count] * Table1[price] ),
SUMX ( Table1, Table1[count] )
)
- Mercator_19808 years agoFrequent Visitor
Thank you - this is working and giving me a weighted average by multiple groups. Manual calculations are identical to those of power bi.
But i truly have problems understanding the functionality of measures and the formula.
It is unclear to me, how the measure observes the different groups in its calculation! I understand, that the measure will be influenced by the Filters i am using like date, item and so on. But there must be some interconnection with the SUMX-command.
The tooltip to SUMX states:
"Returns the sum of an expression evaluated for each row in a table"
Is ist therefore correct to say that the measure calculates the number (Sum) of identical rows (identical item, dates and so on) per each individual combination of all rows taken into consideration? By this we get the sum of occurences per combinationen. This is what SUMX ( Table1, Table1[count] ) is about. The Dividision of SUMX ( Table1, Table1[count] * Table1[price] ) by SUMX ( Table1, Table1[count] ) is therefore also done for each individual combination of grouping combinations.
That still leaves me with not understanding, how the Measure is knowing to calculate (sum up) the overall weighted average.
Where does my brain break?
- syedallam6 years agoNew Member
Hi,
I tried your solution and I am able to get the data over a table value. Now, what I am trying to do is, us this weighted average to show as line series. For eg., I have total trades (buy and sell) for multiple currencies (USD, GBP, EUR) and for each month (APR, MAY, JUN). I have used measure to calculate weighted average rate of these 3 categories. I want to create a Line and clustered column chart with the values shown along with the measure value as a line value. When I try doing it, it show the average or total of the measure value.
Please help me out.