renwaters said:
Instead of round I did Mround of 5 to cut having to have ones on hand to.
Okay. I will assume that the total (e.g. 2040) is a multiple of 5.
Then my original suggestion becomes:
B1: =MROUND(A1,5)
B2: =MROUND(SUM($A$1:A2),5) - SUM($B$1:B1)
I developed a better suggestion in another thread about a similar problem.
Assuming that the amounts to be rounded are sorted in descending order, as
yours are, then I would suggest:
B1: =MAX(5, MROUND(A1,5))
B2: =MIN(MAX(5, MROUND(($A$9-SUM($B$1:B1))*A2/SUM(A2:$A$6),5)),
$A$9-SUM($B$1:B1))
where A9 is the total (e.g. 2040).
Theory of operation: Allocation is based on the percentage of the
remainder. MAX(5,...) adjusts upward the first allocations less than 5.
The MIN() expression ensures that the artificial adjustments do not cause
the sum to exceed the total.
To see the benefit, consider a total of 30 with the same distribution of
unrounded amounts as a percentage of the total, namely: 43%, 26%, 12%, 8%,
6% and 5%.
My original suggestion would yield the following allocation:
12.90 15
7.80 5
3.60 5
2.40 0
1.80 5
1.50 0
Note the out-of-order allocation for 1.8, which is counter-intuitive. I
warned about that in my original posting of that suggestion.
My new suggestion avoids that. It yields the following allocation:
12.90 15
7.80 5
3.60 5
2.40 5
1.80 0
1.50 0
Arguably, the "7.80" person might complain that he should get 10, not 5.
The reason why he got only 5 is: after allocating 15 to the "12.90" person,
there are only 15 left, and the "7.80" person gets 7.8/17.1 (30 - 12.90) of
15 mrounded -- about 6.84, not 7.80.
It is tempting to want to change my new formula so that we simply mround the
unrounded allocations. That is:
B2: =MIN(MAX(5, MROUND(A2,5)), $A$9-SUM($B$1:B1))
In fact, that will seem to work in many/most cases.
But if we do that, the sum of the mrounded allocations will not always equal
the total.
For example, if the total is 85, this bogus formula yields the following
allocation:
36.55 35
22.10 20
10.20 10
6.80 5
5.10 5
4.25 5
which sums to 80 instead of 85.
I have not thought of any way to satisfy both desirable requirements,
namely: allocate based on the unrounded amounts, and the sum exactly equals
the total allocation.
----- original message -----