In situations like these you need to precisely define the rules of when you want to apply the changes and when you don't. For instance the following workflow gives you the output your looking for, but probably not for the reasons that you want.
It adds a subrowID and then uses this to remove the alternate values from the CR and DR columns, to give you this.
The output matches your requirements, but likely won't work with your real data. In order to get something that works in all cases, you need to explicitly write down the rules to transform your input into your outputs for all cases. Your situation probably includes rules like the following and most likely others
- If the previous debit is the same as the current one then 0 the current
- if the next credit is the same as the current then 0 out the current
Without a set of rules, we have no way of knowing what you want to do.