Report Design
 Crystal Reports Forum : Crystal Reports .NET 2003 : Report Design
Message Icon Topic: Dynamic Report Grouping Post Reply Post New Topic
Author Message
merkman
Newbie
Newbie


Joined: 19 Mar 2008
Online Status: Offline
Posts: 8
Quote merkman Replybullet Topic: Dynamic Report Grouping
    Posted: 19 Mar 2008 at 12:01pm

Crystal Reports
Product Version: 11.5.9.1076
OS: Microsoft Windows XP Pro
Database: MS SQL Server 2005
Connection Type: OLE DB (ADO) via UDL


In Crystal Reports I have a Parameter named Group Order
It has the static values of:
By Number
By Sequence


My Report currently is grouped by Number then by sequence.

If the Group Order = By Number I would like to group by number then by sequence.

If the Group Order = By Sequence I would like to group by sequence then by number.

Is this possible?

IP IP Logged
merkman
Newbie
Newbie


Joined: 19 Mar 2008
Online Status: Offline
Posts: 8
Quote merkman Replybullet Posted: 19 Mar 2008 at 12:03pm
Sorry I just noticed this is in the wrong topic.
 
Let me know if the admin can move it or if I need to repost it in the other topic.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 19 Mar 2008 at 4:57pm

This is not too difficult.

1.  Create a parameter so that you pass into the report how you want it grouped. (I'll call it {?Grouping})
 
2.  Create two formulas (I'll call them {@Group1} and {@Group2}): 
{@Group1} is
If {?Grouping} = "By Number" then {number field} else {sequence field}
{@Group2} is
If {?Grouping} = "By Number then {sequence field} else {number field}
 
3.  Use these formulas for your groups.
 
If one of the fields is a number and one is a string, you'll have to convert the number to a string.  However, there is a trick to this because numbers converted to strings sort like strings.  For example:
Number Sort            String Sort
1                            1
2                            10
3                            2
10                           22
22                           10
 
So, you have to do something like this to get it to sort correctly:
 
Right("          " + ToText({number field}, 0), 10)
 
Between the quotes should be the spaces (or zeroes) to match the length of the number field.  You would also change "10" to the length of the number field.
 
-Dell
IP IP Logged
merkman
Newbie
Newbie


Joined: 19 Mar 2008
Online Status: Offline
Posts: 8
Quote merkman Replybullet Posted: 20 Mar 2008 at 6:03am
Originally posted by hilfy

3.  Use these formulas for your groups.

 
 
This is what I am having an issue with, can you expand on how to do this?
 
Thanks
 
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 20 Mar 2008 at 6:40am

On the Insert menu, select "Group".  In the drop-down list in the dialog, scroll down until you see the Group1 formula, select it, set your sort order options and click on OK.  Repeat for the Group2 fomula.  Do this instead of grouping on the actual fields.

 
-Dell
IP IP Logged
merkman
Newbie
Newbie


Joined: 19 Mar 2008
Online Status: Offline
Posts: 8
Quote merkman Replybullet Posted: 20 Mar 2008 at 7:47am

 Thumbs%20Up   Clap   Cool

That did it.
It was right infront of me all that time.
 
Thanks
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.