How to calculate the average load value in an investment tracker?
Hello!
I want to create a portfolio for investment tracking purposes. I want it to be divided in two sheets: a ledger, or transaction log, and a dashboard. In the Ledger sheet, I would manually insert data as shown below (apologies for the absence of screenshot but reddit is giving me an "All media assets must be owned by the submitter of this post" error).
| Date | Time | Ticker | Operation | Qty | Price | Load value | Taxation |
|---|---|---|---|---|---|---|---|
| 15/03/2026 | 15:00:00 | AAPL | Buy | 10 | 250€ | 2500€ | 26% |
| 15/03/2026 | 16:00:00 | AAPL | Sell | 2 | 280€ | 560€ | 26% |
| 15/03/2026 | 17:00:00 | AAPL | Buy | 2 | 240€ | 480€ | 26% |
The only calculated value in this sheet is the Load value, which I calculate as Qty * Price. This table will include any transactions, not just those relative to AAPL. I just picked this one to make my example. Shown values are also examples.
Then, in the Dashboard sheet, I would like to track information such as unrealized P&L and the taxes I would have to pay if I were to sell the whole position, for all the open positions. Here, column B is filled automatically with UNIQUE(Transactions[Ticker]), where Transactions is the table from the previous sheet.
| Ticker | Qty | Average Load Value |
|---|---|---|
| AAPL | 10 | ????? |
| OtherTicker | OtherQty | ????? |
Due to my country's laws (I live in Europe), capital gain taxes are calculated on the average load price, which itself is calculated as the weighted average of the prices of open positions, with the quantities as weights. In the specific example below, I simulated some buy and sell operations, and the average load price after those would be (8 * 250 + 2 * 240) / (8 + 2) = 248.
I have looked for the First-In-First-Out method but couldn't understand it. It also was applied to inventory contexts so I don't know whether it is applicable here.
Could any of you please help me in constructing a formula to do so? Reproducing this scenario shouldn't be an issue but if it is, please ask me any relevant question :)
Edit: I am using Excel for Office 365 (Version 2602) on my Desktop computer and I am a beginner. I would prefer a formula solution but I understand it could get messy so a Macro/VBS solution would be fine as well.
[link] [comments]
Want to read more?
Check out the full article on the original site