Print Page | Close Window

Count formula for number of records in a Group

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22044
Printed Date: 05 May 2024 at 7:28am


Topic: Count formula for number of records in a Group
Posted By: karenb
Subject: Count formula for number of records in a Group
Date Posted: 07 Aug 2016 at 9:08pm
Hi there

I am grouping my report in two levels:

Group1: Object Category
then
Group2: Object Location

At the Group2 Object Location level I want to show a count of how many objects are there in that Group2 location, under that Group1 category.

I've tried putting a running total field in the Group2 footer and, but don't seem to be able to get the correct counts out. I also tried doing a simple formula field with "count" commmand in it but that didn't work either.

Can anyone suggest what I'm doing wrong?

cheers
Karen




Replies:
Posted By: kevlray
Date Posted: 08 Aug 2016 at 6:14am
When you say 'a count of how many objects are there', did you want a row count or something else?  Counts can be a bit tricky if you have duplicated values and/or have conditionally suppressed details.  Can you provide further information on what you are counting?


Posted By: karenb
Date Posted: 08 Aug 2016 at 1:18pm
Hi there Kevlray, thanks for your reply..

I am retrieving a bunch of records, each containing a value in the "Object Category" field and a value in the "Object Location" field. I then want to run a report that will show me for each Object Category, how many records are in each Object Location. I am grouping the report by Object Category and then by Object Location. Within each Object Category group, I want to show how many objects (records) are in each Object Location group. No iteration of the running total field is counting it properly for me!

Here's an example data sample:

Record 1
Object Category = Agriculture
Object Location = Basement1

Record 2
Object Category = Agriculture
Object Location = Basement1

Record 3
Object Category = Models
Object Location = Basement1

Record 4
Object Category = Models
Object Location = Basement3

So then I want the output to be grouped like this:

Object Category: AGRICULTURE
Object Location: Basement1
No of Objects: 2

Object Category: MODELS
Object Location: Basement1
No of Objects: 1
Object Location: Basement3
No of Objects: 1

Too put it simply I just want to count the number of object records that occur within each Object Location Group.

I think it should be pretty simple to do but it's just not working for me!
cheers
Karen


Posted By: karenb
Date Posted: 08 Aug 2016 at 1:59pm
Hi again...

Suddenly this morning I seem to have hit upon the right approach in my Running Total (in the Object Location Group Footer)..

Summarise: Object Record identifier
Type of Summary: Distinct Count
Evaluation: For each record
Reset: On change of group -> Object Location

This seems to be counting correctly now! Perhaps I hadn't tried this combination.

I'll leave this open until I am convinced it really is working :-)

cheers for your help
Karen


Posted By: kevlray
Date Posted: 09 Aug 2016 at 5:20am
The running total that you created appears to be correct.



Print Page | Close Window