Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Ascending Order Split?? Post Reply Post New Topic
Author Message
whowe
Newbie
Newbie


Joined: 17 Mar 2010
Online Status: Offline
Posts: 2
Quote whowe Replybullet Topic: Ascending Order Split??
    Posted: 17 Mar 2010 at 9:39am
Hello everyone!  I have been using Crystal for a while, but today ran into something I have never been asked to do.  I was asked to sort a report ascending by name.  That isn't the part that is getting me, the database I am pulling from only has a NAME table that stores the whole name like such:  Bob Villa.

I need to sort the report from this column, but I don't want to do it by the first name, I want to sort by the last name.  That is my problem, how when the table is spitting out Bob Villa for name in 1 field, can I specify the sort by the last name?  Any help is greatly appreciated!
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 17 Mar 2010 at 10:30am

There are a couple of ways of looking at it.  One if the the NAME field is just a first name and a last name.  Then you could use instr to find the space, then use the left and right functions to reorder the name.  If the name is more complicated (two first name, first name - middle) then you should be able to use instr again, but in a loop where you basically trim off everything but the last name.  It would take some programming skill for the second one.

Of course if someone else has something simpler, let us know.
IP IP Logged
whowe
Newbie
Newbie


Joined: 17 Mar 2010
Online Status: Offline
Posts: 2
Quote whowe Replybullet Posted: 17 Mar 2010 at 10:35am
I have never had to use custom programming in my crystal reports, as everything has usually been stock.  How/where would I do the first solution you spoke of?  Thank you again for all of your help.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 17 Mar 2010 at 11:14am
You can create a new formula and use this:

Mid ({table.namefield}, InStr ({table.namefield}, " " )+1)


and then sort on this formula. As Kevlray said, this is fine as long as all the names are formatted exactly the same (but unfortunately this is rarely the case).


Edited by BrianBischof - 17 Mar 2010 at 11:20am
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
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.048 seconds.