Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Weight Average

Hello,   I'm looking to get help with a formula that will get me the weighted average based off a set of paramters. I would like the formula to take the sum of spend per material number and divide ...
  • fhill's avatar
    fhill
    5 years ago

    This the DateAdd (-1 Year) option instead of the DATE command.....   (Sorry for the change in TABLE name and columns in the version below vs. my original post.)  But you only have to change the FILTER Portion to use DATEADD vs. DATE(Y)(M)(D)

     

    1_Year_Avg_Spend = CALCULATE( SUM( 'Table'[USD Spend]) / SUM('Table'[Qty]), FILTER( 'Table', 'Table'[Document Date] > DATEADD('Table'[Document Date], -1, YEAR)))
  • fhill's avatar
    fhill
    5 years ago

    Try this....

    Last_Pur_Price = CALCULATE( AVERAGE( 'Table'[Part Price]), FILTER('Table', 'Table'[Document Date] = [Last_Pur_Date]))
     
    If you had multiple sales on the same day, assuming you want the average of the two?