I need help on a problem I have. I have a list with several fields including contract, installment and amount.
I need to create a new list based on these fields, including all the others, of course.
So, for every contract with two installments, I need to sum the amounts into the first installment, while maintaining the second one.
You have an example below.
Is this possible?
...contract instalment amount ...
...1 1 100 ...
...1 2 1000 ...
...2 1 100 ...
...3 1 1000 ...
...4 1 200 ...
...4 2 100 ...
...5 1 1000 ...
...contract instalment amount ...
...1 1 1100 ...
...1 2 1000 ...
...2 1 100 ...
...3 1 1000 ...
...4 1 300 ...
...4 2 100 ...
...5 1 1000 ...
I think you want:
Note that in your sample, you only handle cases where groups contain one or two items, but the above code will also work for three or more items in a group by aggregating the first item from all the others.
EDIT:
Since you want to mutate the first record in each group rather than create a new one, I would do: