+ Reply to Thread
Results 1 to 8 of 8

sum occurences meeting criteria by ID, then count how many

  1. #1
    Registered User
    Join Date
    07-24-2012
    Location
    Baltimore
    MS-Off Ver
    Excel for Mac 2011
    Posts
    45

    sum occurences meeting criteria by ID, then count how many

    Hello.

    I have a spreadsheet that has individuals with multiple records indicated by ID in column A and days between outpatient clinic visit and hospital admission in column B.

    I would like to know how many individuals had 0, 1 or >1 clinic visits 90 days or less from hospital admission. So I need to sum clinic visits <=90 days by ID, and then count how many individuals (unique IDs) have 0, 1 or >1 visits.

    Thanks!

    Column A Column B
    ID Days to Admission
    353622 425
    353622 390
    353622 246
    353622 187
    353622 160
    353622 92
    353622 71
    353622 50
    353622 43
    353622 33
    353622 8
    658912 273
    658912 217
    658912 175
    658912 119
    677931 325
    677931 152
    677931 68

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,426

    Re: sum occurences meeting criteria by ID, then count how many

    This is a duplicate post - decide which one you want to use, as the sample data is slightly different.

    Also, you don't want to SUM clinic visits - you want to COUNT them.

    Pete

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,995

    Re: sum occurences meeting criteria by ID, then count how many

    I closed the duplicate and kept this one, which was started earlier. If you need to update your data you can simply edit your post.

    http://www.excelforum.com/showthread...=1#post4439520
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

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

    Re: sum occurences meeting criteria by ID, then count how many

    This solution uses two formulas. The first is an array entered formula* and makes a unique list of ID's as follows:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    The second will identify the frequency of visits as follows:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached is a spread sheet that demonstrates how the formulas work. *Array entered formula are confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    Let me know if you have any questions.
    Attached Files Attached Files
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,745

    Re: sum occurences meeting criteria by ID, then count how many

    Another way.

    With a helper cell in D1 (used in lieu of IFERROR) array entered.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.

    Then in D3 filled down until you get blanks. Does not have to be array entered. This returns unique IDs.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    In E3 non-array entered. This returns the sum of each ID < = 90.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    In F3 non-array entered. Returns the categories.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 07-23-2016 at 02:03 AM.
    Dave

  6. #6
    Registered User
    Join Date
    07-24-2012
    Location
    Baltimore
    MS-Off Ver
    Excel for Mac 2011
    Posts
    45

    Re: sum occurences meeting criteria by ID, then count how many

    thanks, this worked

  7. #7
    Registered User
    Join Date
    07-24-2012
    Location
    Baltimore
    MS-Off Ver
    Excel for Mac 2011
    Posts
    45

    Re: sum occurences meeting criteria by ID, then count how many

    thanks for the solution

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

    Re: sum occurences meeting criteria by ID, then count how many

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread 'Solved' using the thread tools link above your first post. I hope that you have a blessed day.

+ 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] Count Data Meeting Criteria Across Columns Meeting Criteria
    By idelta in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-06-2015, 03:53 PM
  2. [SOLVED] Count of pupils meeting 'less than' criteria...
    By sezza79 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2014, 09:27 AM
  3. Count of Occurences based on multiple criteria
    By hilpup24 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-09-2013, 08:13 AM
  4. lookup and count if meeting criteria
    By reghu in forum Excel General
    Replies: 6
    Last Post: 09-09-2010, 07:41 AM
  5. How to count instances meeting criteria?
    By guntar in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-26-2009, 05:06 PM
  6. Record count meeting 4 criteria
    By harleypop in forum Excel General
    Replies: 6
    Last Post: 03-17-2009, 08:33 PM
  7. [SOLVED] count records meeting three criteria
    By Laura in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-21-2005, 01:50 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