+ Reply to Thread
Results 1 to 27 of 27

Distribute a number from a cell across others based on the percentage of another cell

  1. #1
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Distribute a number from a cell across others based on the percentage of another cell

    I have a total of 100 oranges available to 4 teams. I want them to pick 50 aggregately.
    Each team only has a percentage of the 100 available to them (Team 1 30%, Team 2 20%, Team 3 40%, Team 4 10%).
    I want to assign each team a "fairshare" of that 50 based on the percentage of the 100 they have.

    The total MUST be equal to 50. And must be a whole number.

    Is this possible with a formula?

    In real life, the oranges are people and there are a total of 28 teams.

    I started with this
    Please Login or Register  to view this content.
    to assign each team their respective share but, doesn't work for all the different "fruit". For Oranges it works but, as the total fruit available changes and the percentage each team has available to them changes, the total can be over or under the aggregate amount of fruit to pick as you can see in this sample with "Apples", the total fruit assigned, doesn't equal the aggregate in column C.

    I've updated the attachment to have the actual current formulas I'm using. Oranges the current formula works out perfectly, Apples you will see the issue in column H.
    Last edited by TachyonStiggy; 02-14-2022 at 02:53 PM. Reason: Update with more info and updated excel sample.

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Distribute a number from a cell across others based on the percentage of another cell

    Tricky since you're working only with integer values so you can't guarantee that the split will work out. Your second row is asking to split 11 in ratio 7:2:7:7. Which answer would you prefer? 3,2,3,3 or 3,1,3,4? The second option could be achieved by changing the formula in column G:

    Please Login or Register  to view this content.
    The first option would be trickier to implement - I'd need to put on my thinking cap for that one!

    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    WBD, first thank you for responding! I would honestly prefer a third option of 3,1,4,3. Reason being that Team 3 has a higher total amount of fruit available.

    I've updated the excel and added two rows, one adds the total amount of fruit available for each team (apples and oranges combined), the second Ranks the team with the highest amount.

    So, if the value in column H is lower than column C, I'd like the formula to add 1 to the highest ranked team (and down) until H=C. And subtract 1 if H>C.

    I have a feeling this cannot be done with a formula.


    For what I need it for, there are around 170 "fruits" and 28 total teams and historically we've done about 80% with formulas then, went down each of the fruits and manually adjusted the amounts each team needs to gain.

  4. #4
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Distribute a number from a cell across others based on the percentage of another cell

    OK. I had to use a helper column in J and also use the computed rankings. It's a little complex but I think it works; at least for your data that you have!

    See attached.

    WBD

  5. #5
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    Totally OK with a helper column, I'll admit I got a bit of a headache trying to figure out exactly what it was doing but, I copied it.

    Everything was looking promising as the first cell I pasted the updated formula into was dead on, then as I applied it down the list and across each of the teams, the formula started throwing out negative numbers (which I totally forgot to mention cannot be the case). For my application, there will be times where a Team will have no "fruit" available, and if that is the case they'd be assigned 0.

    The formula you posted worked beautifully when I applied it to the small sample though, and I got super excited for a second :D

    These calculations would be done one time a year, so I don't know if it's something I should post in the Macro/VBA section? Although, I'm very intrigued by the fact your formula worked perfect in the small sample.
    Last edited by TachyonStiggy; 02-11-2022 at 01:39 PM. Reason: New info.

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Distribute a number from a cell across others based on the percentage of another cell

    We might be in a better position to help if we could see a sample that shows where the formula produced negative numbers.
    That said I took a different approach:
    1. D10:G10 are populated using a pseudo banker's rounding formula: =IF(ISODD(D5),ROUNDUP(D4/SUM($D4:$G4),2),ROUNDDOWN(D4/SUM($D4:$G4),2))
    2. D2:G3 are populated using: =MAX(0,$C2*D$10)
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  7. #7
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    Quote Originally Posted by WideBoyDixon View Post
    OK. I had to use a helper column in J and also use the computed rankings. It's a little complex but I think it works; at least for your data that you have!

    See attached.

    WBD
    Quote Originally Posted by JeteMc View Post
    We might be in a better position to help if we could see a sample that shows where the formula produced negative numbers.
    That said I took a different approach:
    1. D10:G10 are populated using a pseudo banker's rounding formula: =IF(ISODD(D5),ROUNDUP(D4/SUM($D4:$G4),2),ROUNDDOWN(D4/SUM($D4:$G4),2))
    2. D2:G3 are populated using: =MAX(0,$C2*D$10)
    Let us know if you have any questions.
    Thank you both again for the assist, it has been doing my head in for the better part of a week...

    I've massively redacted/sanitized my actual working document and attached it. I've added tabs for my original, then the WBD tab, and JETEMC's. All my original formulas are still present.
    Basically, the only time I want the "rank" to come into play is if column AE is not exactly equal to column C.

    You can now see where WBD's is giving me negative numbers.

    On my original you will see it is like a 99% solution. It counts the total of "fruit 1" that "team 1" has available, then divides that by the total amount of "fruit 1" available to all teams, and multiplies it by the "quota".

    Teams may have a massive amount of "fruit 1" available, and none of "fruit 2" so, I cannot tell that team to pick anything of something they don't have...

    Feel free to tell me to get bent I've searched for how to proportionally distribute for the last 2 weeks and I cannot get anywhere on what I've found... They all seem to work for the samples provided (just as each of yours have) but when I apply the same logic to my situation, the numbers get thrown off.
    Attached Files Attached Files
    Last edited by TachyonStiggy; 02-12-2022 at 03:46 PM. Reason: typo

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Distribute a number from a cell across others based on the percentage of another cell

    There are some real genius contributors on this site, and I hope one of them will give you an elegant solution.
    Perhaps my proposal, modeled on the FRUIT ASGN (TACHYONSTIGGY) sheet, will help until then.
    1. I added a column on the Fruit Avail sheet that displays the team number using: =MID(D2,6,3)+0
    2. I put the following into AF2:AG10 to show the next teams that could pick a particular fruit:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    3. I put the following into AH2:AH10 to show the team assigned a fruit that is being over picked: =IF($C2< $AE2,"TEAM "&AGGREGATE(14,6,MID($D$1:$AD$1,6,3)/($D2:$AD2>0),1),"")
    4. I populated a new pick range in AI2:BI10 using: =SUM(D2,IF(OR($AF2=AI$1,$AG2=AI$1),1),IF($AH2=AI$1,-1))
    Note that the columns could be added to AF2:AG10 or AH2:AH10 if you find the values in column AE are off by more than one or two.
    Let us know if you have any questions.

  9. #9
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    Quote Originally Posted by JeteMc View Post
    There are some real genius contributors on this site, and I hope one of them will give you an elegant solution.
    Perhaps my proposal, modeled on the FRUIT ASGN (TACHYONSTIGGY) sheet, will help until then.
    1. I added a column on the Fruit Avail sheet that displays the team number using: =MID(D2,6,3)+0
    2. I put the following into AF2:AG10 to show the next teams that could pick a particular fruit:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    3. I put the following into AH2:AH10 to show the team assigned a fruit that is being over picked: =IF($C2< $AE2,"TEAM "&AGGREGATE(14,6,MID($D$1:$AD$1,6,3)/($D2:$AD2>0),1),"")
    4. I populated a new pick range in AI2:BI10 using: =SUM(D2,IF(OR($AF2=AI$1,$AG2=AI$1),1),IF($AH2=AI$1,-1))
    Note that the columns could be added to AF2:AG10 or AH2:AH10 if you find the values in column AE are off by more than one or two.
    Let us know if you have any questions.
    I think we have a winner here... This looks like it could work, I really only have one question... Why did you add the column to display just the team number, instead of just using the column with the Team name that already existed? I can only assume it needed to be that way to work correctly?

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Distribute a number from a cell across others based on the percentage of another cell

    Good catch. Column E has been removed and the formula for columns AF:AG has been modified to read:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.

  11. #11
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    JeteMc, you are a gentlemen... It won't let me add more reputation to you but, I've tried. I've been working on adding it to my actual workbook now, ran into some hiccups but, I think I can make this work without asking anything else of you right now. When I'm finished, I'll post again. THANK YOU!

  12. #12
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    EDIT: I figured out how to duplicate it (leaving the below as a reference for myself later), the issue was in the "under assigned" columns, you used the reference as the columns... For the "over assigned" you just had it as a "1" like below
    Please Login or Register  to view this content.
    once I added the columns to that reference/k It stopped duplicating it...
    Please Login or Register  to view this content.
    I have marked this as solved however, I may have another issue... Have to run to an appointment. Again, if I could add more rep to you boss, I would.

    Quote Originally Posted by JeteMc View Post
    3. I put the following into AH2:AH10 to show the team assigned a fruit that is being over picked: =IF($C2< $AE2,"TEAM "&AGGREGATE(14,6,MID($D$1:$AD$1,6,3)/($D2:$AD2>0),1),"")
    I am about 99% finished. The biggest issue I have now is, I cannot figure out how to duplicate
    Please Login or Register  to view this content.
    that is in column AH. I was able to duplicate AF:AG with no issues but, when I applied the same logic to AH I get the same team listed in each of the new cells... Example, if AE is 3 higher than C, then columns AH (and then AI and AJ) all return the same Team. I tried editing the formula to
    Please Login or Register  to view this content.
    but, I get the same result. (Note: Where the headers show D2:AD2 it is because on my workbook I had to actually add under a new Row under Row 1 that identifies each Team as "Team #", the actual Teams have individual names that don't follow any logic) :D
    Last edited by TachyonStiggy; 02-14-2022 at 02:53 PM. Reason: Figured out my problem, editing message text.

  13. #13
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Distribute a number from a cell across others based on the percentage of another cell

    I believe that the following will do what you want:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    If not please upload a sample that shows where the formula isn't working.

  14. #14
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    I edited my last response, and while I was doing so you responded... Thank you again boss, I have amended the OP to reflect Solved. I may have another issue but, I think it is on my end and not the formulas... This will save me so much time now!

  15. #15
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    I cannot express enough how grateful I am right now for what you've done so far JeteMc...

    I've uploaded a sample of the so very few instances where the formulas aren't working. I took your new pick range and brought it to the left because the over/under-assigned could potentially be larger in the future.

    I have a filter in place right now to only have the fruit where the formulas aren't working to display. It took me longer to sanitize the attachment than it did for me to apply your formulas to it.

    Of note, rows 1&2 are effectively duplicated due to the redaction required, references to "teams" should be row 2.
    Attached Files Attached Files

  16. #16
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Distribute a number from a cell across others based on the percentage of another cell

    In the case of fruits displayed on the RED POP % sheet all teams that have those fruits available have been assigned an amount, which is a different situation from earlier examples where some teams that had a particular fruit available had not yet been assigned an amount.
    From an Excel standpoint a second IFERROR can be added that will add the difference between the values in columns C and BH to one of the teams which already has a value.
    So this becomes a non-Excel decision as to which of the teams should have that value added. As in the case of fruit 40 should the one extra unit be assigned to the team which is picking the most (1) or the team which is picking the least (11) or to one of the other teams. We will need to know the rational for the selection so that we can write a corresponding value_if_error argument.
    Let us know if you have any questions.

  17. #17
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    Apologies on that change, I guess that is what happens when only providing a "sample" and not the whole picture scenarios can fall through the cracks.

    To answer your question, as it pertains to Fruit 40 (and any others in the same situation), I would like the extra fruit(s) be assigned to the Team with the highest aggregate of all fruit assigned. I thought having the RANK row added at the bottom would help in this but, after you provided the current version and it is so close to a 100% solution I didn't think about adding it back. The RANK should be 1-27 no duplicates. I've added it to the bottom of this attachment, no other changes were made to the formulas.

    I cannot think of any additional curveballs for this, I'm relatively confident this sample captures all possible scenarios.

    Again, thank you!
    Attached Files Attached Files

  18. #18
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Distribute a number from a cell across others based on the percentage of another cell

    Team #1 has the highest aggregate of all fruits, yet when the Red Pop % is filtered by fruit and team, team 1 is not assigned fruit 72.
    The highest ranked team that is assigned fruit 72 appears to be team22.
    So, I am going to proceed on the assumption that you want the additional value added to the highest overall ranked team that has a particular fruit assigned.
    The formula for BJ26 is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.

  19. #19
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    Can we mark this super solved? JeteMc, I cannot express how appreciative I am. Thank you so much!

  20. #20
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Distribute a number from a cell across others based on the percentage of another cell

    You're Very Welcome. Thank You for the feedback and for marking the thread as 'Solved'. I hope that you have a blessed day.

  21. #21
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    Quick confirmation if able... If I wanted to "flip the logic" from first checking if the team has a fruit available and wasn't assigned a fruit to pick, to first adding to that team that was already assigned, I would change

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    to this

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    correct?

  22. #22
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Distribute a number from a cell across others based on the percentage of another cell

    The second formula starting with cell BJ3 and copied across and down would be:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Note that when I test using the file attached to post #18 and clearing the filter on column C, it causes problems in several rows including 6, 7, 15 etc.
    The first formula starting with cell BJ3 and copied across and down would be:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The first formula doesn't produce any problems when tested.
    Let us know if you have any questions.

  23. #23
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Distribute a number from a cell across others based on the percentage of another cell

    If I understand then you want to add the first additional value to the highest overall ranked team that has a particular fruit assigned and then if more values need adding they should be added to teams that have fruit available but not yet assigned.
    If that is accurate then the following will should work:
    For column BJ:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    For columns BK:BM
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.

  24. #24
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Distribute a number from a cell across others based on the percentage of another cell

    I still don't feel that I have answered your last question.
    Here is a formula that will check all previously assigned teams and then start adding values to teams that have fruit available but have not yet been assigned:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Hopefully one of these works for your purposes.
    Let us know if you have any questions.

  25. #25
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    Not sure why but, I wasn't getting the email notifications when you responded so, I apologize for the delay.

    Unfortunately, I did uncover an issue with the AGGREGATE function as it pertained to my application. As an example, in your latest attachment if you look at Fruit 49... Columns BJ:BM return the values; Team 1, Team 8, Team 4, Team 5. But, those aren't the teams with the highest assigned fruit, they would be Team 9, Team 3, Team 6, Team 8. I am pretty confident it is with portion of the AGGREGATE that is looking at the Team # and uses it as part of the calculation for the returned Team.

    I was able to find a different solution for the Columns BJ (expanded as needed) by using this Array Formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I also was able to apply it to columns BN:BP by changing the IF formula to match what you had already provided, but keeping the index formula.

    There were some other tweaks some of my peers have requested that I think I have figured out largely/mostly thanks to your assistance! Really appreciate it again. I've attached the document using the Array formula if interested.

  26. #26
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Distribute a number from a cell across others based on the percentage of another cell

    The aggregate formula was using the ranks in row 151 to arrange the teams, however it seems I didn't understand that "highest" meant the largest number in row 151. I took it to mean that the team ranked 1st should get the first extra value.
    According to row 151 Team 1, Team 8, Team 4, Team 5 are the 1st, 2nd, 3rd and 4th ranked teams, while Team 9, Team 3, Team 6, Team 8 are the 9th, 7th, 5th and 2nd ranked teams.
    Interestingly the SMALL IF formula skips team 7 which is the 8th ranked team and team 2 which is the 6th ranked team.
    Modifying the AGGREGATE formula as follows shows TEAM 9, TEAM 7, TEAM 3 and TEAM 2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.

  27. #27
    Registered User
    Join Date
    02-10-2022
    Location
    USA
    MS-Off Ver
    Professional Plus 2016
    Posts
    14

    Re: Distribute a number from a cell across others based on the percentage of another cell

    Not a mistake on your part, the "non excel" logic behind the decisions on how to populate column BL and beyond have changed from when I had originally posted. As of yesterday, they do not want a team that didn't already have an assigned fruit BE assigned a fruit. They want the Team(s) that have the highest assigned for that particular fruit be the ones that are either given the extra to pick, OR have the fruit removed if it was over assigned.

    Again, thanks to everything you've provided I've been able to tweak this anytime one of my peers have made a recommendation.

    I guess my understanding of the AGGREGATE function with the divisors is messing with my head. When I was playing with the formulas if I would drop that MID(AG2:BG2,6,3) off the equation it would display the correct team so, I just assumed it was that throwing it off.

    As for Row 151, now (different from a few days ago) the only time that row should be referenced is if there is a tie between two teams for a particular fruit that would be assigned extra, or dropping the excess from.

    Either way, you've helped tremendously throughout this process. I appreciate it!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Distribute number in one cell evenly across 5 other cells (round up if necessary)
    By b1ke in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-20-2022, 01:19 PM
  2. How to distribute a number in Excel based on percentage?
    By Sybon in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-12-2021, 06:19 AM
  3. [SOLVED] How to evenly distribute work based on cell values and number of employees?
    By AccountingJ in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-09-2019, 12:50 PM
  4. [SOLVED] distribute number on excel cell according to value
    By mazan2010 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 12-05-2017, 12:12 PM
  5. Replies: 2
    Last Post: 04-04-2013, 12:44 AM
  6. Replies: 3
    Last Post: 01-31-2013, 09:38 PM
  7. Printout a number of sheet copies using Number fron cell?
    By ibmerlin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-13-2005, 02:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1