Calculate average cost of goods

SavingsJoe

New Member
Joined
Jul 9, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi

I have a sheet with the cost of the goods we purchased, my current stock is 160 apples and 90 oranges how do i calculate the cost of each item which are currently in stock, I dont want the average cost from the first purchase, this should be the calculated using the cost of the latest purchase, so for the apples it would calculate 120 @ £1.65 and 40 at £1.52
thanks

DateItemQtyCost
01/01/20Apples120
£1.81​
01/01/20Oranges120
£1.28​
03/03/20Apples120
£1.52​
03/03/20Oranges120
£1.35​
06/06/20Apples120
£1.65​
06/06/20Oranges120
£1.34​
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Welcome to MrExcel!

You could do something like this:

Book1
ABCDEFGHIJ
1DateItemQtyCostTotal stock purchasedAmount to use for this dateItemQtyCost of inventory (FIFO)
21/1/2020Apples1201.813600Apples160258.8
31/1/2020Oranges1201.283600Oranges90120.6
43/3/2020Apples1201.5224040
53/3/2020Oranges1201.352400
66/6/2020Apples1201.65120120
76/6/2020Oranges1201.3412090
8
Sheet14
Cell Formulas
RangeFormula
E2:E7E2=SUMIFS($C2:$C$7,$B2:$B$7,B2)
F2:F7F2=MIN(C2,VLOOKUP(B2,$H$2:$I$3,2,0)-SUMIFS($F3:$F$8,$B3:$B$8,B2))
J2:J3J2=SUMPRODUCT(--($B$2:$B$7=H2),$D$2:$D$7,$F$2:$F$7)


You'd be adding the E and F helper columns. You can hide them if you don't want to see them. Then the cost of inventory in J2 is a pretty basic SUMPRODUCT formula. I'm thinking about what it would take to create a single-cell formula, but MIN, SUMIFS, and variable ranges are all tricky elements to include in an array formula, and all together? Well . . .

The other option would be a UDF (User Defined Function) which could be written in VBA. It would be a much simpler function, but it would require you to enable macros.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,830
Messages
6,121,839
Members
449,051
Latest member
excelquestion515

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