Simple(r) Excel formula to calculate forward stock (inventory) cover - excel

This is a perennial question for retailers, for which there are a number of solutions in existence:
How can you calculate the "forward cover" of a product knowing its current inventory and armed with forward sales estimates.
eg.
current inventory 100 units (cell A1)
weekly forward sales estimates: 25, 30, 10, 40, 90... (in range
A2:AX)
Here the answer would be 3.875 weeks (3 full weeks plus 0.875 of week 4)
I have a UDF to do this already.
I also have some slightly complicated array functions to do this, eg.
=MATCH(TRUE,SUBTOTAL(9,OFFSET(A2:A13,,,ROW(A2:A13)-ROW(A2)+1))>A1,0)-1+(A1-SUM(A2:INDEX(A2:A13,MATCH(TRUE,SUBTOTAL(9,OFFSET(A2:A13,,,ROW(A2:A13)-ROW(A2)+1))>A1,0)-1)))/INDEX(A2:A13,MATCH(TRUE,SUBTOTAL(9,OFFSET(A2:A13,,,ROW(A2:A13)-ROW(A2)+1))>A1,0)-1+1)
I was wondering if there is a neater way with these 'new-fangled' array functions which have been available for the last few years in later versions of Excel?

Here is another possible solution, although it requires the LET() function which is only available to newer version of excel (2021, 365 and later I believe).
The solution would be the following formula:
=LET(
sales,A2:A50,
inventory,A1,
cum_sum,MMULT(SEQUENCE(1,ROWS(sales),1,0),(ROW(sales)<=TRANSPOSE(ROW(sales)))*sales),
week_full,MATCH(TRUE,inventory<cum_sum,0) - 1,
week_frac,(inventory - INDEX(cum_sum,week_full)) / INDEX(sales,week_full + 1),
week_full + week_frac
)
Explanation
Given inventory and the forward looking sales estimates, the formula calculates the running total (i.e. cumulated sum) of the sales estimates as shown in the table here below
Inv and Sales
Cumulated Sum
Inv > Cum_Sum
Week
100
25
25
0
1
30
55
0
2
10
65
0
3
40
105
1
4
90
195
1
5
...
...
1
6
The formula goes on to get the number of full weeks of 'forward cover' by finding the the value for the cumulated sum that exceeds the inventory minus one (here 4 - 1 = 3).
Lastly, for the value of the week fraction covered in the last week, the formula calculates inventory minus sum of sales estimates of all previous weeks divided by sales estimate of final week of cover (i.e. (100 - 65) / 40 = 0.875).
Edit
After simplifying the formula you used with the LET() function, I noticed it's doing exactly the same calculation with the only difference of how the cumulated sum is being calculated. Here's your formula using LET():
=LET(
sales,A2:A50,
inventory,A1,
cum_sum,SUBTOTAL(9,OFFSET(sales,,,SEQUENCE(ROWS(sales)))),
week_full,MATCH(TRUE,cum_sum>inventory,0)-1,
week_frac,(inventory - INDEX(cum_sum,week_full)) / INDEX(sales,week_full+1),
week_full + week_frac
)

=LET(inv,A1,
sales,A2:A6,
cs,SCAN(0,sales,LAMBDA(x,y,x+y)),
m,XMATCH(A1,cs,1)-1,
m+(inv-
IF(m=0,
0,
INDEX(cs,m)))
/INDEX(sales,m+1))
SCAN() is perfect for creating a cumulative sum.
It can be referenced inside XMATCH because of the use of LET.
Here m returns the number of full weeks and the final calculation is the number of full weeks + (inv- cumulative sum up to the full week)/sales of the following week.

Related

What dynamic array formula can I use to calculate runway or burnrate in Excel?

I'm using dynamic array functions in Excel (SCAN, MAP, LET, BYCOL, etc); wihtout VBA or regular SUMIF formulas, to create a runway or burnrate-type table. So, I start with a $10,000 budget, month 1 $2,000 are spent, so $2,000 come out of the budget, month 2 $3,000, and so on until the cash available is 0 for the remaining months of the year. With a table showing how much cash was used from the budget per month, Desired outcome in the case below.
A
B
C
D
E
F
1
Budget
$10,000
2
Month
1
2
3
4
5
3
Expense
-$2,000
-$3,000
-$7,000
-$4,000
-$2,000
4
Desired outcome
-$2,000
-$3,000
-$5,000
$0
$0
Note that the Desired outcome amount is how much of the budget was used to cover the expenses.
Notice that Month 3 I spent $7,000, but from the budget, only $5,000 were left; so that's what I show.
Studied all the dynamic array (SPILL!) functions and lambda functions that I could find on the internet (this video by excelisfun is great) but I couldn't make it work. Some combination between SCAN or MAP would be the go-to solution I would think.
The solution should be one formula that leverage MS365 dynamic array functions.
I used REDUCE to get your result:
=LET(budget, -B1,
expenses, B3:F3,
DROP(REDUCE( 0, expenses,
LAMBDA( x, y,
HSTACK( x,
IF( SUM(x,y)>=budget,
y,
budget-SUM(x))))),
,1))
It creates a cumulative sum of expenses and checks if it's greater than or equal to the budget (since your expenses are negatives I converted budget to a negative).
If it is it, the value of expenses is shown, otherwise the remainder of the budget minus the cumulative sum of the expenses.

Trying to show a full years amount based on a smaller fraction of the year's total

this is my first post.
Right now, I have a limited set of data ranging from the beginning of this financial year until now. I'm trying to show what a full year's worth of that data would look like.
For example, if the number is at 10, and the data range is from 1/07/2021 - 30/12/2021 (half the year), then the end output should be 20. Or for example, turn a 12 with 3/4 of the year date range to 16 for a full years' worth.
However, my current formula would end up with 15 (10 + "half") rather than (10 + 10)
Right now this is what I have, but I know there's something off on my logic, as the output is smaller than it should be:
D1+((364-(F1-E1))/365)*D1
where E1 is the start date and F1 is the end date, and d1 is the number for that date range
Thanks in advance
endDate - startDate will give you the number of days the data covers.
(endDate - startDate) / 365 will give you what fraction of a year the sample represents.
Let’s say this works out to be 30%, or 0.30.
annualValue * 0.30 = periodValue and therefore we know that periodValue / 0.30 = annualValue.
So there it is, the cell you want the Annual Value in should be:
= periodValue / ( ( endDate - startDate) / 365 )
I will leave it to you to replace each of the three named values in my example to be the correct cell references. I suspect that’s probably:
=D1/((F1-E1)/365) which is the same as (D1*365)/(F1-E1).
The easy way to remember this is that it’s just cross-multiplication.
periodValue / days is proportionate to annualValue / 365. Thus periodValue / days = annualValue / 365. Cross-multiply and you get periodValue * 365 = annualValue * days. Divide both sides by days and you get `annualValue = (periodValue * 365)/days.

Doing an operation before SUMIF or MATCH-ing multiple values to multiply before summing

I have an Excel document with multiple small tables in it. Here, each table describes a single project, and at the end of the worksheet, I want to create a summary that doesn't have "hardcoded" locations so that that when the amount of projects (tables) is adjusted, it doesn't break all the formulas. Basically, it looks like this:
A B
1 Project 1
2 Units 200
3 Price / Unit 10
4 Material / Unit 5
5 Handling / Unit 1
6 Total cost 6
7 Profit Margin / Unit 4
8
9 Project 2
10 Units 100
11 Price / Unit 5
12 Material / Unit 1
13 Handling / Unit 1
14 Total cost 2
15 Profit Margin / Unit 3
16
...
19 Summary
20 Units =SUMIF( A$1:A19 ; A20 ; B$1:B19 )
21 Material costs ???
22 Handling costs ???
23 Total Profit ???
Here, there may be an arbitrary amount of projects and I'm unsure how to create a formula that directly calculates the total material costs (and by the same pattern, Handling and Total Profit). For the total units, I can simply use a =SUMIF( A$1:A19 ; A20 ; B$1:B19 ) instead of =B2 + B2 by having the function search col A for the keyword "Units" but in order to do this for the total material costs, I need to multiply first. Eg, it would be =B2*B4 + B10*B12.
My first idea was to use an INDEX MATCH approach to extract a subarray from each table and then sum it all up using SUMPRODUCT however the MATCH function unfortunately only returns the first result and I can't get it to output an array of results (I think this is just a limitation with the function?).
I guess it would also be possible to simply add extra lines to each table to pre-calculate these products, but I don't like that solution as it would give the tables a lot of unnecessary extra bloat and I'd really like to solve this in one formula.
Any help would be greatly appreciated!
I came up with a dirty solution, using SUMPRODUCT formula that works if your using Office 365 :
example calculating total handling cost:
=SUMPRODUCT(FILTER(B:B,A:A="Units"),FILTER(B:B,A:A="Handling / Unit"))
FILTER(B:B,A:A="Units"), returns an array of values on the right of cells containing "Unit"
FILTER(B:B,A:A="Handling / Unit"), returns an array of values on the right of cells containing "Handling / Unit"

Is there a way to use the offset function in Excel to sum the contribution from multiple cohorts over time?

I am trying to find a formula that will generate the total profit for a number of cohorts that generate a different periodic profit per unit, without having to create a line item for each cohort.
In this example, the profit contributed by each widget over time is shown in row 3, and the number of widgets issued in each cohort is shown vertically in column B. Each unit will contribute $25 in the first period, $60 in the second period, and so on. So year 1 total profit would be 100 x $25 = $2,500. Then in year 2, the Y1 cohort would generate 100 x $60 and the Y2 cohort would generate 200 x $25 for a total year 2 profit of $11,000.
Does someone know of a method in Excel that would work to consolidate the total profit calculation each year into a single formula? I am trying to model multiple line items over many periods, so looking for a more efficient solution.
Edit: In case this helps clarify the question, below is an image showing an example of another inefficient way to solve the problem in one line for year 4 total profits, but this is still not scalable. Also shown in text below.
`Year 4 total profit =
Y1 units issued x P4 profit per unit +
Y2 units issued x P3 profit per unit +
Y3 units issued x P2 profit per unit +
Y4 units issued x P1 profit per unit`
inefficient solution
Office 365, in C17:
=SUM(INDEX($B7:$B15,SEQUENCE(COUNT($C3:C3)))*INDEX($C3:C3,SEQUENCE(COUNT($C3:C3),,COUNT($C3:C3),-1)))
and copied right.
Ah well, I've just written an answer compatible with lower versions of Excel:
=MMULT(TRANSPOSE(B7:B15)^0,IF(ROW(B7:B15)-ROW(B7)<=COLUMN(C3:K3)-COLUMN(C3),INDEX(C3:K3,COLUMN(C3:K3)-COLUMN(C3)-(ROW(B7:B15)-ROW(B7))+1)*B7:B15,0))
It could be done a bit more easily in Excel 365 using Sequence() instead of row() and column(), but the same principle - generate a 2D matrix by comparing row and column numbers, then obtain its column totals using a standard method with Mmult.
I've filled in the intermediate results in C7:K15, but you only need the formula in C17.

Formula to Calculate Subscriber Churn Revenue

I'm trying to sum up 12 months of subscriber revenue factoring a 6% monthly churn (assuming no signups) to come up with the one-year value of a subscriber. A simple future value gives me the start and end values, but I'm looking to get the sum of the monthly declining revenues in a single Excel / Google Sheets formula. I can make 11 entries (plus the starting month full value), but is there a better one-liner or formula for this?
This gives me the 12th-month revenue:
=FV(-6%,11,0,100)
I'd like to get the sum without this:
=100 + FV(-6%,1,0,100) + FV(-6%,2,0,100) ... FV(-6%,11,0,100)
You are looking for the sum of a finite geometric series:
1 + r + r^2 + r^3 .... + r^11
And the sum of this series is
(1 - r^12) / (1 - r)
where r = 1 - 6%
So the formula would be
= (1 - (1-6%)^12 ) / (1 - (1-6%) ) * 100
This is assuming the OP meant
=100 + FV(-6%,1,0,-100) + FV(-6%,2,0,-100) ... FV(-6%,11,0,-100)
as FV(-6%,1,0,100) would output a negative number
I don't know much about such math but would the following formula give you the result?
=100+SUMPRODUCT(FV(-6%,ROW(1:11),0,-100))
The formula works in both Excel and Google Spreadsheets

Resources