How to get part of total based on 2 percentages

52 Views Asked by At

sorry I don't know the name for this problem, nor if it's even solvable.

I'm trying to calculate the new delivery cost based on previous data.

Say we have 2 products with respective delivery cost per item:
Apple --> 7 $ (7 -> current value)
Melon --> 20 $ (20 -> current value)

Then, I make a purchase of:
10 x Apple
50 x Melon
Total new delivery fee is: 1,130 $.

Just with the data above, is it possible to calculate and know that the new delivery fees are:
Apple --> 8 $ (10 x 8 $ = 80 $)
Melon --> 21 $ (50 x 21 $ = 1,050 $)

If the quantities were equal, then I could assume that 25.93% (7 / (7 + 20)) of the delivery fee belongs to Apples, and 74.07% belongs to Melons.

But since quantities are not equal, I have this problem of 2 percentages. I can't say that 25.93 % (based on previous delivery fee) or 16.67 % (based on quantity) of the total belongs to Apples.

This problem comes from making purchases of big and small items. If I just take the total and divide with all quantity, then the smaller items would have their delivery cost higher than their own cost.

Thanks in advance!

update - edit ------------
So I got this idea, it doesn't solve what I asked, but may be good enough for you as it is for me.

Basically, calculate the total delivery fee using old values:

10 x Apple ( 7 $) =    70 $
50 x Melon (20 $) = 1,000 $
            total = 1,070 $

Then compare it with the new delivery fee: 1,130 $

1,070 -> 1,130 = 5.6 % Increase

Now I can use that % to update the products delivery fee:

Apple  7 $ + 5.6 % =>  7.39 $
Melon 20 $ + 5.6 % => 21.12 $

This is not a solution for what I originally asked in the post (I asked poorly). But I think this might be what you were looking for if you had the same problem as I did.

1

There are 1 best solutions below

1
On BEST ANSWER

As Lulu notes, you got the arithmetic in your example wrong.

In general, it's not possible, no. Here's how I know. There are two different per-apple and per-melon prices that produce the same total. So you cannot tell which of these (or some other) the right value is. For instance, in your example, the data

Apple -> 14
Melon -> 18.60

gives exactly the same total cost.

If you happen to have data for two different deliveries, say

10 Apple, 50 Melon -> 1070
 8 Apple, 32 Melon -> 696

then you can, generally, figure out the cost per apple or per melon. If you call the first of these $A$ and the second $M$, then we have

\begin{align} 10A + 50 M = 1070 \\ 8A + 32 M = 696 \end{align} We multiply the top equation by $8$ (the thing next to $A$ in the bottom one) and the bottom by 10 (the thing next to $A$ in the top one) to get \begin{align} 80A + 400 M = 8560 \\ 80A + 320 M = 6960 \end{align} We then subtract one equation from the other to get \begin{align} 80A + 400 M = 8560 \\ 0A + 80 M = 1600 \end{align} and now we can see that since 80M = 1600, we have $M = 20$. The first equation then becomes \begin{align} 80A + 400 \cdot 20 = 8560 \\ 80A + 8000= 8560 \\ 80A = 560 \\ 8A = 56 \\ A = 7 \\ \end{align}

This technique can fail: if one of the orders contains zero apples, it won't work (you'll need to do the "cross multiplying" using the numbers next to the $M$s instead!), and if the two orders are just multiples of one another, i.e. the first is $$ (4A, 3M) $$ and the second is $$ (8A, 6M) $$ then you won't have enough information. Otherwise, this technique should work (given two orders) to discover the hidden pricing.

Warning: Often, there a delivery charge, and that messes up everything!