Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Dyanmic grouping? Post Reply Post New Topic
Author Message
Anubisascends
Newbie
Newbie
Avatar

Joined: 05 Apr 2009
Online Status: Offline
Posts: 15
Quote Anubisascends Replybullet Topic: Dyanmic grouping?
     Posted: 28 Apr 2009 at 7:11am
Is there a way to change the order of the grouping for a report.

For instance, I have a report file that I am trying to use to replace two existing report files.  To get this to work, I need to group one report by Width, then by Length.  The other report needs to group by Length, then by Width.

This grouping is the only reason that we have multiple report files...

If there are any tricks or methods to do this, I would love to know, thank you in advanced for your help.




Edited by Anubisascends - 28 Apr 2009 at 7:11am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Apr 2009 at 7:56am
Create a parameter field at run time. You choose how you want to do it based on your deployment method. For this example I will just use a 1 and 2.
1=Width by Length
2= Length by Width
Assuming these are 2 different fields in you DB just create a formula field using this parameter.
if {?Parameter} =1 then {table.width} + " by " + {Table.length} else
if {?Parameter} =2 then {table.length} + " by " + {Table.width} else "ERROR"
The "ERROR" is not necessary but can be to catch items that for some reason didn't work correctly in the formula.
Change your group 1 to using this formula field to group on and it will swap the grouping based on the user selection at run time.
IP IP Logged
Anubisascends
Newbie
Newbie
Avatar

Joined: 05 Apr 2009
Online Status: Offline
Posts: 15
Quote Anubisascends Replybullet Posted: 28 Apr 2009 at 8:22am
The problem is that I need to group by the width and length (or vice versa)

I have the width and length displaying properly, I just need to change the order of the grouping.

Here is the default order of the groups:

Group 1 = Parts.Width
Group 2 = Parts.Length

I want to make a formula that I can change it to this:

Group 1 = Parts.Length
Group 2 = Parts.Width

I need to do this because there can be thousands upon thousands of records in the database.  Using this grouping (and a few others) I can give a count of the all the parts that are the same:

Name,
Size,
Material

Which will, in turn, shorten the printed report greatly.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 28 Apr 2009 at 8:41am
Just split it into 2 formulas then. Using my same example of a 1 or 2 for your parameter.
Formula 1 is for GROUP 1:
if {?Parameter} =1 then {parts.width} else {parts.length}
Formula 2 is for Group 2:
if {?Parameter} =1 then {parts.length} else {parts.width}
Instead of creating the group on the actual field you group it on the formual fields. The formula field dynamically changes between the fields basically just inverting your grouping.
Make sense?


Edited by DBlank - 28 Apr 2009 at 8:42am
IP IP Logged
Anubisascends
Newbie
Newbie
Avatar

Joined: 05 Apr 2009
Online Status: Offline
Posts: 15
Quote Anubisascends Replybullet Posted: 29 Apr 2009 at 9:30am
That is awesome...I never even thought of doing that....

thank you so much, this will drop my number of reports that I need significantly....
IP IP Logged
kemigirl
Newbie
Newbie


Joined: 05 May 2009
Online Status: Offline
Posts: 14
Quote kemigirl Replybullet Posted: 16 Jun 2009 at 1:06pm
DBlank,

THANK YOU for your detail!  I was able to apply your method to one of my reports, combining 4 reports into 1, which is absolutely amazing.  Thanks so much!

Clap
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