Assuming group 4 is the distinctly selected group, it should work with a running total. Set the Summary
field to the field you are totaling, the Evaluate
option to On change of group
(selecting group 4), and Reset
to Never
.
If you need to pull distinct records that are not grouped in group 4 (or one of the other groups), then you would probably have to write a running total manually. Then, you can use whatever logic makes sense for when to add to the total.
If they are not in any set order, you would have to be fancier, I'd personally use an array to keep track of which records have been added to the total. If a record is in the array, don't do anything, and if it isn't, add to the total and then add the record to the array.