Google Sheet Function updated for Excel

dmcmaste

New Member
Joined
Mar 31, 2020
Messages
15
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
I am trying to replicated this Google Sheet in Excel. I can't get the array/filter functionality in Column I, L working correctly in Excel. Can anyone please help replicate/troubleshoot.


For Column I - if it is the first time buying the stock previous units should be 0 otherwise added Transacted Units (Column D) to the previously bought Cumulative Unites (Column J).
Fol Column L - If it is the first time buying the stock it should be 0 otherwise it should be the previous Cumulative Cost (Column O) and added to the new transacted value (Column K)


Thanks!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try removing 'arrayformula' and the corresponding parenthesis from the formula, then array confirm it in excel with Ctrl Shift Enter.
 
Upvote 0
Try removing 'arrayformula' and the corresponding parenthesis from the formula, then array confirm it in excel with Ctrl Shift Enter.


Thanks for your quick reply. I did that and then I got filter highlight and the error: "That function isn't valid" popped up. I think I need to replace that part since INDEX() doesn't like Filter(). Any further suggestions?


1585752920400.png
 
Upvote 0
If you're seeing that then it means that the FILTER function isn't currently supported in your version of excel.

It appears that not all users of office 365 have received the update with the new functions, I'll have look at an alternative method.
 
Upvote 0
It took me a while to figure out what the formula was doing, think this should do what you need.

In I2 and fill down, =IF(B2<>"Deposit", IFERROR(LOOKUP(2,1/(C$1:C1=C2),J$1:J1),0),"")
In L2 and fill down, =IF(B2<>"Deposit", IFERROR(LOOKUP(2,1/(C$1:C1=C2),O$1:O1),0),"")
 
Upvote 0
It took me a while to figure out what the formula was doing, think this should do what you need.

In I2 and fill down, =IF(B2<>"Deposit", IFERROR(LOOKUP(2,1/(C$1:C1=C2),J$1:J1),0),"")
In L2 and fill down, =IF(B2<>"Deposit", IFERROR(LOOKUP(2,1/(C$1:C1=C2),O$1:O1),0),"")


Thanks you so much! Appreciate the help. I think we are in business.
 
Upvote 0
Thanks you so much! Appreciate the help. I think we are in business.

I have one more request. Could you help me add R2, S2 and T2 formulas? Basically I want to do what I'm doing in O2, P2, Q2 to get cumulative Gain/Loss grouped by company instead of since buy and sell period. In this example I want to see AAPL's overall gains/loss between the 2 sell periods.

Book1
ABCDEFGHIJKLMNOPQRST
1DateTypeStockTransacted UnitsTransacted Price (per unit)Avg. PriceFeesStock Split RatioPrevious UnitsCumulative UnitsTransacted ValuePrevious CostCost of TransactionCost of Transaction (per unit)Cumulative CostGains/Losses from SaleRealised Gains/Losses %Cumulative Cost by TickerGains/Losses from Sale by TickerRealised Gains/Losses % by Ticker
212/10/2018DepositCASH1159,570.56-01      Error0 
312/31/2018InterestCASH166.84-01      Error0 
41/15/2019BuyAXP5090900105045000--45000 
51/16/2019BuyAAPL351501500103552500--52500 
61/17/2019BuyAXP1003050015015030004500--75000 
72/14/2019SellAAPL35170-01350595052505250150070013%
82/19/2019BuyAAPL101001000101010000--10000 
92/20/2019BuyAAPL209093.3301103018001000--28000 
103/2/2020SellAAPL30230-0130069002800280093.3333333304100146%
Sheet2
Cell Formulas
RangeFormula
I2:I10I2=IF((AND(B2<>"Deposit", B2<>"Interest", B2<>"DIV")), IFERROR(LOOKUP(2,1/(C$1:C1=C2),J$1:J1),0),"")
J2:J10J2=IF((AND(B2<>"Deposit", B2<>"Interest", B2<>"DIV")),IF(B2="Buy",I2+D2,IF(B2="Sell",I2-D2,IF(OR(B2="Div",B2="Fee"),I2,IF(B2="Split",I2*H2,0)))),"")
K2:K10K2=IF((AND(B2<>"Deposit", B2<>"Interest", B2<>"DIV")), IF(B2="Buy",E2*D2+G2,IF(B2="Sell",E2*D2-G2,E2*D2-G2)), "")
L2:L10L2=IF((AND(B2<>"Deposit", B2<>"Interest", B2<>"DIV")),IFERROR(LOOKUP(2,1/(C$1:C1=C2),O$1:O1),0),"")
M2:M10M2=IF((AND(B2<>"Deposit", B2<>"Interest", B2<>"DIV")),IF(B2="Sell",IF(I2=0,0,D2/I2*L2),"-"),"")
N2:N10N2=IF((AND(B2<>"Deposit", B2<>"Interest", B2<>"DIV")),IF(B2="Sell",IF(I2=0,0,L2/I2),"-"),"")
O2:O10O2=IF(B2="Buy",L2+K2,IF(OR(B2="Div",B2="Fee"),L2,IF(B2="Sell",IF(L2<=0,"Error.No Previous units.",L2-M2),IF(B2="Split",L2,"Error"))))
P2:P10P2=IF(B2="Sell",K2-M2,IF(OR(B2="Div",B2="Fee"),K2,0))
Q2:Q10Q2=IF(B2="Sell",(K2-M2)/M2,"")
 
Upvote 0
Would you be able to manually calculate the results for your example then enter them into the sheet so that I have something to aim at?
To someone who deals with stock investment all day is is probably quite obvious, to me not so much.
 
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,674
Members
448,977
Latest member
moonlight6

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top