Comparison of two slopes to get the best value

64 Views Asked by At

I'm trying to get something in excel that may be solvable by coming up with the proper formula. I believe it's a comparison of two slopes. The theory comes an economies of scale: How can I spend the same amount of money but get as much stuff as you can for that total cost.

Example: it may be better to buy $200$ than 180 because at $200$ the price drops.

Here are the prices $1$ to $200$ costs $18.48$ $201$ to $1001$ costs $12.48$

So if I want $136$ which costs $\$2513$ $(136*18.48)$, it's more advantageous to buy $201$ which costs $2496 (201 * 12.48)$

Attached is a graph to display the logic

enter image description here

2

There are 2 best solutions below

1
On BEST ANSWER

To do this in Excel, the first thing is to decide how you want to deal with piecewise-linear functions.

One way to implement a piecewise-linear function is to have nested IFs, one for each of the "breakpoints" (input values at which the function's slope changes). But I usually prefer to make a table in which the left-hand column is the list of breakpoints and the remaining columns describe the parameters of each linear segment of the function. In your case, all you need to specify is the unit price after each breakpoint. Then I would use VLOOKUP on the input value and the leftmost column of the table to find out which row of parameters to use for that input value.

In your case it is simpler than usual because all segments of your function have the same $y$-intercept, namely zero. All you need to keep track of is the slope.

So, first construct a function which takes any order size (number of units to buy) and determines the total cost for that order. This requires a lookup table with the number-of-units breakpoints in one column and the price per unit in another column.

Now comes the clever part: construct a second function that takes any total cost and determines how many units you can get for that cost. The breakpoints for this function are the lower left-hand ends of each segment in your graph, that is, take the smallest number of units in each price bracket, multiply by the price in that price bracket, and use the total cost at that point as one of your breakpoints. Again, the breakpoints are one column of the lookup table for this function, and the other column you need is again the price per unit.

To find out how many units to buy for the best deal, you apply the first function, then the second function. For example, suppose you start with the idea of buying $180$ units. You give the input $180$ to your first function, which produces the result $3326.40$. You then take $3326.40$ as the input to your second function, which determines that since $3326.40 \geq 2508.48$ (where $201 \times 12.48 = 2508.48$ is one of the breakpoints of that function), the unit price to use is $12.48$ and you can buy $3326.40/12.48 \approx 266.538$ units for the same price. If you have to order a whole number of units, you must round the second function's result to an integer. (I would generally round down, that is, just discard any fractional part of this intermediate result, but it's up to you how you want to handle that.) So I would order $266$ units.

Now that you know how many units to order, if you want to know the exact cost, just apply the first function again. In the example from the paragraph above, the cost would be $266 \times 12.48 = 3319.68$.

1
On

It looks to me like you are misunderstanding "Here are the prices 1 to 200 costs 18.48 201 to 1001 costs 12.48".

If you buy 201 you will [b]not[/b] get all 201 for 12.48 each. You will pay 18.48 for the first 200 then 12.48 for the last 1.

More generally, that means that if you by "x" items where x> 200, then you will pay 20*18.48= 369.60 for the first 20 and (x- 20)12.48 for the last x- 20.