Hi community,
I am totally stuck with one issue. I already tried several batch macros, iterative macros etc. but cannot find a suitable solution. Other threads also did not have the exact solution for my case.
Hope you guy have an idea 
I have one data table containing the transaction history of one stock. (see Input.xlsx)
I manually created the needed output in excel (see Output.xlsx) but was not able to recreate that in Alteryx so far.
Tasks needed:
When stocks are sold, we will need to calculate "Total Costs" using the unit price of the sold stocks and the unit price of buyed stocks according to the first-in first-out method (FIFO). So, if the number of sold units are more then the buyed units from the first transaction, I will need to use the unit price of the historically next buy.
Example:
First Buy -> 10 Units for 1$ each
Second Buy -> 10 Units for 2$ each
Third Buy -> 20 Units for 3$ each
Sell -> 15 Units --> Total Costs = 10 Units x 1$ + 5 Units x 2$ // now there are only 5 Units left from the second buy
Sell -> 15 Units --> Total Costs = 5 Units x 2$ + 10 Units x 3$
It gets more complex with increasing number of transactions. (see my example files)
Any idea how to solve this?