Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Raymond Gallegos
 
Posts: n/a
Default Using Countif for Date Matches

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0, when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005
  #2   Report Post  
tjtjjtjt
 
Posts: n/a
Default

Perhaps something like:
=SUMPRODUCT(--(YEAR(SalesForecast!D1:D4)=2004))

For an explanation of what is going on, see:
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

tj

"Raymond Gallegos" wrote:

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0, when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005

  #3   Report Post  
Peo Sjoblom
 
Posts: n/a
Default

One way

=SUMPRODUCT(--(YEAR(SalesForecast!D1:D4)=2004))


Regards,

Peo Sjoblom

"Raymond Gallegos" wrote:

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0, when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005

  #5   Report Post  
Jason Morin
 
Posts: n/a
Default

A few ways:

=SUMPRODUCT(--(YEAR(A1:A4)=2004))
=COUNTIF(A1:A4,"=1/1/04")-COUNTIF(A1:A4,"12/31/04")
=SUM(COUNTIF(A1:A4,{"=1/1/04","12/31/04"})*{1,-1})

HTH
Jason
Atlanta, GA

-----Original Message-----
Hello. I am trying to count the number of sales that

occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get

is 0, when
I thought I would get 1, which represented the sale for

2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005
.



  #6   Report Post  
JBoulton
 
Posts: n/a
Default

tj

That looks so simple, but I get !VALUE# using this formula:

=SUMPRODUCT(--(YEAR(A$1:A182)=2004))

Col A is all dates. What's wrong?

TIA

"tjtjjtjt" wrote:

Perhaps something like:
=SUMPRODUCT(--(YEAR(SalesForecast!D1:D4)=2004))

For an explanation of what is going on, see:
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

tj

"Raymond Gallegos" wrote:

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0, when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005

  #7   Report Post  
tjtjjtjt
 
Posts: n/a
Default

How are you typing your dates compared to your system settings?

I'm using US dates: 12/26/2004 means December 26th of 2004. If I type
26/12/2004 in my range, I get #VALUE.

I copied and pasted your formula, and it worked fine. I suspect you are
typing your dates in a way your operating system isn't recognizing as a date.

(If your) In Windows, go into the Control Panel and find the Regional
Settings. Do the settings for your Date Formats look the same as how you
typed Dtes in Excel? If not, that is the problem.

tj

"JBoulton" wrote:

tj

That looks so simple, but I get !VALUE# using this formula:

=SUMPRODUCT(--(YEAR(A$1:A182)=2004))

Col A is all dates. What's wrong?

TIA

"tjtjjtjt" wrote:

Perhaps something like:
=SUMPRODUCT(--(YEAR(SalesForecast!D1:D4)=2004))

For an explanation of what is going on, see:
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

tj

"Raymond Gallegos" wrote:

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0, when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005

  #8   Report Post  
JBoulton
 
Posts: n/a
Default

tj,

That's an interesting idea, but doesn't apply here. My dates are mm/dd/yyyy
both in the spreadsheet and in the control pannel.



"tjtjjtjt" wrote:

How are you typing your dates compared to your system settings?

I'm using US dates: 12/26/2004 means December 26th of 2004. If I type
26/12/2004 in my range, I get #VALUE.

I copied and pasted your formula, and it worked fine. I suspect you are
typing your dates in a way your operating system isn't recognizing as a date.

(If your) In Windows, go into the Control Panel and find the Regional
Settings. Do the settings for your Date Formats look the same as how you
typed Dtes in Excel? If not, that is the problem.

tj

"JBoulton" wrote:

tj

That looks so simple, but I get !VALUE# using this formula:

=SUMPRODUCT(--(YEAR(A$1:A182)=2004))

Col A is all dates. What's wrong?

TIA

"tjtjjtjt" wrote:

Perhaps something like:
=SUMPRODUCT(--(YEAR(SalesForecast!D1:D4)=2004))

For an explanation of what is going on, see:
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

tj

"Raymond Gallegos" wrote:

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0, when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005

  #9   Report Post  
RagDyeR
 
Posts: n/a
Default

I have to agree that the problem is probably your data in the search column.

Exactly how is Column A populated?

Keyed in ... result of formula ... import from other source?
--

Regards,

RD
--------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit !
--------------------------------------------------------------------

"JBoulton" wrote in message
...
tj,

That's an interesting idea, but doesn't apply here. My dates are mm/dd/yyyy
both in the spreadsheet and in the control pannel.



"tjtjjtjt" wrote:

How are you typing your dates compared to your system settings?

I'm using US dates: 12/26/2004 means December 26th of 2004. If I type
26/12/2004 in my range, I get #VALUE.

I copied and pasted your formula, and it worked fine. I suspect you are
typing your dates in a way your operating system isn't recognizing as a

date.

(If your) In Windows, go into the Control Panel and find the Regional
Settings. Do the settings for your Date Formats look the same as how you
typed Dtes in Excel? If not, that is the problem.

tj

"JBoulton" wrote:

tj

That looks so simple, but I get !VALUE# using this formula:

=SUMPRODUCT(--(YEAR(A$1:A182)=2004))

Col A is all dates. What's wrong?

TIA

"tjtjjtjt" wrote:

Perhaps something like:
=SUMPRODUCT(--(YEAR(SalesForecast!D1:D4)=2004))

For an explanation of what is going on, see:
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

tj

"Raymond Gallegos" wrote:

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0, when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005



  #10   Report Post  
JBoulton
 
Posts: n/a
Default

Rag,

The daya is keyed. I can sort the data and it appears correct. If there
were something amiss, the errors would be at the top or bottom, I think.

"RagDyeR" wrote:

I have to agree that the problem is probably your data in the search column.

Exactly how is Column A populated?

Keyed in ... result of formula ... import from other source?
--

Regards,

RD
--------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit !
--------------------------------------------------------------------

"JBoulton" wrote in message
...
tj,

That's an interesting idea, but doesn't apply here. My dates are mm/dd/yyyy
both in the spreadsheet and in the control pannel.



"tjtjjtjt" wrote:

How are you typing your dates compared to your system settings?

I'm using US dates: 12/26/2004 means December 26th of 2004. If I type
26/12/2004 in my range, I get #VALUE.

I copied and pasted your formula, and it worked fine. I suspect you are
typing your dates in a way your operating system isn't recognizing as a

date.

(If your) In Windows, go into the Control Panel and find the Regional
Settings. Do the settings for your Date Formats look the same as how you
typed Dtes in Excel? If not, that is the problem.

tj

"JBoulton" wrote:

tj

That looks so simple, but I get !VALUE# using this formula:

=SUMPRODUCT(--(YEAR(A$1:A182)=2004))

Col A is all dates. What's wrong?

TIA

"tjtjjtjt" wrote:

Perhaps something like:
=SUMPRODUCT(--(YEAR(SalesForecast!D1:D4)=2004))

For an explanation of what is going on, see:
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

tj

"Raymond Gallegos" wrote:

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0, when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005






  #11   Report Post  
RagDyer
 
Posts: n/a
Default

Couple of ways I could duplicate the VALUE! error with correctly formatted
date data, was to put a <Space in front of the date, and/or have *alpha*
text somewhere within the range.
Numeric text is accepted.
Even a space entered in front of a *single* date in the entire range
produced the #VALUE! error, even if the date was not one of the ones that
met the criteria.

Any possibility of that?

Try this formula:

=SUMPRODUCT(--(YEAR(TRIM(A$1:A182))=2004))

This will take care of any cells that may contain a leading space.
However, the caveat here, is that with this TRIM() inserted, you *CANNOT*
have any empty cells in the range (A1:A182).

Also, what happens when you try the second and third formulas of Jason?
Either of those should work with text or spaces.
--

HTH,

RD
--------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit!
-------------------------------------------------------------------

"JBoulton" wrote in message
...
Rag,

The daya is keyed. I can sort the data and it appears correct. If there
were something amiss, the errors would be at the top or bottom, I think.

"RagDyeR" wrote:

I have to agree that the problem is probably your data in the search

column.

Exactly how is Column A populated?

Keyed in ... result of formula ... import from other source?
--

Regards,

RD
--------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit !
--------------------------------------------------------------------

"JBoulton" wrote in message
...
tj,

That's an interesting idea, but doesn't apply here. My dates are

mm/dd/yyyy
both in the spreadsheet and in the control pannel.



"tjtjjtjt" wrote:

How are you typing your dates compared to your system settings?

I'm using US dates: 12/26/2004 means December 26th of 2004. If I type
26/12/2004 in my range, I get #VALUE.

I copied and pasted your formula, and it worked fine. I suspect you are
typing your dates in a way your operating system isn't recognizing as a

date.

(If your) In Windows, go into the Control Panel and find the Regional
Settings. Do the settings for your Date Formats look the same as how you
typed Dtes in Excel? If not, that is the problem.

tj

"JBoulton" wrote:

tj

That looks so simple, but I get !VALUE# using this formula:

=SUMPRODUCT(--(YEAR(A$1:A182)=2004))

Col A is all dates. What's wrong?

TIA

"tjtjjtjt" wrote:

Perhaps something like:
=SUMPRODUCT(--(YEAR(SalesForecast!D1:D4)=2004))

For an explanation of what is going on, see:
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

tj

"Raymond Gallegos" wrote:

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0, when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005





  #12   Report Post  
JBoulton
 
Posts: n/a
Default

Rag,

You're right in that those errors *would* cause my problem, but it turns out
that's not the source of the problem. A1 contains a heading (date.) When I
changed the array to $a$2 the error disappeared.

Thanks so much for your helpful attention to my problem. My final formula,
where I was truly heading is:
=SUMPRODUCT(--(MONTH(A$2:$A183)=MONTH($A183)),C$2:$C183)

This gives me the running total by month. Now it works as it should.

Thanks, again.

"RagDyer" wrote:

Couple of ways I could duplicate the VALUE! error with correctly formatted
date data, was to put a <Space in front of the date, and/or have *alpha*
text somewhere within the range.
Numeric text is accepted.
Even a space entered in front of a *single* date in the entire range
produced the #VALUE! error, even if the date was not one of the ones that
met the criteria.

Any possibility of that?

Try this formula:

=SUMPRODUCT(--(YEAR(TRIM(A$1:A182))=2004))

This will take care of any cells that may contain a leading space.
However, the caveat here, is that with this TRIM() inserted, you *CANNOT*
have any empty cells in the range (A1:A182).

Also, what happens when you try the second and third formulas of Jason?
Either of those should work with text or spaces.
--

HTH,

RD
--------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit!
-------------------------------------------------------------------

"JBoulton" wrote in message
...
Rag,

The daya is keyed. I can sort the data and it appears correct. If there
were something amiss, the errors would be at the top or bottom, I think.

"RagDyeR" wrote:

I have to agree that the problem is probably your data in the search

column.

Exactly how is Column A populated?

Keyed in ... result of formula ... import from other source?
--

Regards,

RD
--------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit !
--------------------------------------------------------------------

"JBoulton" wrote in message
...
tj,

That's an interesting idea, but doesn't apply here. My dates are

mm/dd/yyyy
both in the spreadsheet and in the control pannel.



"tjtjjtjt" wrote:

How are you typing your dates compared to your system settings?

I'm using US dates: 12/26/2004 means December 26th of 2004. If I type
26/12/2004 in my range, I get #VALUE.

I copied and pasted your formula, and it worked fine. I suspect you are
typing your dates in a way your operating system isn't recognizing as a

date.

(If your) In Windows, go into the Control Panel and find the Regional
Settings. Do the settings for your Date Formats look the same as how you
typed Dtes in Excel? If not, that is the problem.

tj

"JBoulton" wrote:

tj

That looks so simple, but I get !VALUE# using this formula:

=SUMPRODUCT(--(YEAR(A$1:A182)=2004))

Col A is all dates. What's wrong?

TIA

"tjtjjtjt" wrote:

Perhaps something like:
=SUMPRODUCT(--(YEAR(SalesForecast!D1:D4)=2004))

For an explanation of what is going on, see:
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

tj

"Raymond Gallegos" wrote:

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0, when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005






  #13   Report Post  
RagDyer
 
Posts: n/a
Default

Thanks for the feed-back.

And I'll bet that *THAT* WAS* the source of the problem, the header being
*TEXT*.
If the header was a "true" date, formatted to display whatever you wanted to
see, the formula would have worked!
--


Regards,

RD
--------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit!
-------------------------------------------------------------------

"JBoulton" wrote in message
...
Rag,

You're right in that those errors *would* cause my problem, but it turns out
that's not the source of the problem. A1 contains a heading (date.) When I
changed the array to $a$2 the error disappeared.

Thanks so much for your helpful attention to my problem. My final formula,
where I was truly heading is:
=SUMPRODUCT(--(MONTH(A$2:$A183)=MONTH($A183)),C$2:$C183)

This gives me the running total by month. Now it works as it should.

Thanks, again.

"RagDyer" wrote:

Couple of ways I could duplicate the VALUE! error with correctly formatted
date data, was to put a <Space in front of the date, and/or have *alpha*
text somewhere within the range.
Numeric text is accepted.
Even a space entered in front of a *single* date in the entire range
produced the #VALUE! error, even if the date was not one of the ones that
met the criteria.

Any possibility of that?

Try this formula:

=SUMPRODUCT(--(YEAR(TRIM(A$1:A182))=2004))

This will take care of any cells that may contain a leading space.
However, the caveat here, is that with this TRIM() inserted, you *CANNOT*
have any empty cells in the range (A1:A182).

Also, what happens when you try the second and third formulas of Jason?
Either of those should work with text or spaces.
--

HTH,

RD
--------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit!
-------------------------------------------------------------------

"JBoulton" wrote in message
...
Rag,

The daya is keyed. I can sort the data and it appears correct. If there
were something amiss, the errors would be at the top or bottom, I think.

"RagDyeR" wrote:

I have to agree that the problem is probably your data in the search

column.

Exactly how is Column A populated?

Keyed in ... result of formula ... import from other source?
--

Regards,

RD
--------------------------------------------------------------------
Please keep all correspondence within the Group, so all may benefit !
--------------------------------------------------------------------

"JBoulton" wrote in message
...
tj,

That's an interesting idea, but doesn't apply here. My dates are

mm/dd/yyyy
both in the spreadsheet and in the control pannel.



"tjtjjtjt" wrote:

How are you typing your dates compared to your system settings?

I'm using US dates: 12/26/2004 means December 26th of 2004. If I type
26/12/2004 in my range, I get #VALUE.

I copied and pasted your formula, and it worked fine. I suspect you

are
typing your dates in a way your operating system isn't recognizing as

a
date.

(If your) In Windows, go into the Control Panel and find the Regional
Settings. Do the settings for your Date Formats look the same as how

you
typed Dtes in Excel? If not, that is the problem.

tj

"JBoulton" wrote:

tj

That looks so simple, but I get !VALUE# using this formula:

=SUMPRODUCT(--(YEAR(A$1:A182)=2004))

Col A is all dates. What's wrong?

TIA

"tjtjjtjt" wrote:

Perhaps something like:
=SUMPRODUCT(--(YEAR(SalesForecast!D1:D4)=2004))

For an explanation of what is going on, see:
http://www.xldynamic.com/source/xld.SUMPRODUCT.html

tj

"Raymond Gallegos" wrote:

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0,

when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005







  #14   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On Thu, 23 Dec 2004 08:45:02 -0800, "Raymond Gallegos"
wrote:

Hello. I am trying to count the number of sales that occurred
in 2004 by using the following Countif formula
=COUNTIF(SalesForecast!D1:D4,year=2004), but all I get is 0, when
I thought I would get 1, which represented the sale for 2004.
Can anyone help?

Data
01/01/2003
03/15/2003
06/01/2004
09/30/2005


=COUNTIF(SalesForecast!D1:D4,"=" & DATE(2004,1,1)) -
COUNTIF(SalesForecast!D1:D4,"" & DATE(2004,12,31))


--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
countif statement Russell Hampton Excel Worksheet Functions 6 December 18th 04 07:39 PM
Countif - Countif maswinney Excel Worksheet Functions 3 November 15th 04 11:06 PM
Countif ??? terryv Excel Worksheet Functions 2 November 8th 04 09:03 AM
countif, again Liz G Excel Worksheet Functions 2 November 1st 04 11:20 PM
combining countif formulas Liz G Excel Worksheet Functions 3 November 1st 04 09:34 PM


All times are GMT +1. The time now is 11:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"