Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Weighted average using measures?

I have this data:

 

I am trying to get a weighted average, per LL.

 

That shall be the sum of: TotalPerCustomer * MDMCustomer / Total.

 

(The code for MDMCustomer is   [TotalPerCustomer]/[MaxCustomer])

 

So for L1 it shall be: (50*1 + 35*1,4)  /85       //(Whenever I try to do it, I get 35*1,4 twice)

And for L2 it shall be:  (35*1,75) / 35

 

How can I achieve it? 

 

 

 

1 Reply

  • Anonymous 

    You can create the following measure to calculate the weighted average:

    M = 
    var __t =    
        CALCULATETABLE( SUMMARIZE(Table3,Table3[LL],Table3[CUST], "Total", MAX(Table3[Total Per Customer]),"MDS", MAX(Table3[MDS Customer])), ALLEXCEPT(Table3,Table3[LL] ))
    
    var __Total = SUMX( __t , [Total] )     
    var __line = SUMX( __t , [Total] * [MDS] )  
    return
    DIVIDE( __line , __Total )