CountIIF - Counting Date Values - CountIF

Gordon

Gordon
Local time
Today, 00:58
Joined
Nov 25, 1999
Messages
34
I've read various posts, some of which indicate that the CountIF function does not exist, and some of which suggest using it.

What I'm trying to do is to show the number of incidents in a report where the date in the field "Current Revision Date" is greater than a given date.

Here are the formulas I've tried:

=Count(IIf([Current Revision Date]>5/1/2007,1,0))

I've also tried:
=Count([Current Revision Date]>5/1/2007)

The result I get is a count of all of the records, not just the records whose date is greater than 5/1/2007

Any suggestions?

Thanks.....

Gordon
 

boblarson

Smeghead
Local time
Yesterday, 16:58
Joined
Jan 12, 2001
Messages
32,059
=Count(IIf([Current Revision Date]>#5/1/2007#,1,0))
 

Gordon

Gordon
Local time
Today, 00:58
Joined
Nov 25, 1999
Messages
34
=Count(IIf([Current Revision Date]>#5/1/2007#,1,0))

Hi Bob,

Thanks so much for the quick response. I tried your suggestion, but am still getting all 36 records. I should only be getting about 16 records. :(

Any other thoughts?

Gordon
 

boblarson

Smeghead
Local time
Yesterday, 16:58
Joined
Jan 12, 2001
Messages
32,059
Is your date field a date/time field (with time in it as well)? I've had that problem before so I created a separate date field in my query to be just the date.
 

Gordon

Gordon
Local time
Today, 00:58
Joined
Nov 25, 1999
Messages
34
Sum and Count for selective Counting of Records -- CountIF

I found the following suggestion in another Thread:

"Count gives a total count of all the records, which is what it is supposed to do.

Sum gives a total count of all the records meeting the criteria, it Sums the result of the IIf statement."

I tried changing the formula to

=Sum(IIf([Current Revision Date]>#5/1/2007#,1,0)) and it returns the correct result.

Does anyone see any problem with using "Sum" instead of "Count"?

Gordon
 

Gordon

Gordon
Local time
Today, 00:58
Joined
Nov 25, 1999
Messages
34
Format date for selective criteria query

Is your date field a date/time field (with time in it as well)? I've had that problem before so I created a separate date field in my query to be just the date.

Good suggestion... but the format is "Short Date" (D/mm/yy)

Gordon
 

Brianwarnock

Retired
Local time
Today, 00:58
Joined
Jun 2, 2003
Messages
12,701
I found the following suggestion in another Thread:

"Count gives a total count of all the records, which is what it is supposed to do.

Sum gives a total count of all the records meeting the criteria, it Sums the result of the IIf statement."

I tried changing the formula to

=Sum(IIf([Current Revision Date]>#5/1/2007#,1,0)) and it returns the correct result.

Does anyone see any problem with using "Sum" instead of "Count"?

Gordon

No the use of Sum is correct, the IIf returns 1 when the criteria is met and you want to sum those 1s

Brian
 

rachel_fo

New member
Local time
Yesterday, 17:58
Joined
Jun 11, 2013
Messages
1
My problem is similar. I am creating a query, which I will then create a report from (unless there is an easier way- I'm an Access noob).

I'm trying to create a report where it will count how many instances/rows occur in a date range recorded in a field (DateofEvent) in each record. I also want it to sum a different field (NumberSpokenTo).

On the report, I'd like it to break down progress by week looking like the following:
Week Range # of Events # Spoken To
May 26-June 1 5 400
June 2-June 8 4 150

Any help appreciated. Please don't assume I know what I'm doing at all in your response! :confused:
 

Users who are viewing this thread

Top Bottom