It is easiest of you sort your data first by transactionbegdtm to make sure the ordering is "correct", then you might be able to use something like
Col Cumulative Sum(1, :SerialNo, :LotNo))
Also if there can only be either 1 or 2 as test order, you can use something like
If(:TransactionBegDtm == Col Min(:TransactionBegDtm, :SerialNo, :LotNo),
1
, 2
)
-Jarmo