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! 🙂
littlemojopuppy
5 years agoCommunity Champion
Hi Anonymous can you provide some sample data to work with?
- Anonymous5 years agoNot applicable
Hi, littlemojopuppy, thanks for replying.
Product Time PROD1 43,8 PROD1 38,9 PROD1 40,4 PROD1 30,2 PROD2 38,3 PROD2 28,7 PROD2 36,3 PROD3 27,5 PROD3 28,4 PROD4 36,6 PROD4 37,9 PROD5 39,8 PROD6 40,5 PROD6 36,7 PROD7 37,3 PROD7 23,8 PROD8 37,2 PROD9 32,5 PROD9 32,1 PROD9 43,9 I hope it helps. Each category weight is the % of the ocorrences
Thanks again!
- littlemojopuppy5 years agoCommunity Champion
Anonymous one more question: how is the weighing calculated? I'm assuming
(product total count) * (product time) / (total product count)- littlemojopuppy5 years agoCommunity Champion
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! 🙂
- Ashish_Mathur5 years agoSuper User
Hi,
Try these measures:
Total time = SUM(Data[Time])Product count = COUNTROWS(Data)Measure 2 = SUMX(VALUES(Data[Product]),[Total time]*[Product count])/[Product count]Hope this helps.- littlemojopuppy5 years agoCommunity Champion
Ashish_Mathur not only did I offer a solution five hours ago, someone else offered essentially the same solution three hours ago. Your input was warranted?