If the problem has values increasing the way it is proposed (0.58; 0.64; 1;05; 1.46), an optimization function to obtain the minimum solves...
Excel Solver
To perform these tasks without using the VBA or a gigantic formula, the Solver needs to be used and a simple logic is used.
Enable Solver in Excel
The version used is Excel 2010.
- Enter the Office or File button.
- Click on Options.
- Click on Add-Ins.
- Install the Solver Add-in and click Ok.
Enable the Add-in
- Enable the Developer Mode
- On the tab Developer, click on Add-ins
- A window will open and the Solver Add-in must be marked.
Solver
With the following data in the spreadsheet:
| | A | B | C | D | E | F |
|---|----|------|--------|--------------|----------------------------|-------------------|
| 1 | 0 | 0,58 | =A2-A1 | | =SOMARPRODUTO(D1:D4;B1:B4) | =VALOR_QUANTIDADE |
| 2 | 5 | 0,64 | =A3-A2 | | | |
| 3 | 10 | 1,05 | =A4-A3 | | | |
| 4 | 15 | 1,46 | | | | |
| 5 | | | | =SOMA(D1:D4) | | |
The following objective function and restrictions are added:
Solver is added to the cell E1
with the following parameters:
Upshot
For 4 m³:
For 8 m³:
For 15 m³:
Extra:
To change the optimization function, other forms of objective function or more constraints can be added. If you want to delve into the subject look for Linear Programming, Simplex Method or Solver. Or in English Linear Programming (LP), Simplex or Linear Optimization. A good tool for Excel optimization problems is the Solver Studio.
I’m not the best Excel expert, but I believe that using maximum and minimum can reach the desired levels. Type,
min($A1, 5) * 0.58 + max(min($A1-5, 10-5), 0) * 0.64
(being$A1
a cell with the argument)– Jefferson Quesado
I believe you can make a giant formula with several
SES()
or use a Solver with an objective function of the type:FO= x_0 * 0,58 + x_1 * 0,64 + x_2 * 1,05 + x_3 * 1,46
if the values are increasing or decreasing as in the example... and the restrictions ofx
with the desired range.– danieltakeshi
I’ll set a better example, see if you can help me. Luis - 8 m3 Pedro - 4 m3 Andre - 15 m3 The price of water is calculated using these steps: Between 0 and 5 m3 = 0,58€ Between 6 and 10 m3 = 0,64€ Between 11 and 15 m3 = 1,05€ So I want to know how much each of them will pay for water consumption according to the echelons. And the calculation is done as follows: Luis consumed 8 m3; (50,58) + (30,64) = 4,82€ Pedro 4 m3; 40,58= 2,32 €; Andre 15 m3; (50,58) + (50,64) + (51,05) = 11,35 €. .
– Luis Silva
I understood your problem, I only gave hints as to the possible ways to solve them.
– danieltakeshi
You have to review those intervals there, if it is
5.5
the value drops in limbo. It would probably be:[0, 5[
,[5, 10[
,[10, 15[
... Or[0, 6[
,6, 11[
,[11, 16[
.– fernandosavio