Formula to Number Multi-Part Transactions and Re-Start Count Each Day

turn7or5

New Member
Joined
Aug 21, 2024
Messages
12
Office Version
  1. 2021
Platform
  1. MacOS
Can anyone provide a formula to do this? Your help is greatly appreciated.

Each transaction has multiple buy and sells and each needs the same count number to show it is all the same transaction. Example: Rows 21-24 are all one transaction so each row has same number of 8.

Each time Qnty (Clmn F) sums to zero a transaction is completed. Shown in helper column K.

When the date changes (Clmn B Row 52) the count needs to start at 1 again.

Column A has no formula, just a model to show what desired result looks like.

Basic idea is identify and assign a number to each transaction and start new at 1 the next day.

It seemed simple but I cant solve it.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Welcome to the MrExcel board!

Try:

Book1
ABC
1IndexDateQty
29/29/2022
319/29/20223
419/29/2022-3
529/29/20223
629/29/2022-3
739/29/20223
839/29/2022-3
949/29/20223
1049/29/2022-3
1159/29/20223
1259/29/2022-3
1369/29/20223
1469/29/20223
1569/29/2022-3
1669/29/2022-3
1779/29/20223
1879/29/20223
1979/29/2022-3
2079/29/2022-3
2189/29/20223
2289/29/20223
2389/29/2022-3
2489/29/2022-3
2599/29/20221
2699/29/2022-1
27109/29/20221
28109/29/2022-1
29119/29/20222
30119/29/2022-2
31129/29/20221
32129/29/20221
33129/29/2022-1
34129/29/2022-1
35139/29/20221
36139/29/2022-1
37149/29/20221
38149/29/2022-1
39159/29/20221
40159/29/2022-1
41169/29/20221
42169/29/2022-1
43179/29/20221
44179/29/20221
45179/29/2022-1
46179/29/2022-1
47189/29/20221
48189/29/2022-1
49199/29/20221
50199/29/20221
51199/29/2022-2
5216/21/20231
5316/21/20231
5416/21/20231
5516/21/2023-1
5616/21/2023-1
5716/21/2023-1
Sheet1
Cell Formulas
RangeFormula
A3:A57A3=IF(B2<>B3,1,IF(SUM(C$2:C2)=0,A2+1,A2))
 
Upvote 0



Just discovered a case in which formula in Column A returns unwanted results. The data used initially did not have this feature.
It happens when a new transaction starts before the current one is completed.
See rows 62-115 for example. (LEFT table is current and RIGHT table is desired result)
Six units of Onions are sold at F62-63 and not resolved until F113-F115. All nine transactions in between are counted as the same, with a number 4.
The formula I think looks for the Qnty Column to sum to zero to move onto the next count.

I tried to fix it by including the Item column so Qnty would exclude non-matching items when summing Qnty Column.
I also tried to make it count properly if a transaction was left unresolved until a later day. Attempted formulas did not work.

There is no formula in Column N. Its just a model to show desired result.

Im hoping the formula might be modified to solve this or some other solution.

The first solution will be re-checked once this is resolved because it was correct for initial data.
 
Upvote 0
This requires a much different approach. Try:

Book1
ABCDE
1
2Transaction NumberDateTimeItemQty
313/1/2023Banana2
413/1/2023Banana-2
523/1/2023Onion-3
623/1/2023Onion-3
733/1/2023Leek20
833/1/2023Leek10
933/1/2023Leek-10
1033/1/2023Leek-10
1133/1/2023Leek-10
1243/1/2023Leek8
1343/1/2023Leek-8
1453/1/2023Vinegar4
1553/1/2023Vinegar4
1653/1/2023Vinegar4
1753/1/2023Vinegar4
1853/1/2023Vinegar8
1953/1/2023Vinegar8
2053/1/2023Vinegar-8
2153/1/2023Vinegar-8
2253/1/2023Vinegar-8
2353/1/2023Vinegar-8
2463/1/2023Melon5
2563/1/2023Melon5
2663/1/2023Melon-5
2763/1/2023Melon-5
2873/1/2023Melon5
2973/1/2023Melon-5
3083/1/2023Melon5
3183/1/2023Melon5
3283/1/2023Melon5
3383/1/2023Melon-5
3483/1/2023Melon-5
3583/1/2023Melon-5
3693/1/2023Bread20
3793/1/2023Bread20
3893/1/2023Bread20
3993/1/2023Bread20
4093/1/2023Bread-20
4193/1/2023Bread-20
4293/1/2023Bread-20
4393/1/2023Bread-20
44103/1/2023Olive5
45103/1/2023Olive5
46103/1/2023Olive-5
47103/1/2023Olive-5
48113/1/2023Peach10
49113/1/2023Peach10
50113/1/2023Peach10
51113/1/2023Peach10
52113/1/2023Peach-10
53113/1/2023Peach-10
54113/1/2023Peach-10
55113/1/2023Peach-10
5623/1/2023Onion2
5723/1/2023Onion2
5823/1/2023Onion2
59123/1/2023Onion2
60123/1/2023Onion-2
61133/1/2023Banana1
62133/1/2023Banana-1
6313/2/2023Grapes-2
6413/2/2023Grapes2
6523/2/2023Olives3
6623/2/2023Olives-3
671
681
Sheet1
Cell Formulas
RangeFormula
A3:A68A3=IF(B2<>B3,1,IF(SUMIFS($E$2:$E2,$D$2:$D2,D3)=0,MAXIFS($A$2:$A2,$B$2:$B2,">="&B3)+1,XLOOKUP(D3,$D$2:$D2,$A$2:$A2,1/0,0,-1)))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A3:E66Expression=MOD(SUM(--($A$2:$A2<>$A$3:$A3)),2)textNO


I noticed that you also mentioned the possibility that a transaction might not be concluded until the next day. This would be problematic. Consider if transaction 1, onions, did not finish on 3/1, then you started 3/2 with another transaction, olives, which is assigned 1, then finished onions. You can't reuse 1, things would get very messy. I've got some ideas, but let me know what you think.

Also, please look into getting the xl2bb add-in. It's what I used to display my suggestions. It makes it MUCH easier to work on your problem, since I can copy the data directly without having to manually retype everything. See the link in my signature or the reply box.
 
Upvote 0
Solution
Thank you for your quick response. The formula works :)

I set aside the issue of transactions open beyond same day. It appears to be a very rare occurance and one of little consequence. A manual adjustment of the stray bit's date/time to the day of initiation will probably be okay. Should conditions change I would be glad to hear your ideas.

I will look at the tool you recommend although there are limitations with adding software to this machine. I'll certainly do what i can as this spreadsheet may be more complex than anticipated.
 
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,126
Members
453,021
Latest member
Justyna P

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