Calculate price difference on product in FIFO order

JackDanIce

Well-known Member
Joined
Feb 3, 2010
Messages
9,922
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a table in date order (oldest to newest, by day, including duplicate dates) with ledger entries for stock purchases and stock sold.

I will never sell more than what is available to sell

DateOrderProductQuantityUnit PriceUnit Price Difference (£)Unit Price Difference (%)
01/01/2019BuyA50£2
02/02/2019BuyA100£1
03/03/2019SellA-50£10??

If I need to calculate difference in price for A as £8 (£10 - £2) for date 03/01/2019, what formula would I need, based on first Buy price for Product A vs first Sell price for Product A
Related, if for 03/01/2019 -100 were sold, how would I calculate price difference as: £8.17 for Product A? £10 - (50*£2 + 10*£1)/60
And formula for % difference for same!

TIA,
Jack
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
DateOrderProductQuantityUnit PriceUnit Price Difference (£)Unit Price Difference (%)
01/01/2019BuyA50£2
02/02/2019BuyA100£1
03/03/2019SellA-50£10?
If I need to calculate difference in price for A as £8 (£10 - £2) for date 03/01/2019, what formula would I need, based on first Buy price for Product A vs first Sell price for Product A

Code:
=E4-SUMIFS(E:E,A:A,MINIFS(A:A,C:C,C4))

Related, if for 03/01/2019 -100 were sold, how would I calculate price difference as: £8.17 for Product A? £10 - (50*£2 + 10*£1)/60

I think, if sold 100 --> £8.5 =10-((50*2+50*1)/100)
 
Upvote 0
Thank you Kokosek,
Code:
=E4-SUMIFS(E:E,A:A,MINIFS(A:A,C:C,C4))
If more dates are added with similar data, will this formula only pull for the earliest MINIF date? I need it to work on a FIFO basis (first in, first out)

My error, meant if 60 were sold
 
Upvote 0
How do you want to solve this manually it the case if there are few deliveries on the same date (MIN date) with different price?
What your 'First Buy price' will be? Maybe it is worth to create additional column with weighted average price for each delivery date?
 
Upvote 0
Happy to use a weighted average or other helper column, may need similar for quantity i.e. running total available in stock

Maximum 1 delivery per product per date. Different products can exist on matching dates.

'First Buy price' is first price for a product after it's quantity increases from 0 (assume all products quantities start at 0)

i.e.

DateOrderQuantityPrice
01/01/2019Buy100£1
02/02/2019Sell-100£10
03/03/2019Buy100£2
So in data above, 'first buy price' from 01/01/2019 - 02/02/2019 is £1

After 02/02/2019 next 'first buy price' is £2 until quantity falls back to 0

At the moment there is just a single ledger table that is meant to show change in cash and change in quantity and then margin calculations are needed from price changes over time (like table in #1)
 
Upvote 0
Thank you Kokosek,
Code:
=E4-SUMIFS(E:E,A:A,MINIFS(A:A,C:C,C4))
If more dates are added with similar data, will this formula only pull for the earliest MINIF date? I need it to work on a FIFO basis (first in, first out)
If it is only 1 delivery per day First Buy date is MIN date.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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