Aug 28 2024 09:31 PM - edited Aug 29 2024 10:10 PM
I have a Table of stocks that I buy & sell. I need a Formula that will subtract my 'Sell Price' from my 'Buy Price' showing me any P/L that occurred once it has been sold (I don't do multiple buys of a stock before finally selling it, however I may do so in the future). Example: I bought TSLA on APR 1st and on MAY 1st I decided that it wasn't for me, so I sold it. I did, however, buy a couple of other stocks within that time frame, so there will be any # of rows in between (this will also occur as I buy & sell stocks in the future). In the Table below it shows when I bought TSLA (Row #5) & sold it (Row #8). I want to show in column 'J' (on the corresponding row of the sale) the value of my P/L when it was sold. I hope that I worded this properly. My knowledge of Excel is on a 'Moderate' level and no Formula (Xlookup, Direct, Match, etc) that I've tried has worked. Thank you very much for any help that you may provide!! (BTW, Column 'A' is left blank intentionally.)
Aug 28 2024 10:25 PM
Aug 29 2024 01:17 AM
Aug 29 2024 02:57 AM
Aug 29 2024 04:53 PM
Aug 29 2024 05:45 PM
Aug 29 2024 10:14 PM
Aug 30 2024 08:22 PM
Aug 31 2024 06:16 AM
SolutionPerhaps
=IF([@UNITS]>0, 0,
IF( [@SYMB]="", "",
SUMPRODUCT(
([@DATE] >= [DATE] )*
([@SYMB] = [SYMB])*
-[UNITS]*
[$/Share]
)
) )
Aug 31 2024 07:37 AM
In addition, if you'd like to deduct possible fees
=IF([@UNITS]>0, 0,
IF( [@SYMB]="", "",
SUMPRODUCT(
([@DATE] >= [DATE] )*
([@SYMB] = [SYMB])*
-[UNITS]*
[$/Share]
) -
SUMPRODUCT(
([@DATE] >= [DATE] )*
([@SYMB] = [SYMB])*
[FEE(S)]
)
) )
and cosmetic, it's better to apply "comma style" format to P/L column
Aug 31 2024 06:16 AM
SolutionPerhaps
=IF([@UNITS]>0, 0,
IF( [@SYMB]="", "",
SUMPRODUCT(
([@DATE] >= [DATE] )*
([@SYMB] = [SYMB])*
-[UNITS]*
[$/Share]
)
) )