+ Reply to Thread
Results 1 to 13 of 13

Countifs with multiple criteria and ranges within single column?

  1. #1
    Registered User
    Join Date
    12-21-2015
    Location
    United States
    MS-Off Ver
    2016
    Posts
    62

    Countifs with multiple criteria and ranges within single column?

    Hi all,

    Having some trouble with this one.

    I have a large set of data, all within one column (roughly 100k lines). And I am trying to come up with a formula to see if a specific cell value exists between two other specific cell values in that column. Whether or not it returns a true, yes, a number, or whatever is of little importance however.

    My problem is since I have multiple criteria all within the same column and the range in between each instance is different, it's a bit of a puzzle to me. Anyone have an idea?

    See attachment for an example (check both tabs).

    Thank you,

    Edit: I noticed in the mock formula I had in there I listed F2, it should of said F3.

    Edited again: Please see post below with updated information
    Attached Files Attached Files
    Last edited by Skiptomylou; 03-12-2018 at 08:10 PM.

  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: Countifs with multiple criteria and ranges within single column?

    Is the order of the names the same on both sheets.

    Incidentally would you edit your location to something meaningful. It often helps when we need to consider regional settings of date formats..etc.
    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
    12-21-2015
    Location
    United States
    MS-Off Ver
    2016
    Posts
    62

    Re: Countifs with multiple criteria and ranges within single column?

    Quote Originally Posted by Richard Buttrey View Post
    Is the order of the names the same on both sheets.

    Incidentally would you edit your location to something meaningful. It often helps when we need to consider regional settings of date formats..etc.
    Heh, I never noticed my location listed as "yesterday", but that's fixed. To answer your first question, no - they are not in order.

    Edited: I thought I could put them in order - but alas, they are not, and cannot be.
    Last edited by Skiptomylou; 03-12-2018 at 05:58 PM.

  4. #4
    Registered User
    Join Date
    03-07-2018
    Location
    Berlin
    MS-Off Ver
    2016
    Posts
    4

    Re: Countifs with multiple criteria and ranges within single column?

    It's not clear what you're trying to achieve. Could you please upload a bigger amount of test data and formulate what the correct formula should count?

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Countifs with multiple criteria and ranges within single column?

    Perhaps this in B2
    =COUNTIF(INDEX('Data Sample'!A:A,MATCH(A2&"",'Data Sample'!A:A,0)+1):INDEX('Data Sample'!A:A,IF(A3="",COUNTA('Data Sample'!A:A),MATCH(A3,'Data Sample'!A:A,0)-1)),$F$3)>0
    and copy down?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  6. #6
    Registered User
    Join Date
    12-21-2015
    Location
    United States
    MS-Off Ver
    2016
    Posts
    62

    Re: Countifs with multiple criteria and ranges within single column?

    This actually works for the test that I supplied, and is a very wise response. Next problem though that I failed to realize until my prior message - the names on the second sheet are not in the same order as the previous sheet, so my original thought, and your solution will not work for the application.

    I have made some changes to the sheet, and extended the data amount as requested by another post and added it in this comment.

    Basically - the formula will need to search in the data tab for the specified name (All begin with variations of "XX_","XXX_","XXXX_") and see if the lookup value of "B" (from the example sheet) exists until the next instance of "XX*". No other form of "XX*" will exist in the columns besides the names. And then return the result of either True or False.

    Now, I am aware the test sheet has them in order, but the actual data is not.
    Attached Files Attached Files
    Last edited by Skiptomylou; 03-13-2018 at 08:27 AM.

  7. #7
    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: Countifs with multiple criteria and ranges within single column?

    Quote Originally Posted by Skiptomylou View Post
    This actually works for the test that I supplied, and is a very wise response. Next problem though that I failed to realize until my prior message - the names on the second sheet are not in the same order as the previous sheet, so my original thought, and your solution will not work for the application.

    I have made some changes to the sheet, and extended the data amount as requested by another post and added it in this comment.

    Basically - the formula will need to search in the data tab for the specified name (All begin with variations of "XX_","XXX_","XXXX_") and see if the lookup value of "B" (from the example sheet) exists until the next instance of "XX*". No other form of "XX*" will exist in the columns besides the names. And then return the result of either True or False.

    Now, I am aware the test sheet has them in order, but the actual data is not.
    That was why I asked you in #2 if the names were in order.
    Nevertheless the file you've attached still has the names on each sheet in the same order, i.e. Steve follows john and Mike follows Steve etc. with no others in between.

    If as you say above the names are not in order thhe please supply a file that represents your data.
    We often find that when we give an answer to what is a trivial non representative example when the solution is used with the real world data it doesn't work because of factors like string length and other stuff which is important but hasn't been mentioned.

    Therefore upload your real workbook (or at least a cut down copy), and manually add the results you expect to see. Clearly identify which is original data and which are the results and in a note clearly explain how you have arrived at your results.

  8. #8
    Registered User
    Join Date
    12-21-2015
    Location
    United States
    MS-Off Ver
    2016
    Posts
    62

    Re: Countifs with multiple criteria and ranges within single column?

    Which, is why I replied to you with the answer to your question.

    My actual workbook cannot be supplied due to confidential information. I clearly said at the bottom of the last message that while the data in the example is in order, the real data is not.

    Just to appease you though, see the attached for some out of order names.
    Attached Files Attached Files

  9. #9
    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: Countifs with multiple criteria and ranges within single column?

    Yes, but it wasn't clear what you meant by 'in order'

    That could have meant the names were in alphabetical order, or that the names on the two lists were not in alphabetical order but were in the same relative positions in the two lists.

    We don't expect you to upload workbooks with sensitive data but we do like you to anonymise your data keeping faithful to any formatting or string lengths etc and upload at representative workbook. We often find that when we give an answer to what is a trivial non representative example when the solution is used with the real world data it doesn't work because of factors like string length and other stuff which is important but hasn't been mentioned.

    Please don't get critical and argumentative. None of us are paid for doing this which we do because we genuinely like to help people discover Excel, and we don't welcome the sort of response you've given.

  10. #10
    Registered User
    Join Date
    12-21-2015
    Location
    United States
    MS-Off Ver
    2016
    Posts
    62

    Re: Countifs with multiple criteria and ranges within single column?

    You receive responses in the same fashion that you submit your questions - nothing more, nothing less.

    In fairness, I don't welcome the sort of results or questions you have supplied, and would happily do without the initial "critical" responses.

    You have my sample workbook, albeit 1/1500th the size, that represents the data in the true workbook. If you want to help, great, and I appreciate it. If not, that's alright too. But understand, I will always respond in kind.

    Thanks again.

    crit·i·cal
    /ˈkridək(ə)l/
    adjective
    1. Inclined to find fault or to judge with severity, often too readily.

  11. #11
    Registered User
    Join Date
    12-21-2015
    Location
    United States
    MS-Off Ver
    2016
    Posts
    62

    Re: Countifs with multiple criteria and ranges within single column?

    Just solved this with a few helper columns:
    In B:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    In C:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    In D:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    In E:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Was able to consolidate in the actual worksheet to just a one formula. Large combination of all those together, but it works. Thanks to everyone who supplied feedback.
    Last edited by Skiptomylou; 03-13-2018 at 11:45 AM.

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,245

    Re: Countifs with multiple criteria and ranges within single column?

    FYI (another option)

    in A2

    =IFERROR(INDEX('Data Sample'!$A$1:$A$63,SMALL(IF(ISNUMBER(SEARCH("_",'Data Sample'!$A$1:$A$63)),ROW('Data Sample'!$A$1:$A$63)-ROW($A$1)+1,""),ROWS($A$1:A1))),"")



    ...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.

    Copy down

    in B2 (xlnitwit formula)

    =COUNTIF(INDEX('Data Sample'!A:A,MATCH($C2&"",'Data Sample'!A:A,0)+1):INDEX('Data Sample'!A:A,IF($C3="",COUNTA('Data Sample'!A:A),MATCH($C3,'Data Sample'!A:A,0)-1)),$G$3)>0


    Add XX_END to end of input data

  13. #13
    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: Countifs with multiple criteria and ranges within single column?

    Quote Originally Posted by Skiptomylou View Post
    You receive responses in the same fashion that you submit your questions - nothing more, nothing less.

    In fairness, I don't welcome the sort of results or questions you have supplied, and would happily do without the initial "critical" responses.

    You have my sample workbook, albeit 1/1500th the size, that represents the data in the true workbook. If you want to help, great, and I appreciate it. If not, that's alright too. But understand, I will always respond in kind.

    Thanks again.

    crit·i·cal
    /ˈkridək(ə)l/
    adjective
    1. Inclined to find fault or to judge with severity, often too readily.
    Just a minute. Where have I been critical?
    And precisely what, in anything I have supplied, do you find unwelcome?

    I still detect an element of truculence in your response. I don't expect to see you continue in this vein.

+ 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. Countifs formula with multiple criteria against a single range
    By GymnasticHippo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-07-2017, 09:54 PM
  2. COUNTIFs: Multiple ranges, single criterion with OR logic
    By A.Khan in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-20-2017, 06:05 AM
  3. Countifs with multiple criteria in single criteria range
    By SUHAS KARHADKAR in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 12-01-2016, 10:55 AM
  4. Countifs with multiple criteria in single criteria range
    By MCP313 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-01-2016, 03:51 AM
  5. [SOLVED] countifs statement with multiple criteria for multiple criteria ranges
    By mcdermott2 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-07-2015, 11:48 AM
  6. Replies: 5
    Last Post: 05-04-2014, 10:56 AM
  7. Countifs with multiple criteria in a single range
    By Wolfpackfan320 in forum Excel General
    Replies: 1
    Last Post: 02-27-2012, 04:54 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