FIFO Problem

Joined
Oct 19, 2020
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hello!
I have the worksheet in the enclosed image.
It presents purchases and sells in a certain period, based on the FIFO system.
The available input data are in columns A, B, C, D and E. The rest, in columns F–I, have to be calculated. I.e. formulas in F4 to I4, to be pulled down.
I couldn't solve the problem of the price when a previously purchased quantity is finished and the next sell takes partially from the old stock and partially from the new one.
I'll be greatfull if someone could help me.
Thanks!
Alexandru
 

Attachments

  • Excel FIFO.JPG
    Excel FIFO.JPG
    106.9 KB · Views: 16

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Could you adapt something like this:

ABCDEFG
1AverageAverage
2BuySellHoldingSell
3QuantityPriceQuantityPriceHoldingPricePrice
4800$1.00800$1.000
5200$1.20600$1.000$1.000
6400$1.25200$1.000$1.000
7100$1.10300$1.033 
8150$1.15450$1.072 
9300$1.05150$1.150$1.033
10500$1.05650$1.073 
11200$1.10450$1.050$1.125
12100$1.30550$1.095 
13
14Check total prices:
15Purchases$1,737.50
16less: Sales$1,135.00
17$602.50
18Holdings$602.50
Sheet1
Cell Formulas
RangeFormula
E4E4=A4
F4:F12F4=LET(q,A$4:A4,p,B$4:B4,h,E4,qTot1,DROP(SCAN(SUM(q),A$3:A4,LAMBDA(a,b,a-N(b))),-1),qTot2,q+(h-qTot1)*(qTot1>h),IF(h=0,"n/a",SUM((qTot2>0)*qTot2*p)/h))
E5:E12E5=E4+A5-C5
G5:G12G5=IF(C5>0,(PRODUCT(E4:F4)-PRODUCT(E5:F5))/C5,"")
D15D15=SUMPRODUCT(A4:A12,B4:B12)
D16D16=SUMPRODUCT(C4:C12,G4:G12)
D17D17=D15-D16
D18D18=E12*F12
 
Upvote 1
Solution
Could you adapt something like this:

ABCDEFG
1AverageAverage
2BuySellHoldingSell
3QuantityPriceQuantityPriceHoldingPricePrice
4800$1.00800$1.000
5200$1.20600$1.000$1.000
6400$1.25200$1.000$1.000
7100$1.10300$1.033 
8150$1.15450$1.072 
9300$1.05150$1.150$1.033
10500$1.05650$1.073 
11200$1.10450$1.050$1.125
12100$1.30550$1.095 
13
14Check total prices:
15Purchases$1,737.50
16less: Sales$1,135.00
17$602.50
18Holdings$602.50
Sheet1
Cell Formulas
RangeFormula
E4E4=A4
F4:F12F4=LET(q,A$4:A4,p,B$4:B4,h,E4,qTot1,DROP(SCAN(SUM(q),A$3:A4,LAMBDA(a,b,a-N(b))),-1),qTot2,q+(h-qTot1)*(qTot1>h),IF(h=0,"n/a",SUM((qTot2>0)*qTot2*p)/h))
E5:E12E5=E4+A5-C5
G5:G12G5=IF(C5>0,(PRODUCT(E4:F4)-PRODUCT(E5:F5))/C5,"")
D15D15=SUMPRODUCT(A4:A12,B4:B12)
D16D16=SUMPRODUCT(C4:C12,G4:G12)
D17D17=D15-D16
D18D18=E12*F12
Hello, Stephen!
Your solution is unique and great! And it works p e r f e c t.
The brilliant formula in F4 left me... "the eyes in the sun", how we use to say in Romanian. 🤩
Congratulations & thank you very much!

Alexandru
 
Upvote 0

Forum statistics

Threads
1,225,730
Messages
6,186,701
Members
453,369
Latest member
positivemind

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top