COUNTIF using structured reference and dates

PatRichard

New Member
Joined
Dec 29, 2018
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Greetings - I didn't see this in a search, but maybe I'm not searching right. I have a table with a column of dates. Some of the dates are mm/dd/yyyy, and some are just mm/yyyy. I'm trying to count the number of cells in a column in which the year is a specific value. But I'm just coming up with 0. I'm using:
Excel Formula:
=COUNTIF((MyInventory[Born On]),1985)
but also tried replacing the year with a cell reference (I'm building a table that shows quantities by year).

What am I missing here?
 
I am fully aware of that, see post#4
And your comment makes no sense in relation to what I said in reply to post#6
I guess a picture's worth a lot of words!
Book1
ABC
1Date2
201/01/20224
302/2022
403/01/2022
504/2022
Sheet5
Cell Formulas
RangeFormula
C1C1=COUNT(A2:A5)
C2C2=COUNTA(A2:A5)
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I've absolutely no idea what your point is.
 
Upvote 0
I am fully aware of that, see post#4
And your comment makes no sense in relation to what I said in reply to post#6
Guess sometimes it takes a picture.
Book1
ABC
1Date2
201/01/20224
302/2022
403/01/2022
504/2022
Sheet5
Cell Formulas
RangeFormula
C1C1=COUNT(A2:A5)
C2C2=COUNTA(A2:A5)

Without any other info, can you tell which cells are date and which are text?
 
Upvote 0
I still don't see what your point is. Try using words.
 
Upvote 0
I still don't see what your point is. Try using words.
The FORMAT of a cell can mask what it actually is. In the sample I just posted, the FORMAT of Cell A3 is yy/dddd
1670705719413.png

The FORMAT of cell is General - Right Aligned.
1670705819101.png

Why else would the COUNT function for A2:A5 return 2, and COUNTA returns 4.
The only reason the YEAR function wouldn't return the year of a date is if it isn't a date.
 
Upvote 0
The only reason the YEAR function wouldn't return the year of a date is if it isn't a date.
I know that, have you actually read post#4?.

Now please lets wait to hear back from the OP, rather than flooding the thread with posts that don't actually say anything new.
 
Upvote 0
Make sure that all the dates are real dates & not text.
Ensured all cells are date and it made no difference.

If you're not getting a valid return from something like COUNTIF (or COUNTIFS if you have a recent version of Excel - what OS and Excel Version can be added to your Profile), then those "dates" are not actually dates. If they were, regardless of their formatting (mm/dd/yyyy or mm/yyyy) they would represent an actual date, although in the second case you wouldn't know what the date is without either changing the format or using the DAY function. You should fix the data rather than find a work-around to bad data.
"Fixing" the data isn't an option. Older records don't have a day, just mm/yyyy. Nothing I can do about that right now. Setting those to be the first of the month just to get them into the right format isn't an option, either.

Are you able to add this column to MyInventory, and then count that instead?

Excel Formula:
=YEAR([@[Born On]])
This seems to work!

Guess sometimes it takes a picture.
Book1
ABC
1Date2
201/01/20224
302/2022
403/01/2022
504/2022
Sheet5
Cell Formulas
RangeFormula
C1C1=COUNT(A2:A5)
C2C2=COUNTA(A2:A5)

Without any other info, can you tell which cells are date and which are text?
They are all formatted as date cells
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top