Hi, you are absolute right: my portfolio changes over time. I'm actually starting my calculations from transactions table, which structure is
[TABLE="width: 498"]
<tbody>[TR]
[TD][TABLE="width: 745"]
<tbody>[TR]
[TD]
-- removed inline image ---
Then I calculate previous rows and next rows, previous units and units for each row:[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TABLE="width: 745"]
<colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD]Date[/TD]
[TD]Type[/TD]
[TD]Broker[/TD]
[TD]Asset[/TD]
[TD]Currency[/TD]
[TD]in EUR[/TD]
[TD]Transacted Units[/TD]
[TD]Transacted Price (per unit)[/TD]
[TD]Fees[/TD]
[TD]Stock Split Ratio[/TD]
[TD]B&A[/TD]
[TD]Prev Row[/TD]
[TD]Next Row[/TD]
[TD]Previous Units[/TD]
[TD]Units[/TD]
[/TR]
[TR]
[TD]21.4.2006[/TD]
[TD]Buy[/TD]
[TD]Nordea[/TD]
[TD]NOKIA[/TD]
[TD]EUR[/TD]
[TD]1[/TD]
[TD]100,0[/TD]
[TD]18,380[/TD]
[TD="align: right"]2,00[/TD]
[TD]1,0[/TD]
[TD]NordeaNOKIA[/TD]
[TD]0[/TD]
[TD]4[/TD]
[TD]0,0[/TD]
[TD]100,00[/TD]
[/TR]
[TR]
[TD]2.1.2007[/TD]
[TD]Buy[/TD]
[TD]Nordnet[/TD]
[TD]MSFT[/TD]
[TD]USD[/TD]
[TD]0,9[/TD]
[TD]20,00[/TD]
[TD]20,000[/TD]
[TD="align: right"]2,00[/TD]
[TD]1,0[/TD]
[TD]NordnetMSFT[/TD]
[TD]0[/TD]
[TD]5[/TD]
[TD]0,0[/TD]
[TD]20,00[/TD]
[/TR]
[TR]
[TD]28.2.2007[/TD]
[TD]Sell[/TD]
[TD]Nordea[/TD]
[TD]NOKIA[/TD]
[TD]EUR[/TD]
[TD]1[/TD]
[TD]26,00[/TD]
[TD]12,350[/TD]
[TD="align: right"]2,00[/TD]
[TD]1,0[/TD]
[TD]NordeaNOKIA[/TD]
[TD]2[/TD]
[TD]7[/TD]
[TD]100,0[/TD]
[TD]74,00[/TD]
[/TR]
[TR]
[TD]5.3.2007[/TD]
[TD]Sell[/TD]
[TD]Nordnet[/TD]
[TD]MSFT[/TD]
[TD]USD[/TD]
[TD]0,9[/TD]
[TD]12,00[/TD]
[TD]7,060[/TD]
[TD="align: right"]2,00[/TD]
[TD]1,0[/TD]
[TD]NordnetMSFT[/TD]
[TD]3[/TD]
[TD]10[/TD]
[TD]20,0[/TD]
[TD]8,00[/TD]
[/TR]
[TR]
[TD]14.3.2007[/TD]
[TD]Buy[/TD]
[TD]Nordnet[/TD]
[TD]KO[/TD]
[TD]EUR[/TD]
[TD]0,95[/TD]
[TD]28,00[/TD]
[TD]5,400[/TD]
[TD="align: right"]2,00[/TD]
[TD]1,0[/TD]
[TD]NordnetKO[/TD]
[TD]0[/TD]
[TD]8[/TD]
[TD]0,0[/TD]
[TD]28,00[/TD]
[/TR]
[TR]
[TD]14.3.2007[/TD]
[TD]Sell[/TD]
[TD]Nordea[/TD]
[TD]NOKIA[/TD]
[TD]EUR[/TD]
[TD]1[/TD]
[TD]50,00[/TD]
[TD]10,010[/TD]
[TD="align: right"]2,00[/TD]
[TD]1,0[/TD]
[TD]NordeaNOKIA[/TD]
[TD]4[/TD]
[TD]11[/TD]
[TD]74,0[/TD]
[TD]24,00[/TD]
[/TR]
[TR]
[TD]6.7.2007[/TD]
[TD]Buy[/TD]
[TD]Nordnet[/TD]
[TD]KO[/TD]
[TD]USD[/TD]
[TD]0,9[/TD]
[TD]2,00[/TD]
[TD]40,000[/TD]
[TD="align: right"]4,00[/TD]
[TD]1,0[/TD]
[TD]NordnetKO[/TD]
[TD]6[/TD]
[TD]12[/TD]
[TD]28,0[/TD]
[TD]30,00[/TD]
[/TR]
[TR]
[TD]9.7.2007[/TD]
[TD]Buy[/TD]
[TD]Nordnet[/TD]
[TD]CCF[/TD]
[TD]EUR[/TD]
[TD]1[/TD]
[TD]3,00[/TD]
[TD]380,000[/TD]
[TD="align: right"]4,00[/TD]
[TD]1,0[/TD]
[TD]NordnetCCF[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD]0,0[/TD]
[TD]3,00[/TD]
[/TR]
[TR]
[TD]9.7.2007[/TD]
[TD]Sell[/TD]
[TD]Nordnet[/TD]
[TD]MSFT[/TD]
[TD]USD[/TD]
[TD]0,9[/TD]
[TD]8,00[/TD]
[TD]5,000[/TD]
[TD="align: right"]2,00[/TD]
[TD]1,0[/TD]
[TD]NordnetMSFT[/TD]
[TD]5[/TD]
[TD]0[/TD]
[TD]8,0[/TD]
[TD]0,00[/TD]
[/TR]
[TR]
[TD]9.7.2007[/TD]
[TD]Sell[/TD]
[TD]Nordea[/TD]
[TD]NOKIA[/TD]
[TD]EUR[/TD]
[TD]1[/TD]
[TD]24,00[/TD]
[TD]14,000[/TD]
[TD="align: right"]2,00[/TD]
[TD]1,0[/TD]
[TD]NordeaNOKIA[/TD]
[TD]7[/TD]
[TD]0[/TD]
[TD]24,0[/TD]
[TD]0,00[/TD]
[/TR]
[TR]
[TD]9.7.2007[/TD]
[TD]Sell[/TD]
[TD]Nordnet[/TD]
[TD]KO[/TD]
[TD]USD[/TD]
[TD]0,9[/TD]
[TD]29,00[/TD]
[TD]42,000[/TD]
[TD="align: right"]2,00[/TD]
[TD]1,0[/TD]
[TD]NordnetKO[/TD]
[TD]8[/TD]
[TD]0[/TD]
[TD]30,0[/TD]
[TD]1,00[/TD]
[/TR]
</tbody>[/TABLE]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
-- removed inline image ---
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Using tTranscation table I calculate
# of units owned at each day
INDEX(tTransactions[Units];
N(IF(1; LARGE(IF(
((tTransactions[Date]<=$A2) * (tTransactions[Units]>0) * ((tTransactions[Next Row]=0) + (tTransactions[Next Row] > MAX(IF(tTransactions[Date]<=$A2; ROW(tTransactions[Date]))))) * ROW(tTransactions[B&A]))
>0;
((tTransactions[Date]<=$A2) * (tTransactions[Units]>0) * ((tTransactions[Next Row]=0) + (tTransactions[Next Row] > MAX(IF(tTransactions[Date]<=$A2; ROW(tTransactions[Date]))))) * ROW(tTransactions[B&A]))
); ROW($A$1:INDIRECT("A"&SUM(IF(
((tTransactions[Date]<=$A2) * (tTransactions[Units]>0) * ((tTransactions[Next Row]=0) + (tTransactions[Next Row] > MAX(IF(tTransactions[Date]<=$A2; ROW(tTransactions[Date]))))) * ROW(tTransactions[B&A]))
<>0;1;0))))) ))-1; 1);
e.g. for shares owned {"NOKIA";"KO";"MSFT"} on 2nd of July it gives me {24;28;8}
Then I calculate
prices (using my old formula)
SUMIFS(HistoricalQuotes[Price];HistoricalQuotes[Date];"="&$A2; HistoricalQuotes[Ticker]; T(IF(1;
INDEX(tTransactions[Asset];
N(IF(1; LARGE(IF(
((tTransactions[Date]<=$A2) * (tTransactions[Units]>0) * ((tTransactions[Next Row]=0) + (tTransactions[Next Row] > MAX(IF(tTransactions[Date]<=$A2; ROW(tTransactions[Date]))))) * ROW(tTransactions[B&A]))
>0;
((tTransactions[Date]<=$A2) * (tTransactions[Units]>0) * ((tTransactions[Next Row]=0) + (tTransactions[Next Row] > MAX(IF(tTransactions[Date]<=$A2; ROW(tTransactions[Date]))))) * ROW(tTransactions[B&A]))
); ROW($A$1:INDIRECT("A"&SUM(IF(
((tTransactions[Date]<=$A2) * (tTransactions[Units]>0) * ((tTransactions[Next Row]=0) + (tTransactions[Next Row] > MAX(IF(tTransactions[Date]<=$A2; ROW(tTransactions[Date]))))) * ROW(tTransactions[B&A]))
<>0;1;0))))) ))-1; 1)
)) );
I get for {"NOKIA";"KO";"MSFT"} on 2nd of July {202,07;102,07;302,07}
Additionally I also calculate
exchange rates, as I have shares in multiple currencies, but in my sample file I have marked all currency rates ones, to keep sample simple.
To get a portfolio value on a date I use SUMPRODUCT(units, prices, forexrates). I works as long there are prices for all shares on needed day.
You can find my sample file from here:
https://1drv.ms/x/s!AtMqEk6YiyvupbVM_Oq4To8_ilvutA
I wish that I could do portfolio calculation without any additional tables. I wonder if its feasible.
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]