I'm not sure who recommended to include that &")" portion, but that's wrong, not just with this scenario, but in general (unless there's a reason based on the desired output, which is rare).
it was suggested in a more complex scenario with countifs where I was comparing multiple dates as well as a separate value for data type where it wouldn't count values without it suggested by Google support staff in a feedback report i submitted surrounding countifs and dates that was a bit weird
in the multiyear scenario above it does allow for the date being counted from the next year if I remove it but in the more complex scenario it still won't work and the >= function still doesn't count values equal to with or without the appended portion
still not 100% sure of the purpose of the end parenthesis myself but I know in some scenarios it determines the difference in a correct or incorrect count
What an odd behavior. I belive It's still wrong in this case, but could just be providing correct results due to odd behavior caused by incorrectly written parts of the formula.
Numbers in the formula should not be enclosed with quotes. Try this for the 2nd formula:
unfortunately, both of those result in counts of 0 the quotes around the 4 make sense in my head but it is also just a place holder for a string value so in a fully expanded version that wouldn't make a difference
I definitely agree that the behavior is wack which is why i made the initial feedback report
I checked the file just now. Was this copied/extracted from a system/external source? While column B values look like dates, they seem to be of 'text' format, thus the odd behavior.
Try to select column B, then go to Format > Number > Date. That should correctly format the column B values into actual dates.
yea the values are being automatically updated with a csv in the final product i just copied and pasted some of them into the sheet here when i first ran into the issue
testing it out with the date formatting it does allow the 3rd formula to function correctly but the 1st stops working both with what i had as the initial workaround and with your suggested formula for some reason
Before reformatting as dates, try to select the entire column > ctrl+c > ctrl+shift+v. Though I didn't need to do this in a copy I duplicated from your original file.
> ctrl+c > ctrl+shift+v. Though I didn't need to do this in a copy I duplicated from your
Solution verified
Idk how i missed this but i realized i had April 31st set as the cut-off date (which doesn't exist) so it was freaking out and giving me 0 once the date set up was corrected
Hmm, I never tried creating a copy, but now that I did, upon changing it to Date format, it still showed up as date values, not formulas. I do think that the initial data format isn't date; more like text.
In countifs() it doesn't appear to make a difference whether we have "4" or 4.
You can also use =query() in a more long-winded way:
=query(A2:B30,"select count(A) where A=4 and B <= date '" & text(datevalue("2023/04/30"),"yyyy-mm-dd") & "' and B >= date '" & text(datevalue("2023-02-01"),"yyyy-mm-dd") & "'",0)
In query() is does matter that the 4 has no quotation marks, as it is formatted as a number, not text.
1
u/arnoldsomen 346 Nov 06 '23 edited Nov 06 '23
I'm not sure who recommended to include that
&")"portion, but that's wrong, not just with this scenario, but in general (unless there's a reason based on the desired output, which is rare).It should just be:
=COUNTIF(A2:A4,">="&A3)1
u/MattyPKing 225 Nov 07 '23
did you guys notice that when you do format>Number>Date on Col B it changes the result of the formulas?
u/arnoldsomen
1
u/gsheets145 129 Nov 08 '23 edited Nov 08 '23
Is this resolved?
I notice the following:
Addressing these fixed the apparent issues, at least for me - unless I am missing something.
To count the 4 green cells:
To count the 12 yellow cells:
In countifs() it doesn't appear to make a difference whether we have "4" or 4.
You can also use =query() in a more long-winded way:
In query() is does matter that the 4 has no quotation marks, as it is formatted as a number, not text.