+ Reply to Thread
Results 1 to 18 of 18

Using Countifs over muttiple colums

  1. #1
    Registered User
    Join Date
    08-08-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    12

    Using Countifs over muttiple colums

    I have 4 columns where the data contains 4 values, but the value could in in any column
    Then a column that has a value

    I normally use countifs, but as the value is different in the column, that does not work
    So I tried countif, but then I can't choose the value

    I tried it as a bulk range of A:D and couldn't get it to work
    I need to return how many of a particular type are in the different value range

    I'm using office 2016 however the file sample is earlier version

    Thanks heaps
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Using Countifs over muttiple colums

    Welcome to the forum.

    Explain the sample data - what is the dates column meant to show? I cannot see any logic to it, if that is meant to be what you want.

    It's best to provide .xlsx files here, as .xls won't always open.
    Last edited by AliGW; 08-08-2020 at 03:50 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    08-08-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    12

    Re: Using Countifs over muttiple colums

    So the dates is just a value of days
    I need to see how many Cats are in the 4 columns that equal 1 in the date column or 2 or 3 etc
    How many cows there are in the 4 columns that equal the number in the date column etc.
    is that clearer? sorry if I am confusing

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Using Countifs over muttiple colums

    No, still not clear, sorry. Remember, you know your data and what you want, but we don't.

    Talk me through one of the calculations step-by-step. Also, please reattach the workbook (in .xlsx format) with your expected results manually added. I have no idea what relevance the days column has to this ...

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

    Re: Using Countifs over muttiple colums

    Hello Richard,

    If I read you correctly;

    Enter your criteria in cells;

    Dates in H1: 1
    Category in H2: Cat

    Then

    =SUM(COUNTIFS(OFFSET(A:A,,{0,1,2,3}),H2,E:E,H1))

    Red highlighted meant; there are 4 columns to look start from A.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  6. #6
    Registered User
    Join Date
    08-08-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    12

    Re: Using Countifs over muttiple colums

    Sorry I can't put it in xlsx format. It's on my work PC and I cannot post from there and I only have 2003 at home. I'm normally pretty good in working it out and first time I tried posting

    I have 1000 rows over 4 columns
    Each row could have a value of 4 possibles. Cat Cow Chicken or Horse and it could be in either column, but only once.
    I need to find the value and then see if it matches by the date

    So I would normally =COUNTIFS(A:A,"Cat",E:E,1) to return all the CATS in column A that = 1 in column E
    However as the other columns are blank, or something.....I thought=COUNTIFS(A:A,"Cat",B:B,"Cat",C:C,"Cat",D:D,"Cat"E:E,1) etc. but it returns 0
    I tried COUNTIFS(A:D) to see if it would look them up in the database but to no avail, so maybe countifs is not the correct formula as the value is only in each column once. Does that make sense

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Using Countifs over muttiple colums

    Does post #5 answer your query? If not, PLEASE post a workbook with some expected results (even if it has to be in .xls format).

    I'm normally pretty good in working it out and first time I tried posting
    Not sure why you made this comment - I am trying to help, not telling you you shouldn't have posted here ...

  8. #8
    Registered User
    Join Date
    08-08-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    12

    Re: Using Countifs over muttiple colums

    it didn't
    I have reattached with results
    Attached Files Attached Files

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Using Countifs over muttiple colums

    OK. In that case, variations on this theme:

    =SUMPRODUCT(($A$2:$D$17="Cat")*($E$2:$E$17<3))

    =SUMPRODUCT(($A$2:$D$17="Cat")*($E$2:$E$17>=3)*($E$2:$E$17<=6))

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

    Re: Using Countifs over muttiple colums

    See the attached.

    FYI: Some of the values have extra spaces at the the (Horse)

    N2;

    =SUM(COUNTIFS(OFFSET(A:A,,{0,1,2,3}),"Cat",E:E,"<3"))

    N3;

    =SUM(COUNTIFS(OFFSET(A:A,,{0,1,2,3}),"Cat",E:E,">=3",E:E,"<=6"))

    Adjust to your categories.
    Attached Files Attached Files
    Last edited by Haseeb Avarakkan; 08-08-2020 at 04:39 AM. Reason: Added formulas in the thread

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Using Countifs over muttiple colums

    Sorry for off-topic interjection:

    @Haseeb A


    Although there is no official rule regarding this behaviour, we request that wherever possible both the question AND the answer be provided in substantive detail here within the thread. An attached workbook is an excellent aid for posing a question and offering a solution, but solely doing that with no in thread explanation makes it difficult for researchers to understand or consider the Q & A of this thread without downloading what may be a pointless doc to them, if they can do that at all. Doing that also hides the content from search engines so others may never benefit from this.

    I'm sure you understand, and we look forward to seeing you post your formulas/macros in your posts for the searching benefit of all.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Using Countifs over muttiple colums

    @Haseeb A

    There really is no need to use the volatile OFFSET function in this case - it's overkill for what is a simple SUMPRODUCT scenario. On large datasets, your suggestion may well slow things down considerably.

  13. #13
    Registered User
    Join Date
    08-08-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    12

    Re: Using Countifs over muttiple colums

    Fantastic that is it. Thanks for your help

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Using Countifs over muttiple colums

    Whose suggestion did you choose?

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

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

    Re: Using Countifs over muttiple colums

    Quote Originally Posted by AliGW View Post
    [I]...AND the answer be provided in substantive detail here within the thread...
    AliGW,

    I always try to post the answers in thread. I was in hurry this time, didn't pay attention. Will keep in mind for future posts.

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Using Countifs over muttiple colums

    Thank you - if I'm in too much of a hurry to post in detail, I leave it to someone else. It's not a race: quality replies are the key to a good forum.

  17. #17
    Registered User
    Join Date
    08-08-2020
    Location
    Australia
    MS-Off Ver
    2016
    Posts
    12

    Re: Using Countifs over muttiple colums

    I used yours.
    Thanks again

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Using Countifs over muttiple colums

    You're welcome.

+ 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] COUNTIFS, INDEX & MATCH not working when dragging to next row & colums
    By chaiyya345 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-05-2019, 05:04 AM
  2. VBA Text (4 colums) to Random Cells (4 Colums) sheet 1 to sheet 2 (excel 07)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-27-2017, 04:06 PM
  3. countifs multiple critera and colums
    By kahlran in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-14-2014, 05:27 AM
  4. Help with adjusting my module to search muttiple sheets..
    By Watersboy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2013, 08:13 AM
  5. freeze first colums and hide one colums
    By pejoi in forum Excel General
    Replies: 2
    Last Post: 08-09-2012, 03:50 AM
  6. Formula required for comparing multiple colums to multiple colums
    By Pringgles in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-30-2012, 07:23 AM
  7. Replies: 0
    Last Post: 12-16-2011, 09:01 AM

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