+ Reply to Thread
Results 1 to 19 of 19

How to find number of rows that meets cumulative percentage critieria

Hybrid View

  1. #1
    Registered User
    Join Date
    04-23-2008
    Posts
    7

    Cumulative percentage of unsorted data

    Hello. I have a dataset in Excel 2007 where I need to determine the number of census tracts (as rows) it takes for each column of data values (populations of different ethnic groups) to reach a cumulative percentage of 50% of their City group total. This is a measure of concentration that will vary from group to group.

    I can do this manually by sorting each column from largest population percentage to smallest population percentage, then shift-click selecting the first row, scrolling down until I see the sum of percentages shown in the bottom right corner first reaches 50.000% or more.

    Is there a cell formula I can use to determine the number of rows it takes to meet the criteria? I have to do this for 250 columns.

    Is there a cell formula I can use to determine the number of rows it takes for a column of data values to reach a specific amount, that is first reach a cumulative percentage of 50.000% of the column total? It must be based on the data values from largest to smallest but I don't want to have to manually sort each column I have.

    I need to do this for 250 columns so any help to make this easier would be appreciated.
    Last edited by shg; 04-23-2008 at 11:42 AM.

  2. #2
    Forum Contributor Portuga's Avatar
    Join Date
    02-20-2004
    Location
    Portugal
    MS-Off Ver
    365
    Posts
    852
    You could probably create a "count" column and then using an if statement/offset combination.

    It would help if you could attach a small sample of your data in format compatible with excel 97-2003
    If you found the solution to your question. Mark the thread as "Solved"
    Thank everyone that helped you with a valid solution by clicking on their

    There is no such thing as a problem, only a temporary lack of a solution

  3. #3
    Registered User
    Join Date
    04-23-2008
    Posts
    7
    Here is a small sample of my dataset. My full dataset has 250 columns of ethnic group populations and 2,000 rows of census tracts in three cities.

    I want a formula that will tell me how many census tracts (rows) it is until the cumulative population percentage of group1 reaches at least 50.000% of the group1 total without having to manually sort each column.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Try the following formula, which needs to be confirmed with CONTROL+SHIFT+ENTER...

    =MATCH(TRUE,MMULT((ROW(E5:E19)>=TRANSPOSE(ROW(E5:E19)))+0,LARGE(E5:E19,ROW(INDIRECT("1:"&ROWS(E5:E19)))))/E4>=50%,0)

    Hope this helps!

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Quote Originally Posted by Domenic
    Try the following formula, which needs to be confirmed with CONTROL+SHIFT+ENTER...

    =MATCH(TRUE,MMULT((ROW(E5:E19)>=TRANSPOSE(ROW(E5:E19)))+0,LARGE(E5:E19,ROW(INDIRECT("1:"&ROWS(E5:E19)))))/E4>=50%,0)

    Hope this helps!
    There's that MMULT/TRANSPOSE combination again Hey Domenic, how's it going?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  6. #6
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Quote Originally Posted by NBVC
    There's that MMULT/TRANSPOSE combination again Hey Domenic, how's it going?
    The bandit strikes again!

  7. #7
    Registered User
    Join Date
    06-14-2021
    Location
    London
    MS-Off Ver
    2010
    Posts
    6

    Re: How to find number of rows that meets cumulative percentage critieria

    Quote Originally Posted by Domenic View Post
    Try the following formula, which needs to be confirmed with CONTROL+SHIFT+ENTER...

    =MATCH(TRUE,MMULT((ROW(E5:E19)>=TRANSPOSE(ROW(E5:E19)))+0,LARGE(E5:E19,ROW(INDIRECT("1:"&ROWS(E5:E19)))))/E4>=50%,0)

    Hope this helps!


    Thanks very much !! this is very helpful.

    Could you please advance how can I make it return the sum of value which represent more than 50% rather than the count.

    Thanks so much.

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

    Re: How to find number of rows that meets cumulative percentage critieria

    Quote Originally Posted by Moatasem91 View Post
    Could you please advance how can I make it return the sum of value which represent more than 50% rather than the count.
    Since it is other people's thread, any further question, try to open a new one.
    Quang PT

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: How to find number of rows that meets cumulative percentage critieria

    Quote Originally Posted by Moatasem91 View Post
    Thanks very much !! this is very helpful.

    Could you please advance how can I make it return the sum of value which represent more than 50% rather than the count.

    Thanks so much.
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  10. #10
    Registered User
    Join Date
    04-23-2008
    Posts
    7
    Domenic,

    It works for group1 (column E, the answer is 5 census tracts) but when I copied and pasted it for group2 (column G) it gave the wrong answer as 6 census tracts (cumulative percentage of 46.8%) when it should be 7 (when it becomes 56.8%).

  11. #11
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    For Group 2...

    Data from largest to smallest:

    330
    295
    260
    260
    255
    235
    195
    170
    160
    155
    140
    135
    135
    110
    105

    Cummulative data:

    330
    625
    885
    1145
    1400
    1635
    1830
    2000
    2160
    2315
    2455
    2590
    2725
    2835
    2940

    Cummulative percentage:

    0.112
    0.213
    0.301
    0.389
    0.476
    0.556
    0.622
    0.680
    0.735
    0.787
    0.835
    0.881
    0.927
    0.964
    1.000

    Therefore, the 50% threshhold is reached at the 6th row with 0.556. Or did I misunderstand your intent?

  12. #12
    Registered User
    Join Date
    04-23-2008
    Posts
    7
    Sorry. Your right. I forgot to sort Group2 from highest to lowest before checking it.

    Thank you very much for your quick help.

  13. #13
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    You're very welcome! Glad I could help!

  14. #14
    Registered User
    Join Date
    04-23-2008
    Posts
    7

    How to stop Excel 2007 from lengthy calculating process?

    I'm using that formula that Domenic gave me but once I've calculated all the values I want, how do I prevent Excel 2007 from auto calculating those values again? Almost any action I take (copy one cell contents to another, opening a new workbook, etc.) makes Excel run the whole long calculation again which takes like a couple of minutes on my large dataset.

  15. #15
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    It's probably the INDIRECT() function within the formula causing that...since it is considered a volatile function (ie. recalculates after any change in sheet).

    You can turn off calcs by going to Tools|Options >> Calculation tab and selecting Manual..

    Then when you want to perform sheet calculations, you will need to hit F9 to recalculate.

  16. #16
    Registered User
    Join Date
    04-23-2008
    Posts
    7
    I tried Calculation Options -> Manual but it didn't help.

  17. #17
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898
    Hmm... should work... perhaps it works differently in 2007.... anybody know?

  18. #18
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474
    Try replacing...

    ROW(INDIRECT("1:"&ROWS(E5:E19 )))

    with

    ROW(INDEX(E:E,1):INDEX(E:E,ROWS(E5:E19 )))

    Hope this helps!

  19. #19
    Registered User
    Join Date
    04-23-2008
    Posts
    7
    Yes, that helps. Thanks again.

+ 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