Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Reports- Sub report Summary

Status
Not open for further replies.

brent21090

IS-IT--Management
Jan 14, 2013
4
0
0
US
I am attempting to get a distinctcount in a sub report for a date&time field and running into a problem. This is my formula;

shared datevar Totalcount:=
totalcount:= distinctcount({@obs_date}) Gives me an error that a date is required. I was intending of passing this datevar on to my main report so I can calculate an average. The formula field being referenced above is a conversion of a date & time field into just a date field.

When I attempt to use insert summary field option I just get a count of 1 on all my records.

Not sure what else to try.

Thanks for your help.
 
You are doing a distinct count on a field which returns a number, but you are assigning to a datetime variable. Thus do you want a date or a summary passed to the main report?
 
Then you should change your shared variable to a numbervar and the error will go away.

shared numbervar Totalcount;
totalcount:= distinctcount({@obs_date})
 
So that worked the only problem now I have is that the formula is returning a count = 1 and I know I have more than 1. I think its just counting each record and summarizing one instead of aggregating I have no grouping in my subreport. I have this formula in the Report footer. I do have 3 groups in the main report. Should this formula be placed in a different section??

Thanks for your help
 
Probably want it in a group (Which group I cannot say). Just be aware that a distinct count will only count when {@obs_date} is different (i.e., {@obs_date} <> next ({@obs_date}). I hope this helps.
 
Do you have details in your subreport, does it include the {@obs_date}? How are you linking from the main report to the sub-report? If it is only returning a values of one, then it appears that all of your {@obs_date}'s are the same value in the sub-report.

I hope this helps.
 
I do have a subreport that includes a detail section. In the detail section I have a date & time field. When I run the report there is more than 1 value for a specific group e.x Customer X 1/2/2013 12:41PM
1/3/2013 12:53PM
1/4/2013 12:55PM
The results displayed in date & time are part of a subreport. I think might best guess is to just pass this result into a shared variable and display it in the main report.
 
Quick question. Does the formula calculate properly in the sub-report?
 
You need to explain the group structure (what you are grouping on for each group, where you have placed the subreport in the main report (which report section), and on what fields you are linking the subreport.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top