use:

=ARRAYFORMULA(COUNTIFS(Data!B:B, "*"&D2:D21&"*", Data!B:B, "*"&E2:E21&"*"))

Answer from player0 on Stack Overflow
🌐
Google Support
support.google.com › docs › thread › 179113558 › google-sheets-countif-not-working
Google Sheets COUNTIF not working - Google Docs Editors Community
September 13, 2022 - Skip to main content · Google Docs Editors Help · Sign in · Google Help · Help Center · Community · Google Docs Editors · Terms of Service · Submit feedback · Send feedback on
🌐
Reddit
reddit.com › r/googlesheets › the simplest of formulas (countif) not working. wtf am i doing wrong?
r/googlesheets on Reddit: The simplest of formulas (COUNTIF) not working. Wtf am I doing wrong?
April 29, 2019 -

I created a super simple table where one column has “Yes” or “No” entered in each cell. At the bottom of the list, I entered =COUNTIF(B2:B84, “Yes”) to find out how many “yes”s I had. It keeps saying “formula parse error”. I can’t figure it out.

Here’s a link to my sheet:

yes/no table

Countif not counting correctly Jul 13, 2022
r/googlesheets
4y ago
COUNTIF not working. May 12, 2024
r/googlesheets
2y ago
Countif function parse error Jun 2, 2022
r/googlesheets
4y ago
COUNTIFS and MONTH formula not working Nov 30, 2024
r/googlesheets
last yr.
More results from reddit.com
Top answer
1 of 2
1

0 is correct because with each new criteria_range you are ANDing the results (i.e. your formula as shown is equivalent to 'give me the count where there is a TRUE present in the same position in each column').

If you want to return 5, that implies to me that you actually want 'give me the count of TRUEs across all rows', in which case you should stack the columns into one using array literals:

=countif({D8:D16;H8:H16;L8:L16;P8:P16;T8:T16},true)
2 of 2
1

Use SUM and FILTER

This aporoach uses a single range and is easy to reuse and manage. It leverages the consistent column pattern found in your sample data.

Formula

=SUM(FILTER(D8:T16*1, NOT(MOD(
   SEQUENCE(1,COLUMNS(D8:T16),0),4))))

Explanation

  1. FILTER is applied to the range D8:T16 to remove columns that aren't wanted.
  2. All the values in the range D8:T16 are multiplied by 1 so Sheets will coerce the checkbox values from TRUE and FALSE to 1 and 0.
  3. The FILTER's condition argument includes only every fourth column starting with the first. This is achieved by:
    1. Creating a one row SEQUENCE of numbers based on the number of columns in the range, starting at 0 and incrementing by 1
    2. Wrapping the SEQUENCE in MOD using 4 as the divisor, which changes the number SEQUENCE:
      # before MOD
      {0,1,2,3,4,5,6,7,8,9,10,11,12,...}
      
      # after MOD
      {0,1,2,3,0,1,2,3,0,1,2,3,0,...}
      
    3. MOD is then wrapped in NOT to convert the values 0,1,2,3 to TRUE,FALSE,FALSE,FALSE. Now the position of all TRUE values in the FILTER condition matches the position of the columns that should be counted.
  4. Lastly, SUM is used to total all values from the array of ones and zeros returned by the FILTER. This is equivalent to counting.
🌐
Google Support
support.google.com › docs › thread › 180481286 › i-can-t-get-my-countifs-to-work-correctly-in-sheets
I can't get my Countifs to work correctly in Sheets - Google Docs Editors Community
September 22, 2022 - Skip to main content · Google Docs Editors Help · Sign in · Google Help · Help Center · Community · Google Docs Editors · Terms of Service · Submit feedback · Send feedback on
🌐
Google Support
support.google.com › docs › thread › 14524035 › countif-not-working-in-some-spreadsheet-country-options
=CountIF "=" not working in some spreadsheet "country options" - Google Docs Editors Community
September 16, 2019 - Skip to main content · Google Docs Editors Help · Sign in · Google Help · Help Center · Community · Google Docs Editors · Terms of Service · Submit feedback · Send feedback on
🌐
Google Support
support.google.com › docs › thread › 60398097 › google-sheet-countif-not-working
Google sheet COUNTIF not working - Google Docs Editors Community
Skip to main content · Google Docs Editors Help · Sign in · Google Help · Help Center · Community · Google Docs Editors · Terms of Service · Submit feedback · Send feedback on
Find elsewhere
🌐
Google Support
support.google.com › docs › thread › 292270517 › countifs-formula-not-working
Countifs formula not working - Google Docs Editors Community
August 22, 2024 - Skip to main content · Google Docs Editors Help · Sign in · Google Help · Help Center · Community · Google Docs Editors · Terms of Service · Submit feedback · Send feedback on
🌐
Google Support
support.google.com › docs › answer › 3093480
COUNTIF - Google Docs Editors Help
COUNTIF can only perform conditional counts with a single criterion.
🌐
OfficeWheel
officewheel.com › home › google sheets › [fixed!] countif function is not working in google sheets
[Fixed!] COUNTIF Function Is Not Working in Google Sheets
August 3, 2023 - Read More: Google Sheets Count ... want to set the argument with a text. Any text value that is not included in double quotes will cause Google Sheets to fail to recognize the function....
🌐
Ablebits
ablebits.com › ablebits blog › google sheets tips › google sheets functions › google spreadsheet countif function with formula examples
Google Spreadsheet COUNTIF function with formula examples
So if they have their name in row 1,3 and 5 it will add up D in sheets 2? ... If I understand your task correctly, you can use QUERY just like in this article or the Combine Duplicate Rows add-on described there at the end. NAEEM..... 2024-02-04 · plz helpmme out for this...... =COUNTIFS(C14:C44,">=350000",C14:C44,"=350000",C14:C44,"=400000",C14:C44,"<450000")*150 it not working
Published: August 16, 2021
Views: 45
🌐
Yagisanatode
yagisanatode.com › home › blog feed › why your count function might not be working in google sheets
Why your COUNT function might not be working in Google Sheets - Yagisanatode
October 30, 2021 - =COUNTIF(ARRAYFORMULA(LEN(K2:K)),“>1”) Check out the video below for more information. Do you have a clever way of dealing with this problem? I would love to hear about it in the comments below. Did you enjoy the tutorial? Want to upskill and get a solid step-by-step course to become a pro at Google Sheets?
Top answer
1 of 2
1

You have separate Columns for "Date Due" and "Time Due" and you are creating a ranking (using countifs) by adjusting for date and time. You have found that the ranking is producing unexpected errors and don't know why.

Your formula is" ={"Priority"; ARRAYFORMULA(if(isblank(J2:J),if(isblank(H2:H)=false, countifs(J:J,"",H:H,"<="&H2:H) -countifs(J:J,"",H:H,H2:H,I:I,">"&I2:I),""),""))}


The error arises as a result of adjusting for Time independent of the Date. Date and Time are both Date Objects. In a Google Spreadsheet function, both are calculated as a decimal value relative to the epoch (12/30/1899 0:00:00), though formatting can is often used to mask this.

In your formula you calculate an adjustment between the count of Dates (Column H) less the count of Times (Column I). However, this assumes that both values exist in the same sequence - this is not the case. These Times are unrelated to their Date counterparts - they exist in isolation and thus the calculation is affected by their relative value (rather than an absolute value).


The solution to the problem is twofold:
- record the Due Date as a Date/Time, and

  • use COUNIFS based on the Date/Time field only (delete the element -countifs(J:J,"",H:H,H2:H,I:I,">"&I2:I))

    OR

  • use the RANK function (sorting descending).


This table shows the effect on the decimal value of the Time when taken in isolation compared to when taken as a Date/Time value).

2 of 2
0

The logic and reasoning expressed by Tedinoz is correct. The proposed solutions work as well.

Still. One can follow a different approach.
The problem is that in your second COUNTIFS condition you are mixing dates and times therefore the incompatibility giving false results.

Easily corrected by slightly tweaking your formula.

You just need to replace the two mentions of column I with H+I

={"Priority"; 
   ARRAYFORMULA(if(isblank(J2:J),
                    if(isblank(H2:H)=false,
                        countifs(J:J,"",H:H,"<="&H2:H)
                       -countifs(J:J,"",H:H,H2:H,H:H+I:I,">"&H2:H+I2:I) ,""),""))}

This way you create a virtual timestamp taking into account both the given date as well as the time of the date (avoiding using an extra helper column along with deleting the second COUNTIFS or radically changing your formula using the RANK function).
As an extra bonus you get to keep all columns intact since you "need those columns separate for functionality in the rest of the workbook".


The virtual timestamp works because using eg. H194+I194 (where H194 is a date 03/09/2020 and I194 is a time 8:33:00 PM), Google Sheets are smart enough NOT to just add these two cells as numeric values but to concatenate them and create the timestamp 3/9/2020 20:33:00

🌐
Reddit
reddit.com › r/googlesheets › why is my countif formula not counting correctly?
r/googlesheets on Reddit: Why is my countif formula not counting correctly?
November 8, 2022 -

I have a list, then below a =UNIQUE to populate a list and =Countif to count the instances of each name.

But the count is off. Why?

Here's the sheet:

https://docs.google.com/spreadsheets/d/1hy7Yuy6uHvtHIhzc7wkdUX4IkBrtKw74RINycz5l2D4/edit?usp=sharing

Top answer
1 of 2
3

See Also: Count rows with not empty value


Unfortunately, this is functions as designed from Google.
Although I'm not sure why it's divergent from the way that Excel calculates COUNTA.

According to the Google Spreadsheet Documentation on COUNTA:

COUNTA counts all values in a dataset, including those which appear more than once and text values (including zero-length strings and whitespace).

Meaning that the only way to "make [the cells] completely empty" is to delete the entire contents, formula and all. But fear not...

Some workarounds:

  1. Hypothetically, you should be able to do this with =COUNTIF(A3:A8,"<>"&""), but Google spreadsheets doesn't support the not equal to operator in the COUNTIF function according to these forums: 1, 2, 3

  2. A workaround is to create a truthy or falsy array based on the condition and use SUMPRODUCT to count the truthy values like this:

     =SUMPRODUCT((A3:A8<>"")*1)
    
  3. Another option you could pursue would be to write a custom function and add it to Drive.
    It's actually pretty easy to do so. Go to Tools > Script Editor and add the following script:

     /**
      * Works like COUNTA except does not include null strings
      *
      * @param {cellRange} myArray The value or range to consider when counting.
      * @return Returns the a count of the number of values in a dataset.
      * @customfunction
      */
     function CountNotBlank(myArray) {
       var output = 0;
       for (i = 0; i < myArray.length; i++) { 
         if (myArray[i] != "") {
           output += 1
         }
       }
       return output;
     }
    

    Then use like this:

     =CountNotBlank(I31:I)
    
2 of 2
1

I would try: =IF(ISNUMBER(D31), "X", iferror(1/0))

I am told that the iferror(1/0) returns nothing at all.

🌐
Google Support
support.google.com › docs › thread › 18438805
countifs not working - Google Docs Editors Community
November 3, 2019 - Skip to main content · Google Docs Editors Help · Sign in · Google Help · Help Center · Community · Google Docs Editors · Terms of Service · Submit feedback · Send feedback on
🌐
Google Support
support.google.com › docs › thread › 6545645
Countif statements work in formula bar but isn't showing correct count in cell. - Google Docs Editors Community
May 21, 2019 - Skip to main content · Google Docs Editors Help · Sign in · Google Help · Help Center · Community · Google Docs Editors · Terms of Service · Submit feedback · Send feedback on
🌐
Facebook
facebook.com › groups › ilovegooglesheets › posts › 1274759460572709
Why is my countif function not working in Google Sheets?
Popular groups · Find communities for you · Over 1 billion people across the globe are using Facebook Groups to explore their favorite topics · Log in · Categories · Science & tech · Travel · Animals · Sports & fitness · Entertainment
🌐
SimpleSheets
simplesheets.co › blog › learn-what-is-google-sheets-countif
Google Sheets Countif: Everything You Need To Know
February 18, 2023 - Check the formulas used if the COUNTIF function on your spreadsheet is not working correctly. Please make sure there are no mistakes in them that could cause the COUNTIF function not to work correctly. Can the Countif function be applied in Google Sheets without specifying a range?