Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Grouping a report by page count Post Reply Post New Topic
Author Message
DaRocke
Newbie
Newbie
Avatar

Joined: 02 Apr 2011
Online Status: Offline
Posts: 3
Quote DaRocke Replybullet Topic: Grouping a report by page count
     Posted: 02 Apr 2011 at 1:51am
Hi,

I was wondering, is it possible to group a report by the pages spanned by groups in the report. For example, say the first group spans 1 page (page 1 of 1), second group spans 4 pages (page 1 of 4) etc. I want to group all the items that only have one page together and all the items with more than one page together. Is this possible?

Thanks in advance.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 04 Apr 2011 at 3:41am
I don't think so.  CR would have to render the report to determine the number pages, and then render it again after grouping...  Since it can't determine the number of pages by just 'looking' at the raw data, it can't group on it.
 
You might try grouping by number of items, if you know how many fit on a page, you might group where the count of the items is < some value, that should give 2 groups.
 
HTH
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 04 Apr 2011 at 4:48am
is it possible to group a report by the pages spanned by groups in the report. For example, say the first group spans 1 page (page 1 of 1)


You can get close to it.

For instance, in section expert you can say you want a new page after each group footer. I think that's all it means to be "grouped by pages" really.

You can also "reset page number after" each group footer, so that will further make it appear that you are grouping by pages.

However I don't think you'll be able to determine the total number of pages a group spans and have the same number print on every page in the group, unless you found a clever way to use arrays. I'm thinking something like:

1: whilereadingrecords, on change of group, push the total number of pages into the array. This way you will have an array of "total page numbers" where the first index represents total pages for group 1, second index for group 2, etc.

2: whileprintingrecords, print the corresponding page number into the group footer, where you have a variable that will increment by one on change of group.

I'll see if my theory actually works. I'm actually interested in how much I can squeeze into the three-step passing system.

Edited by Keikoku - 04 Apr 2011 at 4:53am
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 04 Apr 2011 at 5:02am
Disregard my draft ideas, you can definitely group them by page.

The requirements for "group by page" can be defined as follows:

-all records in the group should appear consecutively across a span of pages
-exactly one group can be displayed in the span of pages
-if all records have been displayed for the current group, the next group must begin on the next page

With these conditions in mind, here's the procedure for my sample report that will have one group.

1. Create a group on the field you want
2. Go to section expert --> group footer
3. Check "new page after" and "reset page number after"
4. Expand the "special fields" tab in the field explorer and put a "Page N of M" field in the page footer

This method works for CRXI and up for sure.
The output for my sample report, grouped by date. Shows the record ID's that were filed for that date.



Edited by Keikoku - 04 Apr 2011 at 5:24am
IP IP Logged
DaRocke
Newbie
Newbie
Avatar

Joined: 02 Apr 2011
Online Status: Offline
Posts: 3
Quote DaRocke Replybullet Posted: 04 Apr 2011 at 9:32am
Hi Keikoku, thanks for your detailed reply. I am not entirely sure you understood what I was trying to acheive though (unless I've misunderstood your post).

I can group by a field and insert a page break after each field. Using the special field "Page N of M" I can easily display the page numbers. What I actually want to do is group items that fit unto one page together and items that span more than one page together. So I can display print off the items with only one page or items which span more than one page.

I've tried a few things. I have gone as far as grouping my a field, inserting a page break, using the "Page N of M" special field. I also created a formula field which basically stores the "total page count" (from the special field). This gives me the page count for each group.

But I have tried to group on using this formula field but it doesn't appear on the section expert (probably because it is a calculated field). Does this make sense?

Thanks.
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 04 Apr 2011 at 9:51am
What I actually want to do is group items that fit unto one page together and items that span more than one page together. So I can display print off the items with only one page or items which span more than one page.


I am not sure how that is different from what I have done. Crystal by default group things together.

But you may also look at the "keep together" option in the group expert for the particular group.

Maybe an example would be clearer?
IP IP Logged
DaRocke
Newbie
Newbie
Avatar

Joined: 02 Apr 2011
Online Status: Offline
Posts: 3
Quote DaRocke Replybullet Posted: 04 Apr 2011 at 10:33am
Hi,

For example: if I have a 100 pages in total, comprised of a 20 items spanning one page (20 x 1), 10 items spanning 5 pages (10 x 5) and 2 items spanning 15 pages (5 x 6).

Basically 10: Page 1 of 1
          20: Page 1 of 5, Page 2 of 5, Page 3 of 5, Page                      4 of 5, Page 5 of 5
          2 : Page 1 of 15, Page 2 of 15, Page 3 of 15... etc

I want the first 10 to follow each other sequentially, and the next 20 to follow sequentially and the next 2 to follow sequentially. I don't want them overlapping. Does that make sense? I want to know the the groups spanning one page are the first 10 items or pages.
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 05 Apr 2011 at 5:49am
Right, I didn't read the title.

Sorting groups by the number of records should be possible but it doesn't seem obvious how.

Probably can't do it perfectly, but if you have some idea which groups are more likely to have more items and want them to appear last, you can use a specified sort order to explicitly state what order the groups should be displayed.

If you want crystal to determine this on its own, one idea is to sort on group size, but I haven't found a way to do so.

Edited by Keikoku - 05 Apr 2011 at 7:18am
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