I thought it best to post this separately but is a continuation of Calculate # repurchases within 30 days of last sale
In the source trade table shown on the left below, the "Rebuys within 30 days" column tallies each time a stock has been re-bought within 30 days of a previous sale of that same stock. The summary table then sums all these up in "# Rebuys within 30 days" column
This works perfectly and a big thanks to Peter_SSs and shaowu459 for providing me with the solution for this in previous post.
I've tried to tweak the "Rebuys within 30 days" formula to tally all buy trades of a stock done on the same day as a sale of that same stock, putting this in the "Rebuys on same day" helper column. I know it's not quite correct as it should be showing a "1" in the row for the buy of MSFT on 11/12/2021. Hoping someone might know how to tweak this further to get the helper column to tally correctly.
In the source trade table shown on the left below, the "Rebuys within 30 days" column tallies each time a stock has been re-bought within 30 days of a previous sale of that same stock. The summary table then sums all these up in "# Rebuys within 30 days" column
This works perfectly and a big thanks to Peter_SSs and shaowu459 for providing me with the solution for this in previous post.
I've tried to tweak the "Rebuys within 30 days" formula to tally all buy trades of a stock done on the same day as a sale of that same stock, putting this in the "Rebuys on same day" helper column. I know it's not quite correct as it should be showing a "1" in the row for the buy of MSFT on 11/12/2021. Hoping someone might know how to tweak this further to get the helper column to tally correctly.
Stock Repurchases.xlsx | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | |||
1 | ||||||||||||
2 | Trade Execution Time | Order Type | Stock | Rebuys on same day | Rebuys within 30 days | Stock | # Same-day Rebuys | # Rebuys within 30 days | ||||
3 | 03/06/2021 | Buy | APPL | APPL | 0 | 2 | ||||||
4 | 07/06/2021 | Buy | APPL | MSFT | 0 | 4 | ||||||
5 | 14/06/2021 | Buy | MSFT | |||||||||
6 | 15/06/2021 | Buy | APPL | |||||||||
7 | 22/06/2021 | Buy | MSFT | |||||||||
8 | 10/07/2021 | Sell | APPL | |||||||||
9 | 16/07/2021 | Buy | APPL | 1 | ||||||||
10 | 22/07/2021 | Buy | APPL | 1 | ||||||||
11 | 23/07/2021 | Sell | MSFT | |||||||||
12 | 26/07/2021 | Buy | MSFT | 1 | ||||||||
13 | 05/11/2021 | Buy | MSFT | |||||||||
14 | 06/12/2021 | Sell | MSFT | |||||||||
15 | 10/12/2021 | Buy | MSFT | 1 | ||||||||
16 | 11/12/2021 | Sell | MSFT | |||||||||
17 | 11/12/2021 | Buy | MSFT | 1 | ||||||||
18 | 10/01/2022 | Buy | MSFT | 1 | ||||||||
Sheet2 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
E3:E18 | E3 | =LET(tet,[Trade Execution Time],ctet,[@[Trade Execution Time]],IF([@[Order Type]]="Buy",IF(ctet-IFERROR(AGGREGATE(14,6,tet/((tet<ctet)*([Stock]=[@Stock])*([Order Type]="Sell")),1),0)<=1,1,""),"")) |
F3:F18 | F3 | =LET(tet,[Trade Execution Time],ctet,[@[Trade Execution Time]],IF([@[Order Type]]="Buy",IF(ctet-IFERROR(AGGREGATE(14,6,tet/((tet<ctet)*([Stock]=[@Stock])*([Order Type]="Sell")),1),0)<=30,1,""),"")) |
I3:I4 | I3 | =SUMIF(tblTradeOrders[Stock],[@Stock],tblTradeOrders[Rebuys on same day]) |
J3:J4 | J3 | =SUMIF(tblTradeOrders[Stock],[@Stock],tblTradeOrders[Rebuys within 30 days]) |
Last edited: