Formula for calcing Weeks of Supply

omarman

New Member
Joined
Feb 25, 2009
Messages
35
Hi there,

I am looking for a way to calculate WOS so that as a unit sales forecast changes, so does the WOS.

Here is an example with the cells highlighted that I would like the formula to live:

excel.png



Thanks!!!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Try...

B4, copied across:


=IF(B3 < SUM(B2:$P2),SUMPRODUCT(--(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))<=B3))+LOOKUP(0,SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2-B3,(B3-(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2))/B2:$P2),IF(B3=SUM(B2:$P2),COUNT(B2:$P2),"N/A"))<?XML:NAMESPACE PREFIX = SUM(B2 /><SUM(B2:$P2),SUMPRODUCT(--(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))<=B3))+LOOKUP(0,SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2-B3,(B3-(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2)) B2:$P2),IF(B3='SUM(B2:$P2),COUNT(B2:$P2),"N/A"))</p'> </SUM(B2:$P2),SUMPRODUCT(--(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))<=B3))+LOOKUP(0,SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2-B3,(B3-(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2))>
<SUM(B2:$P2),SUMPRODUCT(--(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))<=B3))+LOOKUP(0,SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2-B3,(B3-(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2)) B2:$P2),IF(B3='SUM(B2:$P2),COUNT(B2:$P2),"N/A"))</p'>
Note that the formula returns the text value "N/A" when supply exceeds projected sales.
</SUM(B2:$P2),SUMPRODUCT(--(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))<=B3))+LOOKUP(0,SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2-B3,(B3-(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2))>
 
Upvote 0
omarman, can you explain how you get 3.3 as the result in C4?
I can get 3.4 for wk1 with a udf but I get nearer 3.74 for wk2.

Domenic, I was trying to use your formula as a double check but I suspect the board software has screwed up the formula, probably around the '<' and '>' symbols. Could you repost with code tags to prevent line wrap and add an extra space around such symbols to prevent it from being changed?
 
Upvote 0
omarman, can you explain how you get 3.3 as the result in C4?
I can get 3.4 for wk1 with a udf but I get nearer 3.74 for wk2.

Domenic, I was trying to use your formula as a double check but I suspect the board software has screwed up the formula, probably around the '<' and '>' symbols. Could you repost with code tags to prevent line wrap and add an extra space around such symbols to prevent it from being changed?

Sure, no problem...

Code:
=IF(B3 < SUM(B2:$P2),SUMPRODUCT(--(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1)) < =B3))+LOOKUP(0,SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2-B3,(B3-(SUBTOTAL(9,OFFSET(B2:$P2,,,,COLUMN(B2:$P2)-COLUMN(B2)+1))-B2:$P2))/B2:$P2),IF(B3=SUM(B2:$P2),COUNT(B2:$P2),"N/A"))

By the way, my formula returns 3.73958 for the second week. I assumed that there was an error in the calculation by the original poster. :)
 
Upvote 0
A UDF solution:
Excel Workbook
ABCDEFGHIJKLMNOP
1wk1wk2wk3wk4wk5wk6wk7wk8wk9wk10wk11wk12wk13wk14wk15
2unit sls52112335964874678235443744043
3BOP101401701981381261281009418619613612411842
4Dom's WOS0.1923083.7395833.3333333.2567571.8752.0597011.805971.4024391.3428574.754.8139533.441862.232558N/A0.976744
5my WOS0.1923083.7395833.3333333.2567571.8752.0597011.805971.4024391.3428574.754.8139533.441862.232558n/a0.976744
Sheet


supported by this code in a standard module:
Code:
Function WOS(BOP, StartPosn As Range)
Set myRange = Range(StartPosn, StartPosn.End(xlToRight))
Dim lupvals()
ReDim lupvals(1 To myRange.Cells.Count)
i = 1
For Each cll In myRange.Cells
  lupvals(i) = Application.Sum(Range(StartPosn, cll))
  i = i + 1
Next cll
xx = Application.Match(BOP, lupvals)
If IsError(xx) And lupvals(1) >= BOP Then
  WOS = BOP / lupvals(1)
Else
  If xx = UBound(lupvals) And (BOP - lupvals(xx)) > 0 Then
    WOS = "n/a"
  Else
    WOS = xx + (BOP - lupvals(xx)) / myRange(xx + 1)
  End If
End If
End Function
 
Upvote 0
Your formula worked!!! Thanks so much Domenic! This is the second time you've saved me!

P45cal thanks for the code! I haven't tried it yet but will do so later this afternoon.

I really appreciate your help everyone! :)

omarman
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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