Originally Posted by
oldman
My tables are absolutely as simple as I can make them. I really do understand Access at a gut level and know that complexity means problems in the long run. Here is the field structure that I work with.
Stock ID......... Number of shares..........total cost.........cost per share.......... There are other fields that really don't enter into my question like the cost of the broker transaction like the $7 per transaction that Scottrade advertises all the time.
what is the weight factor? number of shares I assume? (there really isn't anything else to consider).
say you have a table called "stockTrans" and the fields called "sharesNo" and "sharesCostPer". In this scenario, the weighted average Cost per share could be calculated in a query as:
Code:
SELECT SUM([sharesCostPer] * [sharesNo]) / SUM([sharesNo]
AS WeightedAvg
Alternatively, a weighted avg of transaction cost might be:
Code:
SELECT SUM([sharesCostPer] * [totalCost]) / SUM([totalCost]
AS WeightedAvg
I'm not sure about the accuracy of the last one because totals are not normally the factors in weighted avg's. But it does follow the same concept!