Forum Discussion
Anonymous
5 years agoNot applicable
Weighted Average Calculation
Hey guys! I'm trying to formulate an weighted average for a product data. I have 4k rows of differents IDs divided by 9 categories (prod1 to prod9), each one with a value of time. I need an weighte...
- 5 years ago
I'm working with my assumption and came up with this...
Weighted Average Product Time = VAR AllProducts = CALCULATETABLE( VALUES(Products[Product]), ALL(Products) ) VAR TotalProductCount = CALCULATE( [Product Count], ALL(Products) ) RETURN DIVIDE( SUMX( AllProducts, [Product Count] * [Total Product Time] ), TotalProductCount, BLANK() )Here's the results
Hope this helps! 🙂
CNENFRNL
5 years agoCommunity Champion
Anonymous , I assume the logic of desired weighted average is like this
(total time of each product) * (occurrence of each product)/(total count of all products)
take Product1 for example:
(43.8+38.9+40.4+30.2)*(4/20)Weighted Avg =
VAR __t = COUNTROWS ( Table1 )
RETURN
SUMX (
DISTINCT ( Table1[Product] ),
CALCULATE ( SUM ( Table1[Time] ) * COUNTROWS ( Table1 ) ) / __t
)
btw, Excel array formula, our oldie but goodie, does the trick with ease,
=SUMPRODUCT(Table1[Time], COUNTIF(Table1[Product],Table1[Product]))/ROWS(Table1)
littlemojopuppy
5 years agoCommunity Champion
CNENFRNL Didn't I offer a similar solution hours ago???