Calculating weighted average unit cost using histroical purchasing data

dosinger

New Member
Joined
Jun 11, 2015
Messages
21
No VBA
No Macros

I need help calculating weighted average unit cost of inventory on hand.

Problem:
I have 25 units on hand.
Recent purchases

1644190306361.png



Possible methodology:
Sum the quantities purchased, until I reach the current quantity on hand.

1644190348236.png



Then sum the total cost for each purchase up to total quantity
View attachment 57152

Ave Cost = $243 / $25 = $9.72

I have 10,000 parts and over 1 million lines of purchase history.
How do I calculate the ave cost for all 10,000 parts, systemically, so I can repeat this process every month.

Thank you.
 

Attachments

  • 1644190263541.png
    1644190263541.png
    6 KB · Views: 8

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
"10.000 parts and 1 million lines of history - no VBA, no macros !!! Oeps."

You can do it like this, the data for buying and purchasing is in the same table to avoid circulair problems.
After every transaction, you get a new average cost per unit in stock.
As you do this on a monthly base, perhaps you can calculate with a monthly average cost.
Table is sorted for ascending date and descending quantity
inventory.xlsx
ABCDEFGHIJ
1datumproductQTYPricevalueavg priceinv.QTYinv.Valueinv. AVGlast row
29/janBCD10010,00 €1.000,00 € 1001.000,00 €10,00 € 
310/janABC108,00 €80,00 € 1080,00 €8,00 € 
410/janABC-5-40,00 €8,00 €540,00 €8,00 €2
510/janBCD-1-10,00 €10,00 €99990,00 €10,00 €1
611/janBCD-1-10,00 €10,00 €98980,00 €10,00 €4
712/janBCD-1-10,00 €10,00 €97970,00 €10,00 €5
813/janBCD-1-10,00 €10,00 €96960,00 €10,00 €6
914/janBCD-1-10,00 €10,00 €95950,00 €10,00 €7
1015/janABC59,00 €45,00 € 1085,00 €8,50 €3
1115/janABC-5-42,50 €8,50 €542,50 €8,50 €9
1215/janBCD-1-10,00 €10,00 €94940,00 €10,00 €8
1316/janABC315,00 €45,00 € 887,50 €10,94 €10
1416/janABC-3-32,81 €10,94 €554,69 €10,94 €12
1516/janBCD-1-10,00 €10,00 €93930,00 €10,00 €11
1617/janBCD-1-10,00 €10,00 €92920,00 €10,00 €14
1718/janBCD-1-10,00 €10,00 €91910,00 €10,00 €15
1819/janBCD-1-10,00 €10,00 €90900,00 €10,00 €16
1920/janBCD-1-10,00 €10,00 €89890,00 €10,00 €17
2021/janBCD-1-10,00 €10,00 €88880,00 €10,00 €18
2122/janBCD-1-10,00 €10,00 €87870,00 €10,00 €19
2223/janBCD-1-10,00 €10,00 €86860,00 €10,00 €20
2324/janBCD-1-10,00 €10,00 €85850,00 €10,00 €21
2425/janBCD-1-10,00 €10,00 €84840,00 €10,00 €22
2526/janBCD-1-10,00 €10,00 €83830,00 €10,00 €23
2627/janBCD-1-10,00 €10,00 €82820,00 €10,00 €24
2728/janABC79,00 €63,00 € 12117,69 €9,81 €13
2828/janABC-7-68,65 €9,81 €549,04 €9,81 €26
2928/janBCD-1-10,00 €10,00 €81810,00 €10,00 €25
3031/janABC510,00 €50,00 € 1099,04 €9,90 €27
3131/janABC-5-49,52 €9,90 €549,52 €9,90 €29
327/febABC-1-9,90 €9,90 €439,61 €9,90 €30
Blad1
Cell Formulas
RangeFormula
E2:E32E2=[@QTY]*IF([@QTY]>0,[@Price],[@[avg price]])
F2:F32F2=IF([@QTY]<0,OFFSET(Tabel1[[#Headers],[inv. AVG]],[@[last row]],,,),0)
G2:G32G2=IF([@[last row]]>0,OFFSET(Tabel1[[#Headers],[inv.QTY]],[@[last row]],,,),0)+[@QTY]
H2:H32H2=IF([@[last row]]>0,OFFSET(Tabel1[[#Headers],[inv.Value]],[@[last row]],,,),0)+[@value]
I2:I32I2=+[@[inv.Value]]/[@[inv.QTY]]
J2:J32J2=MAX(IF($B$1:$B1=[@product],ROW($B$1:$B1)-ROW($B$1),0))
 
Upvote 0
Solution
An interesting solution. It assumes that we have total history of each part, such that the beginning quantity of each part is 0, and that you can trace all of the pluses and minuses to calculate the quantity on hand. Unfortunately, we don't have total history on each part.

All we know is that we have a quantity of 25 currently on hand, and recent purchasing history. That is why I my initial example started with the most recent purchase. By doing so, I know for a fact that I have 5 units purchase at $10, 7 purchased at $9, etc. When I get to 25 units, I know the total cost I paid for all 25 units. This way, I don't need complete history of the part.


Here is an excerpt from the actual data for a single part straight from our system, and how I think I would calculate it under two scenarios.

1644251140448.png


Eager to see what you can come up with.
 
Upvote 0
After your annual inventary, you can actualise for all the articles the qty and the value and start from there.
In multiple tables, it's more complicated.
Excel can suggest a unit price when you purchase a quantity in a separate column, but you have to copy manually (as VBA isn"t allowed) that price, otherwise i have a circular reference error.
All your data is sorted for "trans date" in a descending way ?

- The value of the stock is almost "calculated weighted average", not for 100%
- What happens when invoices for buying articles is booked later then the invoices for purchasing the same articles, that's a fundamental problem.
 
Upvote 0
We are a US government contractor, so certain short cuts are not allowed, like calcing qty and value at the end of the year and bringing that forward.
I followed the login you were using and was able to build some formulas to get me the solution I needed. It's rather clunky, but it works.

Thanks for your efforts. It did help.
 
Upvote 0
In the context of a trading portfolio(lets say stocks), upon sell txn(i.e. quantity with negative value), the average price should not change. How to modify the formula in such cases?
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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