I have the following table (for example)
Product Quantity Price
A 20 3
B 3 2
A -10 3.1
A -3 3.2
B -1 2.2
Data is shown in time ascending sort and quantity which is negative means it is sold and if positive is bought amount.
What I want to do is to calculate realized and unrealized profit or loss for each product using "First in First out" method.
I tried a lot to write it with sumproduct combined with an array function but it does not work properly.
As I am really new in Excel world I would kindly ask you to give any hint how I can proceed further.
Bestie, Jeyhun