Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Splitting Name field with non-standard data Post Reply Post New Topic
Author Message
jkaufman
Newbie
Newbie


Joined: 20 May 2009
Location: United States
Online Status: Offline
Posts: 7
Quote jkaufman Replybullet Topic: Splitting Name field with non-standard data
    Posted: 05 Sep 2017 at 6:50am
I have name data that needs to be split into first and last name.
However, the data in this field is not standard.
Some data just has the first name, some is standard with first name, space, last name.
Others have standard with first name, space, last name with either a "/" with no space after last name followed by other data or
a space and then further data which would not want to show this additional data.

Any suggestions on creating a formula for this?
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 05 Sep 2017 at 8:13am
Can you show some examples of the data to see if this is possible (use phony names).
IP IP Logged
jkaufman
Newbie
Newbie


Joined: 20 May 2009
Location: United States
Online Status: Offline
Posts: 7
Quote jkaufman Replybullet Posted: 05 Sep 2017 at 8:50am
sure...
Data could be like any of the following:

Jennifer
Abby Atkins
Barbara Smith/Ricardo
Lisa Bush - Peggy Olsen
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 05 Sep 2017 at 9:59am
And how would you want the data to look, especially the last two?
IP IP Logged
jkaufman
Newbie
Newbie


Joined: 20 May 2009
Location: United States
Online Status: Offline
Posts: 7
Quote jkaufman Replybullet Posted: 05 Sep 2017 at 10:02am
I would want the last two to look like

Barbara Smith
Lisa Bush

FirstName space LastName
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 06 Sep 2017 at 4:36am
I believe the following formula should work in your situation.

Be sure to use Basic Syntax in the formula editor. Replace theame with your field.

dim i as number

for i = 1 to len(name)
    if mid(name, i, 1) = "-" then
        name = left(name, i-2)
        exit for
    else
        if mid(name, i, 1) = "/" then
            name = left(name, i-1)
            exit for
        end if
    end if
next i       
formula = name
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.