• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 456
  • Last Modified:

Limit the number of detail lines printed for a group in crystal

I'm creating a push report which has a department group.  Within each group I only want to print a maximum 20 detail lines. How do I do this?
0
meagain0707
Asked:
meagain0707
  • 5
  • 3
  • 2
  • +1
2 Solutions
 
peter57rCommented:
What happens after 20 - do you want to ignore the rest?
0
 
meagain0707Author Commented:
Yes, ignore the rest for that group and print the next group with a maximum of 20 lines.
0
 
mlmccCommented:
BY ignore, are there summaries that should include the data from the suppressed records or do you want the summaries to be for just the records shown?

You can use formulas like this

In the group header add a formula
WhilePrintingRecords;
Global NumberVar GroupRecordCount;
GroupRecordCount := 0;

In the detail section suppression formula
WhilePrintingRecords;
Global NumberVar GroupRecordCount;
GroupRecordCount := GroupRecordCount + 1;
GroupRecordCount  > 20

mlmcc
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
meagain0707Author Commented:
The summaries should not include the data that may be missing, only up to the 20 lines. Also, Im using product version 11.0.0.895.
0
 
mlmccCommented:
You could try using a TOP 20 selection.

mlmcc
0
 
meagain0707Author Commented:
Thanks for you answers mlmcc.

I tried the Top 20 and it doesn't work for me because top 20 needs a summary for the group. Then it will rank the totals of the summary to print the top or the bottom N. This means that departments won't print, it's the detail lines that I don't want to print  for up to a maximun of 20 lines. I will keep this in mind if I ever need to build a report with those requirements.

I looked at your other solution with the formulas. I don't understand where to enter them. I don't know where the suppression formula is in the detail section. I don't know how to add a formula specific to the group header. Please help with some more details. I did try..... I think, for the group header, I just add the formula and suppress the printing?
0
 
James0628Commented:
You have a department group.  Create a formula like the first one that mlmcc posted and put it in the group header.  You can suppress the group header (if there's nothing in it that you need to see), or suppress that formula.

 I would also put that same formula in the report header.  It seems that global variables sometimes don't work properly if they're not declared at the beginning of the report.  Safest thing is to just put that same formula in the report header too.

 As for suppressing the extra details, if you also want the totals to only include the first 20 records, I think I'd handle the suppression a little differently.

 Create a new detail section and put it above the other detail section(s).  Suppress the new section.  Create a formula like the following and put it in the new detail section.

WhilePrintingRecords;
Global NumberVar GroupRecordCount;
GroupRecordCount := GroupRecordCount + 1


 Then to suppress the other detail section(s), go to the Section Expert and enter this formula for Suppress:

WhilePrintingRecords;
Global NumberVar GroupRecordCount;
GroupRecordCount  > 20


 I'm pretty sure that should work for the suppression.

 Just to be clear, I think mlmcc's suggestion would also work for the suppression.  But if you need totals, the most direct thing would seem to be to use the same counter there, and I'm not sure if a counter that's updated in the section suppression formula will work.  So, I put the counter update in a separate formula, in a separate detail section (before the section that you want to suppress, and before the formula(s) that will create your totals).

 As for your totals, I think you'll have to create those manually using formulas and variables.  For example, if there was a Quantity field, the formula to accumulate that total might look something like this:

WhilePrintingRecords;
Global NumberVar GroupRecordCount;
Global NumberVar Dept_Quantity;

if GroupRecordCount  <= 20 then
  Dept_Quantity := Dept_Quantity + {your Quantity field}


 Put that formula in a detail section _below_ the new section that you added above, and suppress the formula.

 Then you'd need a formula like the following in the group footer to output the total:

WhilePrintingRecords;
Global NumberVar Dept_Quantity


 You'd also need a formula to reset Dept_Quantity to 0 for each new group.  I'd just add that to the first formula that mlmcc posted (so it would reset GroupRecordCount to 0 and Dept_Quantity to 0).

 If you need more department (group) totals, or grand totals, you'd add variables and formulas for those.  All of the total variables can be reset (for group totals) and updated in the same formulas, but you'd need a separate formula to output each variable.

 If you need any more details, post some more details about your totals.  How many?  Department or grand totals, or both?  etc.

 James
0
 
meagain0707Author Commented:
Hi James,

You had excellent instructions for me to follow, thanks so much! I was able to limit the lines and do the group totals, I also had to add some grand totals. I learned a lot about crystal.

I didn't totally understand report I was developing until now. Not only do I need the limited lines(up to 20), but I also need a percentage calculation for each of those lines which uses the total for the group. (line amount /sum of the group ).  I don't have the 'sum' until the all the lines of the group are printed so I don'think this is possible. Is it?

I'm going to try to limit the result set sent to crystal instead.
0
 
James0628Commented:
 > I don't have the 'sum' until the all the lines of the group
 > are printed so I don'think this is possible. Is it?

 Off hand, I'm going to say no.  To have CR give you a group total in the details, you have to use a CR summary function, and I don't think you're going to be able to use one when you're limiting the number of records like that.

 You could put a subreport in the group header and have the subreport read the first 20 records for that group and save totals in variables, and then use those variables in the details in the main report to calculate your %'s.  It would be very inefficient, especially because, like the main report, it would be reading all of the records for the group, but only including the first 20 in the totals.  But it could theoretically be done.

 It would be much better if you can limit the data sent to CR instead, as you suggested.

 James
0
 
meagain0707Author Commented:
Hi James,

I did limit the data sent to CR.

Many thanks!
0
 
James0628Commented:
You're welcome.

 James
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now