Sum to a max based on ranking, and use partial values

JohnnyMango

New Member
Joined
Jul 16, 2021
Messages
2
Office Version
  1. 365
Platform
  1. MacOS
Hi all

This is my first post, so apologies if I do anything wrong. I'm pretty rusty with Excel, and am struggling to do even basic things, which is quite frustrating!

I've searched for an answer and this thread came close: Sum to a max value based on ranking

It gave a good answer on how to sum to a max value based on ranking. However, I would like to know if it's possible to do this, but to include a portion of the final cell value (if needed) to get to a total.

So, let's say you have 10 machines (or rows), ranked from cheapest to run to the most expensive (but the rows are not in that order), and each of them can produce 200 iPhones. However, you want 1100 iPhones, so, as in the thread linked above, the formula should display 200 for ranks 1 to 5, but then also 100 from the machine ranked 6 (and zero for machines ranked 7 to 10).

Can this be done using MIN? I can't think how to do it in a way that isn't circular, but I feel like I'm being a bit stupid.

I hope that made sense. (I'll install XL2BB before asking any further questions!)

Any help much appreciated.

Johnny
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I've done similar recently, from your description I think that this should do it when you substitute the descriptions for your sheet ranges. Note that @Rank refers to the rank cell in the row with the formula rather than the whole rank column.
Excel Formula:
=MEDIAN(0,Capacity,1100-SUMIFS(capacity,rank,"<"&@rank))
If you have tied / equal ranks then it will be a little more complex.
 
Upvote 0
I've done similar recently, from your description I think that this should do it when you substitute the descriptions for your sheet ranges. Note that @Rank refers to the rank cell in the row with the formula rather than the whole rank column.
Excel Formula:
=MEDIAN(0,Capacity,1100-SUMIFS(capacity,rank,"<"&@rank))
If you have tied / equal ranks then it will be a little more complex.

Thank you! That works really well. I really appreciate your help.

The problem of equal ranks may not be such an issue, but if it is do you have a way to deal with it? (Or is there a way to use a second criteria when ranking things? So in the event of a tie a second criteria will separate them, so that there are no ties?)
 
Upvote 0
For tie breaks it would need to be something like this, for simplicity I've assumed that Capacity is in column A and rank in column B with headers in row 1 (which the second sumifs is looking at) first formula in row 2.
Excel Formula:
=MEDIAN(0,$A2,1100-(SUMIFS($A$2:$A$20,$B$2:$B$20,"<"&$B2)+SUMIFS($A$1:$A1,$B$1:$B1,$B2)))
This method should look at all rows for lower ranks and the rows above the formula for equal ranks. You will need to be careful with the $ symbols and the row offsets when setting this one up, if they are not aligned correctly then the results could be unpredictable.

If this doesn't work as needed then I would most likely need to see an example of the data layout to determine why.
 
Upvote 0

Forum statistics

Threads
1,215,337
Messages
6,124,340
Members
449,155
Latest member
ravioli44

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