How are you able to distinguish the first and third entity from the second and fourth?
Is there some other attribute in those entities that can be used to decide which values you want to add and which ones you don’t.
You will need some way to distinguish them
Here’s one way to do it:
For example a Boolean attribute “includeInTotal”
Then in the scope of your rule sheet you can do define an aliases (oldEntity) for the old entity (the one you want to add the totals to)
And an alias for the entities that you want included in the total (otherEntity)
The filter specifies that the “otherEntity” is any that are flagged to be included
And the “oldEntity” is the one that is flagged as old.
The filter section then uses the “old” attribute and the “includeInTotal” attribute to create two subsets of all the entities.
Presumably there is only one “old” entity but possibly many to be included in the total
Now in the rule sheet itself you can simply calculate the sum of all the entities that are flagged to be included in the total.
So in this test case only the entities identified as “includeInTotal” (2 and 5) have been added to the entity identified as “old” (1) 20 + 100 + 60
4. 6 and 7 were ignored.