How can I give discount to the highest priced product - excel

enter image description hereI am trying to figure out how I can solve the following problem in Excel.
First "buis" with the highest "contract tarief" should cost 100% of the "contract tarief" price. The following highest "buis" should cost 50% of the "contract tarief price" all the other "buizen" will cost 25% of the mentioned "contract tarief" price.
For example 6 "buizen" in total 2 of 200mm 1 of 150mm 1 of 125mm and 2 of 100mm. Normally that would cost 8 + 3 + 2 ++ 2 = 15. But the first "highest price one" is 200mm that one will be 4 and the next 2 the rest will be 25% so 25% of 11. And that will be the total price.
So I am trying to make it automated that it automaticly finds the 2 highest costing "buizen" and calculate that they cost 1x100% and 1x50% and then totalling all of the rest "buizen" with the 25% cost.
I hope I make sense. I am from the Netherlands so please ask if you need more clarification. I appreciate your help.

I don't know the layout of your spreadsheet, but;
if column A is your price and B contains your 'contract tarief' then in cell C2 you could enter:
=IF($B2 = MAX($A:$A), $B2, IF(RANK($A2, $A:$A, 0)+COUNTIF($A:$A, $A2)-1 = 2, $B2*0.5, $B2*0.25))
You'll want to adapt that to match your layout of course.
Note that this will return the 100% tarief for all lines with the max value, the 50% for all lines with the second value, and the 25% for everything lower than that (things with duplicate values will get duplicate tariefs).
To give credit where it's due, I copied the unique ranking formula from here.

If one has Excel O365, you could try:
Formula in F2:
=LET(X,SORT(FILTER(A2:D6,D2:D6>0),1,-1),Y,SUM(INDEX(X,0,4)*(INDEX(X,0,3)/4)),Z,SUM(INDEX(X,0,4)),A,INDEX(X,1,4),Y+INDEX(X,1,3)*0.75+IF(Z=1,0,INDEX(X,IF(A>1,1,2),3)/4))
This is long and wordy and paining my head, I'm sure someone can come up with something clever =)
EDIT: The proper Dutch translation of this formula:
=LET(X;SORTEREN(FILTER(A2:D6;D2:D6>0);1;-1);Y;SOM(INDEX(X;0;4)*(INDEX(X;0;3)/4));Z;SOM(INDEX(X;0;4));A;INDEX(X;1;4);Y+INDEX(X;1;3)*0,75+ALS(Z=1;0;INDEX(X;ALS(A>1;1;2);3)/4))

Related

price calculations weighted values

After a bit of advice on doing a calculator with a sliding scale.
I am building a matrix where we have set price points at intervals based on qty of items. The code I use works fine apart from the first 2 ranges.
Because for 1 qty the unit cost is so high my maths won't work.
Example
Qty 1 = £23.25 (Price per unit is then £23.25)
Qty 10 = £51.59 (Price per unit is then £5.159)
I then have further quantity's that work out correctly.
What I need to be able to do is some sort of weighted value, for 2 off the unit price needs to be near the £20 a unit mark, then 3 off less etc until I get to 10 off # £5.159 a unit.
(It costs more for lesser quantity's, we want to encourage more qty)
Has anyone implemented something like this? From 10 qty onwards the calculation is fine as the unit cost changes are not much at all.
Thanks
Assuming you have quantities form 1 to 10, in column A, put 23.25 in B1 and 51.59 in B10, then the following formula in B2:
=B1+(B$10-B$1)/9
And populate down to B9
in C1 use the following formula:
=B1/A1
and populate down. Final result should look like this:
You could use vlookup with a table as so:

(Excel)Calculating costs, where prices differ based on quantities

I'm looking for some help as I'm not really sure of the correct terms to use on my query below, so whilst normally I would google this, I'm not really sure what to search for.
I need to work out the total cost for something, where you have a flat rate, and then an additional cost that changes depending on how much of something you have.
So an example, you get expenses paid for millage. If you drive 0-20 miles, you'll get £10. Between 30-50 miles you get 50p per mile. Between 51-100 miles you get £1 per mile and so on, added onto the base rate of the initial £10 you'd get paid as standard.
It's not the best example, but hoping it gives an idea of what I'm after.
If I was doing this by hand I'd know how to work it out, but I'm not to sure what kind of formula I need to be using - I've never had to work with complex formulas past "=sum" until now.
If anyone has any examples they can share or can point me in the right direction of what kind of things to google I'd be most grateful !
Thanks
Well, here is one way, but you don't state what the rate is between 21 and 30...
very basic, but you should be able to edit and expand as you want.
Do note that the limits (30 miles, 50 miles) and rates used in the formula all come from the sheet - so if the 30 mile limit changes to 25 miles - all you need to do is change cell A7...
I apologize for not answering sooner, but I find this question a bit difficult to address due to the complexity of formulas we can encounter. I know the one you documented is not the most complex one we might encounter, but I was not sure if that was your actual problem or if it was intended as a simple example. I have seen a variety of other things which have often thrown me for a loop.
For example, take this set of rules:
Minimum Fee is $23.50 up to $500
$501 - $2,000 = $3.05 per 100 unit increment
$2,001 - $25,000 = $14.00 per 1000 unit increment over $2,000
$25,001 - $50,000 = $10.10 per 1000 unit increment over $25,000
$50,001 - $100,000 = $7.00 per 1000 unit increment over $50,000
$100,001 - $500,000 = $5.60 per 1000 unit increment over $100,000
$500,001 - $1,000,000 = $4.75 per 1000 unit increment over $500,000
$1,000,001 - $9,999,000 = $3.65 per 1000 unit increment over $1,000,000
$10,000,001 and up = $3.65 per 1000 unit increment over $10,000,000
It does not look too different from yours except that there is an increment of something other than a single unit. In other words for the $501 to $2,000 range, $501 to $600 would all get the same additional $3.05 incremental charge. Another dollar would actually double this because it jumps to the next increment. Like your example, each range builds on the prior range. Assuming that these amounts are in colums A through F:
i Low High Fee Base Fee Per
0 1 500 23.50
1 501 2,000 $3.05 100
2 2,001 25,000 $23.50 1000
3 25,001 50,000 $10.10 1000
4 50,001 100,000 $7.00 1000
5 100,001 500,000 $5.60 1000
6 500,001 1,000,000 $4.75 1000
7 1,000,001 9,999,999 $3.65 1000
8 10,000,000 $3.65 1000
Note also that the rate declines as the amounts increase whereas yours appears to increase.
What I did with this is create a maximum value in Column H as follows:
i Max
0 =E3
1 =INT((C4-C3)/F4)*D4
2 =INT((C5-C4)/F5)*D5
3 =INT((C6-C5)/F6)*D6
4 =INT((C7-C6)/F7)*D7
5 =INT((C8-C7)/F8)*D8
6 =INT((C9-C8)/F9)*D9
7 =INT((C10-C9)/F10)*D10
8
The first one, where i is zero, is simply the base fee. The others are computed and copied. There is no maximum for the last row. I did not really think I needed this column but it made it easier to devise the formulas.
Assuming that I put an amount to evaluate in Cell I2, it will be evaluated as follows where the formula in row 3 (where i=0) is the set fee but all others are basically a copied formula:
i 4,950
0 =IF(I$2>=$B3,$H3,0)
1 =IF(I$2>=$B4,IF($H4="",INT((I$2-$C3)/$F4)*$D4,MIN($H4,INT((I$2-$C3)/$F4)*$D4)),0)
2 =IF(I$2>=$B5,IF($H5="",INT((I$2-$C4)/$F5)*$D5,MIN($H5,INT((I$2-$C4)/$F5)*$D5)),0)
3 =IF(I$2>=$B6,IF($H6="",INT((I$2-$C5)/$F6)*$D6,MIN($H6,INT((I$2-$C5)/$F6)*$D6)),0)
4 =IF(I$2>=$B7,IF($H7="",INT((I$2-$C6)/$F7)*$D7,MIN($H7,INT((I$2-$C6)/$F7)*$D7)),0)
5 =IF(I$2>=$B8,IF($H8="",INT((I$2-$C7)/$F8)*$D8,MIN($H8,INT((I$2-$C7)/$F8)*$D8)),0)
6 =IF(I$2>=$B9,IF($H9="",INT((I$2-$C8)/$F9)*$D9,MIN($H9,INT((I$2-$C8)/$F9)*$D9)),0)
7 =IF(I$2>=$B10,IF($H10="",INT((I$2-$C9)/$F10)*$D10,MIN($H10,INT((I$2-$C9)/$F10)*$D10)),0)
8 =IF(I$2>=$B11,IF($H11="",INT((I$2-$C10)/$F11)*$D11,MIN($H11,INT((I$2-$C10)/$F11)*$D11)),0)
The Fee for this is the sum of all of the rows (labeled i, 0 through 8 above). in this example, it would be 23.50 plus 45.75 plus 28.00 for a total of 97.25.
Not too bad. How about a set like this:
No fee if $1,000 or less
$1,001 - $5,000 = $80.00 + 3% of excess over $1,000.00 per 100 unit increment
$5,001 - $10,000 = $250.00 + 2% of excess over $5,000.00 per 500 unit increment
$10,001 - $25,000 = $350.00 + 1% of excess over $10,000.00 per 1000 unit increment
$25,001 and Over = $520.00 + 3/4% of excess over $25,000.00 per 1000 unit increment
In your formula, the initial flat amount never changes and once you've computed the amount for that range, other ranges build upon it. Here, there are steps. For example at $1,000 the fee is zero, but at $1,001, it jumps to $80 as if there were an $80 fee for the first 1000. Without boring you with the entire table, Here is the formula for computing the range from 5,001 to 10,000 assuming that G2 contains the amount to use and Row 5 colums A through E are the following:
Low High Rate Minimum Increment
5,001 10,000 2.00% 250 500
=($D5+$C5*INT(($G$2-($A5-1))/$E5)*$E5)*($G$2>=$A5)*OR($B5="",$G$2<=$B5)
The formula simply looks at the current row and does the computation if the amount in G2 falls within the range from Column A to Column B.
A simplification of all of the above comes when each range cumulatively builds on the prior ranges AND the rate of payment is always increasing, like the U.S. Tax Tables:
Over Not Over
0 9,525 10% of taxable income
9,525 38,700 $952.50 plus 12% of the excess over $9,525
38,700 82,500 $4,453.50 plus 22% of the excess over $38,700
82,500 157,500 $14,089.50 plus 24% of the excess over $82,500
157,500 200,000 $32,089.50 plus 32% of the excess over $157,500
200,000 500,000 $45,689.50 plus 35% of the excess over $200,000
500,000 $150,689.50 plus 37% of the excess over $500,000
Here, we can use something referred to as the "deskpad method" to shortcut the computation
Assuming that the amount to be evaluated is in G1 and these are in column A through C starting in Row 1:
Over Not Over Rate
0 9,525 10.0%
9,525 38,700 12.0%
38,700 82,500 22.0%
82,500 157,500 24.0%
157,500 200,000 32.0%
200,000 500,000 35.0%
500,000 37.0%
We compute the amount based on G1 as follows:
=ROUND(SUMPRODUCT($C$2:$C$8-$C$1:$C$7,$G$1-$A$2:$A$8,N($G$1>$A$2:$A$8)),0)
Note: this is not entered as an array formula.
How does this relate to your question. If the need is as simple as you stated (in other words, the rate is always increasing and we do not have any "steps" in the reimbursement, we can compute it similarly to the U.S. Tax computation.
I created these values in columns A through D starting in row 1:
Over Not Over
0 20 £- Flat Amount of £10.00
20 50 £0.50 £10.00 plus £.50 per mile over 20 miles
50 100 £1.00 £25.00 plus £1.00 per mile over 50 miles
100 £1.50 £75.00 plus £1.50 per mile over 100 miles
where column D is just descriptive. I put the £10.00 flat fee in Cell E1.
Assuming that G1 contains the number of miles, we would compute the reimbursement as:
=$E$1+ROUND(SUMPRODUCT($C$2:$C$5-$C$1:$C$4,$G$1-$A$2:$A$5,N($G$1>$A$2:$A$5)),2))
For example, when G1 is 52 miles, the computation is £27.00
Note: this is not entered as an array formula.
So, if this is the situation, what you would need is a place to house Columns A through C, a place to house the flat amount and a formula similar to what I provided to compute the reimbursement based on the cell housing the number of miles.
Please note that all the earlier items indicate that this formula will not be so simple if the rate is stepped or the rate declines or if the incremental unit is something other than 1 mile.
I hope that some of this makes sense. Good luck.
Things to google : "nested IF in excel"
How to do this in a one-line-formula : enter " =IF(A1<20,10,IF(A1>50,IF(A1>50,10+A1,"u"),0.5*(A1))) " in B1, your milage in A1.
To learn building this :
identify the conditions :
condition1 > 0-20 miles, you'll get £10.
condition2 > between 30-50 miles you get 50p per mile
condition3 > between 51-100 miles you get £1 per mile added onto £10
put the conditions into IF() statement
For contition1 > just type " =if(a1<20,10,0) " at B2 (and try it!) (:
Note : The syntax for IF() function is if("condition","if-true-do-this","if-false-do-this")
Thus, for condition2 > " =if(a1>20,a1*0.5,0) "
And for condition3 > " =if(a1>50,if(a1>50,10+a1),0) " correction : should be " =if(a1>50,10+a1,0) "
Combining all the conditions > "=IF(A1>20,IF(A1>50,IF(A1>50,10+A1,"error"),0.5*(A1)),10) "
Notice that I changed 0 in the "if-false-do-this" part of the equation just to make sure it show something when the milage entered is less than 0.
Hope that helps. /(^_^)

Excel Formula, To Calcuate a maximum Weight based off a desired minimum profit (GP%)

So I am working on a spreadsheet for a Butchery I manage and have run into a problem.
First off back story: We do $20 packs for certain bulk products that have a min/max weight range.
The Goal is to be able to put in this spreadsheet the desired minimum GP% and from that get a maximum weight based off that minimum profit margin.
For example a Beef Steak that Costs $17.50 p/kilo Would be minimum of 680g (at a GP% of 30.30%) and a maximum weight of 790g (at a GP% of 20.50%)
I have been 'googling' all day, and banging my head on my desk (as well as experimenting with different formula's) I am starting to think I may have to resort to programming a macro to perform this but I would prefer to be able to achieve in a formula on the cell that way I can copy-paste easily down the spreadsheet.
If anyone has a solution or can put me on the right track would be Awesome.
I think the formula you are looking for is :
your selling price (=20$) / your mark up on cost
where your mark up is :
your cost per kilo / (1- your margin)
So for 20% expected GP it gives :
= 20 / (17.5 / (1-0.2))
= 20 / 21.875
= 0.914... kilos
Balance is then :
Revenue = 20$
Cost = 0.914 * 17.5 = 16
Margin = 4
Margin % = 20

Create an excel formula for "buy one, get the rest 50% off"

I need to create a formula in excel that will kind of do a "buy one item, get the rest at 50% off".
I need excel to pick the most expensive item and charge it at full value, then charge the rest at 50% of their value:
Item A=$30
Item B=$21
If on day one, item A was bought 2 times, and then item B was used once, I need excel to pick out the most expensive item of the day (which would be item A) and charge it at 100% of its value ($30) and then the for the second item A, charge it at 50% of its value ($15) and item B would also be at 50% of its value ($10.5). So the total charge for the day would be $55.50.
I have set up names for each item that correlates to its price. If I put =sum(itemA) in a cell in excel, then it comes up with 30.
I have it set up so that I can put in the number of each item that was bought and excel can multiple it for me =sum(itemA*2)-->60. I just need to figure out the 50% discount for all of the items bought in one day.
Please help, and let me know if there is anymore info that I need to share!!!!
ADDITIONAL:
I have added three items using the name function under "define name". Item A is equal to 30, item B equal to 21, item C equal to 15. So this is what I have set up for example, for day one:
Item Quantity Total price
item A 2 60 =sum(itemA*2)
item B 1 21 =sum (itemB*1)
item C 0 0 =sum (itemc*0)
total daily charges: 81 =sum(C2:C4)
total daily charges with discount: 55.5 (THIS IS WHERE I NEED THE FORMULA!)
ADDITIONAL:
Ok, so after working with this formula, I have another question:
I have two set of this data, and excel will pick the most expensive of the two sets and charge 100% and then charge the rest at 50%. However, I now need a way to separate out the charges for the two sets of data and get their total. So example:
Item A=30, item B=21, item C=15
Set one: item A used 2x, item B used 1x
Set two: item B used 1x, item C used 1x
Excel picks item A (as this is the highest in both sets) and charges it at 100% (30), then charges the rest of the items at 50% (43.5). The total that is charged is 73.5
Now I need excel to separate out the charges by set.
So set one, the charge is 55.5
set two, the charge is 18.
Please let me know if additional details are needed.
Assuming a layout as A:e below, three added columns might suit, with:
in F2: =MAX(IF(A:A=G2,C:C))
in G2: =IF(A2<>A3,A2,"")
in H2: =IF(G2=0,"",0.5*SUMIF(A:A,G2,E:E))+F2/2
each copied down to suit.
The first an array formula so entered with Ctrl+Shift+Enter.
The first identifies the daily maximum unit price (before discount).
The second to identify the daily summary.
The third for the calculations (same approach as #Ron Rosenfeld).
Depends on how you set things up, and you don't show that. It might be simpler to use an algorithm that computes 50% of everything, then add back 50% of the most expensive item. So if you have three columns: Items Prices Quantity, (where Prices = Price/Item) you could use a formula like:
=0.5*MAX(Prices)+SUMPRODUCT(Prices,Quantity)*0.5
If some entries in your "Quantity" column might be zero or blank, then use this formula instead:
=SUMPRODUCT(MAX(Prices*(Quantity>0))+SUMPRODUCT(Prices,Quantity))*0.5

Using the Excel's Rank() function to calculate allocations based on ranking and constraints

I have the following table set up
Limit Allocation Yield Ranking
$600 [to calc] 0.07% 7
$600 0.09% 6
$600 0.20% 1
$400 0.20% 1
$400 0.13% 4
$200 0.19% 3
$200 0.12% 5
Additionally, I have a constraint which I could only allocate a total of $2000 across the 7 rows here, by the rankings of their yield (so a higher yield would get everything allocated up to the limit column if there is any left overs from the $2000 total).
I was wondering how I could set up the equations so that it could perform the allocation automatically. Thanks!
I'm going to assume this table starts in A1...
In E1, put the amount you have to allocate
In B2 (and then copied to B3...B8) use the following formula
=MIN(A2,$E$1-SUMIF($D$2:$D$8,">"&D2,$B$2:$B$8))
This will work out how much has been taken by higher ranked, and take the rest, upto whatever is the lesser amount of their limit, and what is left in the pot.
There is one fault with this equation that you will need to figure out how to handle:
If there are equal ranks at the end of the distribution, then both will get the final amount. (e.g. try this with $2,001, and you will see that the 2 rows that have then rank 1 will both claim the final dollar)
Answer to solve the ties for rank causing problem. In the rank column D, add to the rank =rank(c2,$c$2:$c$8,0) + (.0000001 * row(a2)), or whatever row you are in. Then format the rank column to only show integers. Doing this makes the very small decimal addition to the rank the tie breaker so the first row with the rank's matching integer will take the allocation. Since you are adding it to the rank, it doesn't effect any totals. By changing the column format display to integer, the viewer will not be aware of the tiebreaker.

Resources