Forum Discussion
Weighted Average
| A | B | C | D | E |
| 1 | A | o | 1 | 0.8 |
| 2 | A | o | 212 | 0.5 |
| 3 | A | o | 23 | 0.2 |
| 4 | A | o | 45 | 1 |
| 5 | B | o | 343 | 0.3 |
| 6 | B | o | 32 | 0.4 |
| 7 | B | o | 234 | 0.5 |
| 8 | B | o | 213 | 0.6 |
| 9 | C | v | 65 | 0.7 |
| 10 | C | v | 678 | 0.8 |
| 11 | C | v | 564 | 0.6 |
| 12 | A | v | 23 | 0.6 |
| 13 | A | v | 12 | 0.6 |
| 14 | A | v | 32 | 0.6 |
| 15 | A | v | 11 | 0.6 |
| 16 | E | v | 22 | 0.6 |
I have the above table ... I wanted to calculate the weighted avarage by the following and as the report will be
filter by column "C" if its [all]
for A =(1/(1+212+23+45+23+12+32+11+22)*.8)+(212/(1+212+23+45+23+12+32+11+22)*.5) +...etc
if "C" = o
for A =(1/(1+212+23+45)*.8)+(212/(1+212+23+45)*.5) +...etc
and so..
how can I do that in dax
- Anonymous9 years ago
The solution was very easy.. it just needed a littele mathmatics -_-'
A =(1/(1+212+23+45+23+12+32+11+22)*.8)+(212/(1+212+23+45+23+12+32+11+22)*.5) +...etc
==>the rule says
(x/y*w) + (z/y*o) = ((x*w)+(z*o))/y... "y" will be changed dynamicly during any filter... also "x" ,"z", "w" and "o"
==>so our first equ is equevelant to
((1*0.8)+(212*.5)..etc)/(1+212+23+45+23+12+32+11+22)
1-((1*0.8)..(212*.5)..etc) ===> this is a calculated column1 =[D]*[E]
2-((1*0.8)+(212*.5)..etc) ===> this is a measure:=sum([calculated column1])
3-(1+212+23+45+23+12+32+11+22) ===> this is measure2:= sum([D])
4-((1*0.8)+(212*.5)..etc)/(1+212+23+45+23+12+32+11+22) ===> this is measure3:= [measure]/[measure2]
this is it..
2 Replies
- MFelixSuper User
Hi Anonymous,
Add this measure to your model:
Average_Weight = MAX ( 'AVerage'[D] ) / CALCULATE ( SUM ( 'AVerage'[D] ), ALL ( 'AVerage' ) ) * MAX ( 'AVerage'[E] )In order to get the context filter to act in the C column you need to add one new column to your model based on the previous measure:
Average Column = 'AVerage'[Average_Weight]
Then just add it to your table and add the filters:
Regards,
MFelix
- AnonymousNot applicable
The solution was very easy.. it just needed a littele mathmatics -_-'
A =(1/(1+212+23+45+23+12+32+11+22)*.8)+(212/(1+212+23+45+23+12+32+11+22)*.5) +...etc
==>the rule says
(x/y*w) + (z/y*o) = ((x*w)+(z*o))/y... "y" will be changed dynamicly during any filter... also "x" ,"z", "w" and "o"
==>so our first equ is equevelant to
((1*0.8)+(212*.5)..etc)/(1+212+23+45+23+12+32+11+22)
1-((1*0.8)..(212*.5)..etc) ===> this is a calculated column1 =[D]*[E]
2-((1*0.8)+(212*.5)..etc) ===> this is a measure:=sum([calculated column1])
3-(1+212+23+45+23+12+32+11+22) ===> this is measure2:= sum([D])
4-((1*0.8)+(212*.5)..etc)/(1+212+23+45+23+12+32+11+22) ===> this is measure3:= [measure]/[measure2]
this is it..