Formula for Distribution To Meet a Given Average

mrblister

Board Regular
Joined
Nov 20, 2016
Messages
209
Office Version
  1. 2021
Platform
  1. Windows
Hello all!

I am in need an Excel formula, starting from a cell (e.g. N4) and copied down, where the formula considers:
  • the topmost cell contains a given lowest value
  • the bottom-most cell (given) contains the highest value
  • the average value of all cells equals a given value.
So for example, if:
  • lowest_value = 0.5
  • highest_value = 1.5
  • average_value = 0.95
  • number_of_cells = 3

Then the formula outputs would be: N4 = 0.5, N5 = 0.85, N6 = 1.5.

This is as far as I can get. I need the formula to calculate the distribution values between lowest_value and highest_value , while maintaining average_value, over the number_of_cells (e.g. 4, 5, etc).

Can anyone assist?
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hello, if you do not mind using a volatile function with random values maybe you could try something like:

Excel Formula:
=LET(
n,O1,
l,N1,
u,N2,
a,N3,
x,RANDARRAY(n-1,,l,u),
y,(a*(n+2)-(l+u+SUM(x))),
VSTACK(x,y))

where O1 is the number of values to be generated, N1 is the lowest value, N2 the highest, and N3 the average. The formula includes the lowest and highest values into consideration.
 
Last edited:
Upvote 0
Apologies, I see that there is a mistake in this attempt as the last value might be out of the bounds, please ignore post #2.
 
Upvote 0
Thank you for the attempt @hagia_sofia, but regardless I don't have access to VSTACK anyway (that function is not included in Excel 2021).
 
Upvote 0
You are right, my bad. I tried another one but failed again.
 
Upvote 0
Hi mrblistter,

Her's what I would try:

Excel Formula:
=LET(lowest_value,0.5,
highest_value,1.5,
average_value,0.95,
number_of_cells,3,
tempAverage,((average_value*number_of_cells)-highest_value-lowest_value)/(number_of_cells-2),
rdmTbl,RANDARRAY(number_of_cells-2,1,lowest_value+0.00001,highest_value-0.00001),
lstVal,(rdmTbl/SUM(rdmTbl))*tempAverage*(number_of_cells-2),
VALUE(TEXTSPLIT(TEXTJOIN (";",TRUE,lowest_value,SORT(lstVal),highest_value),,";")))

Bests regards,

Vincent
 
Upvote 0
Solution
It would help if you provided an example.
N.B. You can post an extract of your sheet with the forum's tool named XL2BB.
Goal Seek change the value in D4 to achieve 0.95 in D5



T202501a.xlsm
CD
2lowest_value = 0.50.5
3highest_value = 1.51.5
4average_value = 0.950.85
5number_of_cells = 30.95
6
3c
Cell Formulas
RangeFormula
D5D5=AVERAGE(D2:D4)
 
Upvote 0
It would help if you provided an example.
N.B. You can post an extract of your sheet with the forum's tool named XL2BB.
Goal Seek change the value in D4 to achieve 0.95 in D5



T202501a.xlsm
CD
2lowest_value = 0.50.5
3highest_value = 1.51.5
4average_value = 0.950.85
5number_of_cells = 30.95
6
3c
Cell Formulas
RangeFormula
D5D5=AVERAGE(D2:D4)
Hi Dave,

I'm not quite sure i see what you mean. The question, if I understood it the right way, requested a formula that could be placed anywhere without any cell reference. If I was in the wrong, only replace value (eg. 0.5) with a cell reference (eg. $A$1).

Bests regards,

Vincent
 
Upvote 0
Hi mrblistter,

Her's what I would try:

Excel Formula:
=LET(lowest_value,0.5,
highest_value,1.5,
average_value,0.95,
number_of_cells,3,
tempAverage,((average_value*number_of_cells)-highest_value-lowest_value)/(number_of_cells-2),
rdmTbl,RANDARRAY(number_of_cells-2,1,lowest_value+0.00001,highest_value-0.00001),
lstVal,(rdmTbl/SUM(rdmTbl))*tempAverage*(number_of_cells-2),
VALUE(TEXTSPLIT(TEXTJOIN (";",TRUE,lowest_value,SORT(lstVal),highest_value),,";")))

Bests regards,

Vincent
Thanks Vincent, but I don't have access to the TEXTSPLIT function. (And it's possible the system where the formula will be used may not have access to RANDARRAY, although I think RANDARRAY will be available)
 
Last edited:
Upvote 0
Hi mrbliste,

Does this one work for your version of excel? *I have the french version of Excel 365 so I might make some error while translating formulas*

- ENGLISH -
Excel Formula:
=LET(lowest_value,0.5,
highest_value,1.5,
average_value,0.95,
number_of_cells,5,
tempAverage,((average_value*number_of_cells)-highest_value-lowest_value)/(number_of_cells-2),
rdmTbl,RANDARRAY(number_of_cells-2,1,lowest_value+0.00001,highest_value-0.00001),
lstVal,(rdmTbl/SUM(rdmTbl))*tempAverage*(number_of_cells-2),
seq,SEQUENCE(number_of_cells),
IF(seq=1,lowest_value,IF(seq=number_of_cells,highest_value,INDEX(SORT(lstVal),seq-1))))

- FRENCH -
Excel Formula:
=LET(lowest_value;0,5;
highest_value;1,5;
average_value;0,95;
number_of_cells;5;
tempAverage;((average_value*number_of_cells)-highest_value-lowest_value)/(number_of_cells-2);
rdmTbl;TABLEAU.ALEA(number_of_cells-2;1;lowest_value+0,00001;highest_value-0,00001);
lstVal;(rdmTbl/SOMME(rdmTbl))*tempAverage*(number_of_cells-2);
seq;SEQUENCE(number_of_cells);
SI(seq=1;lowest_value;SI(seq=number_of_cells;highest_value;INDEX(TRIER(lstVal);seq-1))))

Bests regards,

Vincent
 
Upvote 0

Forum statistics

Threads
1,226,112
Messages
6,189,036
Members
453,520
Latest member
packrat68

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