+ Reply to Thread
Results 1 to 11 of 11

Count the value based on order

  1. #1
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Count the value based on order

    Hi,

    I have a column say with 100 values like below:

    A B
    $100 High
    $20 Low
    $103 High
    .
    .
    .
    $1000 Mid

    I want to see if I can count how many times "High" or "Mid" or "Low" appear in the first 25%, the next 25% and so on.

    Thanks.
    Last edited by huy_le; 12-05-2013 at 06:56 PM.

  2. #2
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Count the value based on order

    Nobody has the solution? Maybe to make it simple, instead of $100, $20 and such, let's just make it 1, 2, 3, 4, 5 in order then. I hope I could get a good solution.

  3. #3
    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
    52,946

    Re: Count the value based on order

    Forum rules require you to wait at least 24 hours before "bumping" your thread.

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    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

  4. #4
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Count the value based on order

    Take A2:B100 is data.

    D2:D4 enter - High, Low & Mid respectively

    E1:H1 - 25%, 50%, 75%, 100% respectively

    E2, with CTRL+SHIFT+ENTER,

    =COUNTIF($B$2:INDEX($B$2:$B$100,MATCH(SUM($A$2:$A$100)*E$1,SUBTOTAL(9,OFFSET($A$2,,,ROW($A$2:$A$100)-ROW($A$2)+1)))),$D2)

    Then copy down & across.

    Is that you like to achieve?
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  5. #5
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Count the value based on order

    Sorry FDibbins, I wasn't trying to pumping it up, I was trying to simplify it so that I could get a solution.

    Ideally I want to get the result without having to sort the list in order, but if it's not achievable, sorting is okay too.

    Attached is the file.
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Count the value based on order

    In D5, with CTRL+SHIFT+ENTER

    =COUNTIF($B$1:INDEX($B$1:$B$252,MATCH(SUM($A$1:$A$252)*25%,SUBTOTAL(9,OFFSET($A$1,,,ROW($A$1:$A$252)-ROW($A$1)+1)))),D$4)-SUM(D$4:D4)

    Change 25% to 50%, 75% & 100% in D6, D7 & D8. Then select D5:D8 then copy across.

  7. #7
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Count the value based on order

    Hi Haseeb,

    It's not correct, I notice the last sum contains only one cell, is that the reason? Ok I got this now, forgot to enter array :D

    Anyway, what I would like to achieve is actually the 25% of the total count. In this case, we have 252 counts, I want to get the 25% of 252.

    Is that achievable?

    Thanks so much for your help.
    Last edited by huy_le; 12-05-2013 at 09:59 PM.

  8. #8
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Count the value based on order

    Try this Array Formula,

    =COUNTIF($B$1:INDEX($B$1:$B$252,MATCH(COUNTA($A$1:$A$252)*25%,SUBTOTAL(3,OFFSET($A$1,,,ROW($A$1:$A$252)-ROW($A$1)+1)))),D$4)-SUM(D$4:D4)

    Used COUNTA instead of SUM & used 3 instead of 9 in SUBTOTAL

  9. #9
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Count the value based on order

    That works! Thanks a bunch! What is the difference between 3 and 9, I may ask?

  10. #10
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Count the value based on order

    There are various options in SUBTOTAL function. ie: SUM a range, COUNT only numbers in a range, count all non blank cells etc... 9 is using to SUM a range, but 3 using for counting non blank cells. If you look on help file can see more about it.

  11. #11
    Forum Contributor
    Join Date
    08-22-2013
    Location
    US
    MS-Off Ver
    Mac Version 2011
    Posts
    126

    Re: Count the value based on order

    Ok, great! That was hella complicated formula, don't know how you did it but you did. Thanks so much!

+ 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. Count only one order number in a list of values
    By david1987 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-20-2013, 10:50 AM
  2. [SOLVED] Quantity in column D based on order amount of times the order no appears
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-19-2013, 06:48 PM
  3. Replies: 4
    Last Post: 02-07-2012, 03:39 AM
  4. Problem with 2 conditions in order to count
    By koncurn in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 03-30-2010, 12:30 PM

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