Closed Thread
Results 1 to 13 of 13

Summing portions of a column until certain value is met

  1. #1
    Registered User
    Join Date
    10-10-2009
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Question Summing portions of a column until certain value is met

    I have been trying to find the best way of solving the problem without success. Any advice from the experts out there would be greatly appreciated.

    For Segment 1 (Column D), I need a formula which sums the volumes in column B until the SumTotal Volume in Column E (Volume) is met or nearly met. There will be very few circumstances where there is an exact match so the sum calculated needs to be as close as possible to the volume in Column E. Whichever cell in column B is added last to reach the necessary sum, I need the adjacent cell from column A to be input into the yellow box in Column G. I've done them partly by hand and using some formulas based on how a similar problem was solved on another forum an example of the data that should appear. (e.g. Starting at Raw Point 0, it took up to a Raw Point 25 to reach the sum volume of 3.97 which is the number closet to 4. If we had gone to raw Point 26 the total would have been 4.78 which is further away from 4 than 3.97).

    For Segment 2, I need the start Raw Point to be 1 greater than the end Raw Point from segment 1. (e.g. starting at a Raw Point of 26, it took up to a Raw Point of 31 to reach a volume of 6.49 which is the number closet to 7). And so on.

    Please let me know what are the best formulas to put into the yellow boxes. A very similar problem was solved on another forum - http://www.mrexcel.com/forum/excel-q...value-met.html. I have tried to replicate this but unfortunately this formula seems to fail when it reaches Segment 6 and beyond. Is there something I am doing wrong? Any help or advise with this will be appreciated
    Attached Files Attached Files

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Summing portions of a column until certain value is met

    Hi and welcome to the forum!

    What should the results be for Segment 6 onwards?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Summing portions of a column until certain value is met

    Apologies - I just realised that your column is a mixture of the formula results up to Segment 5, and your manually-inputted desired results after that.

    Regards

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Summing portions of a column until certain value is met

    Your main issue is that you appear to be wanting these partial sums to be taken over ranges the end point of which is determined by an absolutely closest value ("3.97 which is the number closet to 4. If we had gone to raw Point 26 the total would have been 4.78 which is further away from 4 than 3.97)."

    However, the formulae you are using do not appear to be consistent with this criterion, as they are seeking the point at which subsequent totals are surpassed.

    I think you need to decide first and foremost whether or not you have the flexibility to adjust your criterion for absolutely closest to e.g. "smallest value greater than" (though in that case you probably wouldn't be here as you already have that solution!) or if you are insistent that it must be the former, in which case there is work to be done, which I will start looking at now whilst awaiting your response.

    Regards

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Summing portions of a column until certain value is met

    Ok, this array formula (in G2 and copied down) should work for the absolutest:

    =INDEX($A$2:$A$62,MATCH(TRUE,ABS(SUBTOTAL(9,OFFSET($B$1,MATCH(F2,$A$2:$A$62,0),0,ROW($B$2:$B$62)-ROW($B$1)+1))-$E2)=MIN(ABS(SUBTOTAL(9,OFFSET($B$1,MATCH(F2,$A$2:$A$62,0),0,ROW($B$2:$B$62)-ROW($B$1)+1))-$E2)),0))+F2+1

    though I disagree with your desired result for Segment 7 (and therefore Segment 8), and the result will currently be #N/A for Segment 9 (there is no Raw Point of 61 in your source data).

    Regards
    Last edited by XOR LX; 10-22-2013 at 11:01 AM.

  6. #6
    Registered User
    Join Date
    10-10-2009
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Summing portions of a column until certain value is met

    Thanks very much for your efforts on this. I now see how complicated this might turn out to be. What I am trying to do is recalibrate a lot of data to fit into a 9 segment model. Using this model I need data to be assigned to each segment so that the model makes sense - i.e. the data must fit as close as possible to volume totals you see in column E (these are percentages that add up to 100%). Therefore to get a meaningful result we need to have some data showing for each segment. So having no data under Segment 9 makes the data unusable. Currently I am doing this summing up manually - which is very painful across 45 tabs). How we assign this data seems to be the issue? As you suggest if I have to pick a summing method I would say there might be 2 options (1) use the total just before or equal to volume total (2) use the total within 10% of our required figure (whether its bigger or smaller). Does that make sense? Is this even possible? Is there maybe some other way to achieve this result - maybe I have tried to force a formula that doesn't really work for this situation.

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Summing portions of a column until certain value is met

    Have you tried my proposed solution (which takes the absolutely closest)? Apart from the final Segment (which should be an easy workaround), were you happy with the results for the others? Or did you perhaps disagree with them?

    Regards

  8. #8
    Registered User
    Join Date
    10-10-2009
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Summing portions of a column until certain value is met

    Hi,

    Yes your solution is very good - the numbers coming out are very suitable to what I need except for final segment. What kind of workaround do you suggest?

    One guidance that might be useful. When I do this manually, I find that the outer categories - i.e. the 4% and 7% categories are often most difficult to deal with. They are often too big or too small - so for example I often have to accept 2% at the top or the bottom, though I was hoping for 4%. It would be helpful if these outer categories were as close to the target as possible while the middle ones can vary a bit more. Maybe the formula could say for the 4% categories we can accept 4.7 max before one category of rawpoints become part of the 7% group, etc. Does this make sense?
    The above are just some thoughts which might not be possible to implement in excel. Once again thanks for all your help - you have made me think a bit more about this.

    Regards

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Summing portions of a column until certain value is met

    What do you want the final entry for End Raw Pts to be in these cases, i.e. when the adjacent/corresponding Start Raw Pts is equal to or greater than it?

    Artificially created to account for the Volume 4 in that row, i.e. an End Raw Pts of 63, say, even though this isn't in your range? (Mind you, neither is 61, which is the Start Raw Pts value you'd have in that row based on my current formula.)

    Or perhaps simply equal to the very last entry in the Raw Points column, i.e. 60?

    Regards

  10. #10
    Registered User
    Join Date
    10-10-2009
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Summing portions of a column until certain value is met

    This should simply equal to the very last entry in the raw points column - this is always 60.

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Summing portions of a column until certain value is met

    Ok, but then that would make both the final and penultimate End Raw Pts values 60 in this case - is this what you want? And remember, the Start Raw Pts for Segment 9 is 61, which would mean it is greater than the corresponding End Raw Pts value.

    Or should the number of Segments finish at eight in this case? Is that possible? Or does it always have to be nine?

    Regards

  12. #12
    Registered User
    Join Date
    10-10-2009
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Summing portions of a column until certain value is met

    Unfortunately not. I would need to have all segments shown so we must have segment 9 represented. The issue here is the formula is not able to approximate close enough to the percentages which unfortunately leaves segment 9 with no data. I can see what I am asking for may not be feasible. Could we maybe design the formula to only sum up to the target percentage level (e.g. 4%) and reject any sums beyond the target level? I think that way will ensure there is some left over for level 9? If Segment 9 goes beyond its target that will be fine. Hope that makes some sense. Appreciate all your help on this.
    Regards
    Last edited by almugs; 10-22-2013 at 05:53 PM.

  13. #13
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Summing portions of a column until certain value is met

    Thread posted in CS subforum to speed up resolution, hence closed.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Chart only portions of table that have a value in the first column
    By debbiemccann in forum Excel General
    Replies: 2
    Last Post: 06-08-2012, 10:46 AM
  2. Replies: 3
    Last Post: 03-29-2012, 10:06 AM
  3. Please help conditional summing numeric portions of text entires
    By Jac Flasschoen in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-21-2011, 05:11 PM
  4. Sharing Portions of a spreadsheet
    By scottma in forum Excel General
    Replies: 4
    Last Post: 02-27-2009, 11:39 AM
  5. Formatting portions of a cell
    By Linking to specific cells in pivot table in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-07-2006, 12:45 PM

Tags for this Thread

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