Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Sorting data within a record Post Reply Post New Topic
Author Message
wjordan
Newbie
Newbie


Joined: 07 Jan 2009
Location: United States
Online Status: Offline
Posts: 2
Quote wjordan Replybullet Topic: Sorting data within a record
     Posted: 07 Jan 2009 at 10:17am
I am trying to find a way to sort the results of 12 different fields that are contained within a single record.  Each of the fields contain 1, 2 or 3 as the value. 
 
For instance I have the following fields in a record with values:
 
Family, 2
Residential, 3
Social, 1
Financial, 2
 
I'm trying to get them sorted this way on the report:
 
Residential, 3
Family, 2
Financial, 2
Social, 1
 
Anyone have any ideas?
Thanks,
Wayne Jordan
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 07 Jan 2009 at 12:10pm
You can group on that field and go into the Change Group dialog box and click on the Specified Order tab. This lets you choose the order that each record gets sorted.
 
I have the grouping and sorting options covered in detail in Chapter 3 of my Encyclopedia book. You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Jan 2009 at 6:57pm

another possible approach...

if you are trying to sort numerically descending and secondarily alpha ascending and you always have a single number at the end of the string you could create a formula field to trim the text field down to the last character, convert it to a number then sort descending on this formula field and add a secondary sort ascending on the field itself since it is alpha.
IP IP Logged
wjordan
Newbie
Newbie


Joined: 07 Jan 2009
Location: United States
Online Status: Offline
Posts: 2
Quote wjordan Replybullet Posted: 08 Jan 2009 at 5:16am
Thanks for the help, but I guess I've not explained the issue clearly. 
 
I am working with a single record on the report.  In this record there are several fields (named Family, Residential, Financial, and Social).  In these fields there are values (2, 3, 1, 2).  I am wanting to have a section on the report that will put these fields in order based on the value of the field.
Wayne Jordan
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 08 Jan 2009 at 6:31am
Since you want to transform 1 row of data into multiple rows of report detail, as long as the number of fields is constant you could probably do it in a formula.  In the formula you would need to set variables to the values you desire (the variables would be 'in order') and then you could display the variables on their own lines or one line, however you choose, but this might not work depending on what else you want the report to do.
 
That is how I would start to attack the problem, the final solution might not look like this, but it is a start.
 
Depending on what else the report needs to do, you might want to think about writing a stored procedure so that your one line of data becomes several with the desired data in its own line.
 
Hope this helps.
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