Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Counts that include sub-report? Post Reply Post New Topic
Author Message
Ariel
Newbie
Newbie


Joined: 10 Jun 2010
Location: United States
Online Status: Offline
Posts: 33
Quote Ariel Replybullet Topic: Counts that include sub-report?
     Posted: 24 Jul 2013 at 6:23am
I have a report that is pulling a company roster.  Some of the employees work for a branch so I had to do a sub-report to pull them.  How do I do a count of employees using the information from the main report AND the sub-report.
Thanks!
Ariel
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 24 Jul 2013 at 6:29am
shared variables.

in the subreport you could have a line like:
shared numbervar empCount;
empCount := COUNT({table.field});
"" // this will hide the output, though you might want to display it.

Place the formula in the report footer or a group footer...whichever seems correct.

Now in the main report, create a formula like:
shared numbervar empCount;

count({table.field}) + empCount

This will display the total from the main report, plus the value from the subreport.

HTH
IP IP Logged
Ariel
Newbie
Newbie


Joined: 10 Jun 2010
Location: United States
Online Status: Offline
Posts: 33
Quote Ariel Replybullet Posted: 24 Jul 2013 at 6:54am
I did that but it's showing the same number for all the companies.
IP IP Logged
Ariel
Newbie
Newbie


Joined: 10 Jun 2010
Location: United States
Online Status: Offline
Posts: 33
Quote Ariel Replybullet Posted: 24 Jul 2013 at 8:08am
I got it working, thank you!
IP IP Logged
Ariel
Newbie
Newbie


Joined: 10 Jun 2010
Location: United States
Online Status: Offline
Posts: 33
Quote Ariel Replybullet Posted: 24 Jul 2013 at 8:17am
Just kidding - Now I need it broken down by Groups.  How do I do that?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 25 Jul 2013 at 4:44am
different variables.

if you want to see the totals of the main and the subreport based on the grouping, put the formula in the group footer.

you will need to modify the formula slightly to be like:
count({table.field}, {grouping value})

the {grouping value} should be available as a report value, it might be a formula or it might be a field...since i don't know how the report was written.

that would also go for the subtotal in the main.

HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum