I'll be using 'Formulas and functions' app as a base for this.
We have 'Transaction Values' module:

I created 'adv prod' list and 'T: map' module. It's goal is to assign basic products to advanced products:

Any product can be assigned to no advanced product, to one or many.
My goal is to write a formula for this simple module:

Expected result is:

I would like to avoid adding ANYTHING to Transactions module - let's assume that it is so huge that every new line item impacts performance. Other than that - I can add line items or properties where needed.
I have run out of ideas for this seemingly very simple calculation. Any help appreciated. Thanks!