Hi Guys,
Can someone please help me with the logic of how I can create a workflow that basically creates a accumulative cost based on how products have moved from Their respective shop types. Starting from Manufacturing to Distributor and then to the shop.
The Hierarchy column shows how the products move from one shop type to another. Please note I used an example and in the full data set there are more products. The Hierarchy is something I just created to show how the products move and is not in the dataset. A for Manufacturing, B for Distributor and C for Shop.

I basically need to create a workflow that will group the send and receive thus creating a running total like below.
The red text is the returns of an item (B_A).

Thanks guys any advice will be greatly appreciated.