Forum Discussion
Weight Average
- 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))) - 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?
Since you will want the Last Purchase Date, and we'll use it minus 1 year in the CAL formula, start with that as it's own measure:
Hello fhill
That first formula worked like a charm.
I'm looking for the second option you provided for the average. I'm getting a error with the formula though. Any ideas?
- fhill5 years agoResident Rockstar
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)))- Anonymous5 years agoNot applicable
You my friend, a genius! Thank you! What a journey haha.
One last thing... is it possible to turn that first formula you did into telling me what the price was on that date?
Orginal formula =
CALCULATE(LASTDATE(tbReceivalHistory[Document Date]),FILTER(ALLEXCEPT(tbReceivalHistory,tbReceivalHistory[Part Number (Material)]),1=1))I want this to tell me the piece price on that date it's finding.- fhill5 years agoResident Rockstar
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?