Count of Report values in Report Footer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I need to create a count at the end of my report that tells me how many
occurances of a certain value appear in the report.
e.g. Report field of "Issue". Possible values of "Red" or "Amber". Need to
count how many times red and amber occurs.
I guess, something like "COUNT(Issue) where Issue = "Red")" is needed.
e.g. 2 (more complex)
e.g. Report field of "Name". I do not want to "hard code" the possible
values that can appear in the report for Name but I need to count how many
times each name appears in the report.
I have played around with SUM and COUNT and tried the Running Sum function
but to no avail.
Any help much appreciated.
Thanks, Mark
 
Mark said:
I need to create a count at the end of my report that tells me how many
occurances of a certain value appear in the report.
e.g. Report field of "Issue". Possible values of "Red" or "Amber". Need to
count how many times red and amber occurs.
I guess, something like "COUNT(Issue) where Issue = "Red")" is needed.
e.g. 2 (more complex)
e.g. Report field of "Name". I do not want to "hard code" the possible
values that can appear in the report for Name but I need to count how many
times each name appears in the report.
I have played around with SUM and COUNT and tried the Running Sum function
but to no avail.


For a quick and dirty approach, you can use expressions like
this:
=Sum(IIf(Issue = "red", 1, 0))

But, you're right, you do not want to use hard coded values
most of the time. A more general approach is to create a
Totals type query that retrieves the desired data and
calculates the counts for each name or issue. Then use the
query as the record source for a subreport.
 
Hi Marshall,

Ive tried the =Sum(IIf(Issue = "red", 1, 0)) but it did not seem to work,
could you provide an alternate approach or give more details regarding how to
create a totals type query. Any help you can provide would be great.

Regards.
Nick
 
The =Sum(IIf(Issue = "red", 1, 0)) expression is a tried
and true text box expression as long as [Issue] is a field
in the report's record source table/query. It also assumes
that the [Issue] field actually has a value of "red" and not
some foreign key number into another table that contains the
color name. Also, make sure the text box is in the report
(or group) footer, not the page footer.

The subreport approach would be a trivial report baxed on a
Totals query along these lines:

SELECT Issue, Count(*) As CodeCount
FROM thetable
WHERE <samecriteriaas mainreport>
GROUP BY Issue
 
Back
Top