Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Grouping and details for groups Post Reply Post New Topic
Author Message
tdev
Newbie
Newbie
Avatar

Joined: 27 Aug 2012
Online Status: Offline
Posts: 2
Quote tdev Replybullet Topic: Grouping and details for groups
     Posted: 27 Aug 2012 at 1:56am
Hi, I need some help with a problem I have designing a report with

a) groups based on the value of a report field and
b) displaying details for groups.

a) I have an SP in SQL 2008 and the dataset contains transaction values for companies with 'ParentID', 'OrganisationID' and 'Structurelevel' fields. The maximum number of structure level is 9 with 2 the minimum. I want to group the report by the organisation structure levels of the companies, but I cannot find a way to design the number of groups based on the maximum structure level.

Here is an example of the data:

ParentID OrganisationID  Structurelevel
0              1                        1
1              12                      2
1              13                      2 
12            121                    3
12            122                    3
13            131                    3
13            132                    3
2              21                      2 
21            211                    3

In the example, I want to make group1 for structure level 1, group2 for level 2 and group3 for level 3. I am able to design a report with fixed number of groups and drill down for each ID, but to change the number of groups according to the number of levels has eluded me ... if its possible.

b) On the above report, I want to be able to drill down for each group to display the transaction data for that group. I'm not sure if I can use multiple detail sections linked to specific groups or will sub reports will be my only option to accomplish this?

Thanks in advance.


IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 27 Aug 2012 at 4:07am
So you have an n-level hierarchy with a maximum of 9 levels, correct?
 
Here's some thoughts on what you need to do:
 
1.  You'll need a copy of your data for each level of the hierarchy.  When you try to add a table to your report that is already in the report, Crystal will put up a warning and give you the option to "alias" the table.  When a table is aliased, Crystal will put _n at the end of the name where "n" is the number of this copy.  I'm not sure whether this same procedure will work with SP's, though.  If it doesn't, I'm not sure that there's a way to use subreports for this because you can't put a subreport inside another subreport.
 
2.  Left outer join from each parent to its child.
 
3.  Group by the Organization ID in EACH of the tables.
 
4.  In the Section Expert, turn on "Suppress If Blank" for each of your group sections.  If you have static text (that always appears regardless of whether there's data) in the section, you'll need to use a Suppress formula instead.  The formula would look something like this:
 
IsNull({MyTable_3.OrganisationID})
 
You would use whichever table alias is appropriate for the section.
 
5.  Put your data in group header sections - suppress the details.
 
-Dell
IP IP Logged
tdev
Newbie
Newbie
Avatar

Joined: 27 Aug 2012
Online Status: Offline
Posts: 2
Quote tdev Replybullet Posted: 27 Aug 2012 at 6:45am
Thanks for the reply.

Yes, max of 9 levels. What I did try was to select level 1 as parent, level 2 as division and level 3 as branch in columns and then add a group for each of these columns. Then added a sub report to each group that displays the detail for that group only, but I still have a problem of having a fixed number of groups and I had a problem of selecting level 4+ in my query. I will follow your method and post the outcome here.
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