+ Reply to Thread
Results 1 to 10 of 10

Conditional Summing of the Top 80% of Data

  1. #1
    Registered User
    Join Date
    01-14-2012
    Location
    baltimore, md
    MS-Off Ver
    Excel 2010
    Posts
    4

    Conditional Summing of the Top 80% of Data

    All...I NEED AN EXCEL GENIUS, PLEASE!!! Looking for some help in Excel 2010 and what appears to be a very specific scenario. I have a data set that reflects sales for a specific category of items. Of the entire data set, I need to get to a total of the sales for only the top 80% of that group. Gets trickier because I then need to count that group to understand how many data elements make up the 80%. I see this as two separate formulas...data example is as follows

    (Column A) (Column B)
    Item ID Total Sales
    Item 1 $100,000
    Item 2 $5,000
    Item 3 $40,000
    Item 4 $10,000
    Item 5 $6,000
    Item 6 $10,000
    Item 7 $8,000
    Item 8 $4,000
    Item 9 $500
    Item 10 $3,000

    So for the above, I need one formula that says what the total revenue is for the top 80% of the items without exceeding the 80% threshold. So for the above, the formula should render a total of $140,000 and then I would need another formula that says the count of items to get this is 2. Make sense? I can't for the life of me get something to work. Please help!!! Thanks in advance!!!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Conditional Summing of the Top 80% of Data

    Hi,

    Is first sorting the data allowable?

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    01-14-2012
    Location
    baltimore, md
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Conditional Summing of the Top 80% of Data

    Thanks for your prompt inquiry. Unfortunately, in the actual data set, sorting is not ideal b/c of the size and various sub groups that I have within it.....is there a way to solve this issue with out sorting?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Conditional Summing of the Top 80% of Data

    Hi,

    There may be a complex compound formulao involving array formulae and probably helper columns, but you may find the following user defined function is sufficient if there aren't hundreds of rows. If there are and it proves too slow then it could be modified into a binary bubble sort. At the moment it cycles through all values each time it decides whether the current array value it's sorting is less than the last one.

    enter in a cell
    =TOP(yourrange, "s") to get the Sum and
    =TOP(yourrange,"c"") to get the Count

    Please Login or Register  to view this content.

  5. #5
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Conditional Summing of the Top 80% of Data

    im not sure but percent rank may work this works on your data and gives the result you want,but it may be a coincidence
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,659

    Re: Conditional Summing of the Top 80% of Data

    Solution from martin wilson, without helper column:
    Please Login or Register  to view this content.
    Confirmed with Ctrl-Shift-Enter

  7. #7
    Registered User
    Join Date
    01-14-2012
    Location
    baltimore, md
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Conditional Summing of the Top 80% of Data

    Thanks for everyone's responses. Really appreciate everyone trying to lend a hand. Sadly, I'm still struggling to get any of these solutions to work (I should note that I am not an Excel genius like yourselves) I should have clarified that my data is not sorted so I will have multiple subcategories which need to be isolated and then have the top 80% calculations applied (totaling of the top 80% of sales for each subcategory and then the count of items that make up that 80%). Richard, your code is most intriguing and would be great to have a built in formula that gets to both...but unfortunately can't get it to work. It returns a #value! error when I attempt to use the formula. Any thoughts?

    Martin/Bebo, the percentrank formula is challenging because of the multiple subcategories within the larger population set. I can't seem to get this work for me either as it would have to be a conditional percentrank after identifying the subcategory. Assuming I could get this to work, I'm still challenged to do the count to identify those items that make up the top 80% in each categories.

    Please keep the suggestions coming...IT IS VERY MUCH APPRECIATED. thanks!!!

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Conditional Summing of the Top 80% of Data

    Hi,

    See the attached. Hopefully that will help

    Regards
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    01-14-2012
    Location
    baltimore, md
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Conditional Summing of the Top 80% of Data

    RICHARD YOU ARE A LIFE SAVER and A GENIUS. This is EXACTLY the kind of formula I'm looking for....I hate to ask for one more favor and this is totally on me for not clarifying up front, but is there anyway to make this "conditional" friendly...similar to the SUMIF function, is there a way to leverage the function to select only those items with a certain criteria and perform this calculation. I'm a proposing a TOPIF kinda of function....for example, using the same data set from before if I add in another descriptive column...such as...

    (Column A) (Column B) (Column C)
    Item ID Description Total Sales
    Item 1 Hat $100,000
    Item 2 Shirt $5,000
    Item 3 Shirt $40,000
    Item 4 Tie $10,000
    Item 5 Socks $6,000
    Item 6 Shirt $10,000
    Item 7 Shirt $8,000
    Item 8 Socks $4,000
    Item 9 Hat $500
    Item 10 Socks $3,000

    ....and I wanted to perform the "Top" function on only "shirt" group for example, is there a way to allow such criteria to be defined and have the formula adjust accordingly. I have about 15000 rows of data in total and need to segment this down to get to the top 80% sum and counts for each grouping. I apologize for imposing on you further but you are clearly very good at what you do and if this is possible, it would be HUGE for my analysis.

    Thank you so much!!!

  10. #10
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    365
    Posts
    2,243

    Re: Conditional Summing of the Top 80% of Data

    If you can use helper columns, see the attached.

    If you use these Array Formulas, you can avoid third helper column.

    K5,

    =IFERROR(MATCH(K3,SUMIF(OFFSET(F2,,,ROW(F2:F11)-ROW(F2)+1),"<9E300")),0)

    J5,

    =IF(N(K5),INDEX(SUMIF(OFFSET(F2,,,ROW(F2:F11)-ROW(F2)+1),"<9E300"),K5),0)

    If you have 15000 rows data, volatile function (OFFSET) may slow down the sheet performance.
    Attached Files Attached Files
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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