cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cosminc Member
Member

Average Weighted on DAX - sumx

Hi all,

i'm struggling with an average, i translate below a similar example:

 
Salesmen  Sales Duration Year  Month
A              10         10         2019    1
A               5           20         2019   2
B               20        3            2019   2   
 
expected results in a table with 2019 selected:
top salesmen
 
Salesmen    Weighted Avg
A                      sumproduct(Sales,Duration)/sum(Duration)=6.6666
B                       20
 
i tried this but doesn't work
Weighted Avg = sumx(source,source[Sales]*source[Duration])/sum(source[Duration])
 
Thanks in advance!
Cosmin
 
      
1 ACCEPTED SOLUTION

Accepted Solutions
Nick_M New Contributor
New Contributor

Re: Average Weighted on DAX - sumx

This should work:

Weighted Sales = 
DIVIDE( 
    SUMX(FactSales, 
            FactSales[Sales] * FactSales[Duration] ), 
    SUM ( FactSales[Duration] )
)

 

4 REPLIES 4
Nick_M New Contributor
New Contributor

Re: Average Weighted on DAX - sumx

This should work:

Weighted Sales = 
DIVIDE( 
    SUMX(FactSales, 
            FactSales[Sales] * FactSales[Duration] ), 
    SUM ( FactSales[Duration] )
)

 

cosminc Member
Member

Re: Average Weighted on DAX - sumx

Hi,

it doesn't work unfortunately

it gives me same value for each Salesmen

Thanks

 

Nick_M New Contributor
New Contributor

Re: Average Weighted on DAX - sumx

Hmm. Looks like it works for me?!

Weighted Avg.png

cosminc Member
Member

Re: Average Weighted on DAX - sumx

it works

my mistake

after 2 hours i realised that i made a column instead of a measure...

Thanks!

Cosmin