+ Reply to Thread
Results 1 to 5 of 5

countif() with filter() function

  1. #1
    Registered User
    Join Date
    08-08-2023
    Location
    Texas, USA
    MS-Off Ver
    MS Office 365
    Posts
    49

    countif() with filter() function

    Hello,

    I helped someone in the below thread, but I wanted to make a more elegant solution that didn't require adding another column.

    https://www.excelforum.com/excel-for...ml#post5858297

    My attempt to do this is in tab "Solution 2" of the attached file, and the formula is below. ("Solution 1" tab has the accepted solution)
    =LET(f,FILTER($B$6:$B$9,$A$6:$A$9=A6),CG,COUNTIF(f,"G"),CH,COUNTIF(f,"H"),C,COUNTA(f),IF(CG=C,"G",IF(CH=C,"H","I")))

    I found if I do every step of that formula individually it works out, but combined altogether, it gives the #VALUE! error.

    I tracked the error to using the filter function in the countif function.

    this formula:
    =LET(f,FILTER($B$6:$B$9,$A$6:$A$9=A6),COUNTIF(f,"G"))
    returns:
    #VALUE!
    #VALUE!

    is it possible to use the filter function in the countif function, or would some other workaround be required?

    Thanks!
    Attached Files Attached Files
    Last edited by AliGW; 08-10-2023 at 09:04 AM. Reason: URL fixed.

  2. #2
    Registered User
    Join Date
    01-09-2014
    Location
    Leeds, England
    MS-Off Ver
    Excel 365
    Posts
    77

    Re: countif() with filter() function

    You can't combine countif with filter, as countif deals with ranges but not arrays.

    You can, however, use a combination of Count and If to achieve the same result:

    =LET(f,FILTER($B$6:$B$9,$A$6:$A$9=A6),COUNT(IF(f="G",1,"")))

  3. #3
    Registered User
    Join Date
    08-08-2023
    Location
    Texas, USA
    MS-Off Ver
    MS Office 365
    Posts
    49

    Re: countif() with filter() function

    That works perfectly, I will pay more attention to the differences between arrays and ranges in the future.

    Thanks for the reply/answer!

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

    Re: countif() with filter() function

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

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) 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 all those who offered help.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    08-08-2023
    Location
    Texas, USA
    MS-Off Ver
    MS Office 365
    Posts
    49

    Re: countif() with filter() function

    thanks Ali,

    I was looking for how to mark it as solved, but I couldn't find it.
    I already gave Simon the reputation.

+ 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. Countif + Filter
    By JonBech in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-15-2022, 06:11 PM
  2. UNIQUE and FILTER inside COUNTIF(S) Function
    By dluhut in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-02-2022, 02:38 PM
  3. Adding a COUNTIF function to an existing IF AND COUNTIF Formula...
    By Ourkid123uk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-24-2018, 10:09 AM
  4. countif function + filter
    By Copiloc in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-11-2016, 12:38 AM
  5. countif function + filter
    By Copiloc in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-11-2016, 12:38 AM
  6. countif function + filter
    By Copiloc in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-10-2016, 06:00 PM
  7. Filter & COUNTIF
    By longbow007 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-13-2009, 07:37 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