Solved

Converting Name field into 3 Separate Fields in Crystal Reports

Posted on 2010-08-30
9
1,558 Views
Last Modified: 2012-05-10
My name field consists of one full name field, in this format: Last, First M.  I need to take this field and separate it into 3 different name fields: First Name Last Name and Middle Initial.  How do I do this in Crystal Reports V. 11?  Thanks for your time.
Regards
0
Comment
Question by:carolannp
  • 4
  • 4
9 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Try this

LastName formula
Split({YourNameField},",")[1]

FirstName Formula
Split(Split({YourNameField},",")[2])[1]

MiddleName Formula
Split(Split({YourNameField},",")[2])[2]

mlmcc

0
 
LVL 19

Expert Comment

by:GJParker
Comment Utility
If the format you have shown is consistent then you can simply split the fields at the space i.e.

//@Lastname
Split({Table.Field}, ' ')[1]

//@FirstName
Split({Table.Field}, ' ')[2]

//@Initial
Split({Table.Field}, ' ')[3]

HTH
0
 

Author Comment

by:carolannp
Comment Utility
If I try either above options to get the correct middle initial I get the following error when I actually run the report:
A subscript must be between 1 and the size of the array.  Thanks.
0
 
LVL 19

Expert Comment

by:GJParker
Comment Utility
I take it you must have instances where no middle initial exists.

Try this for your initial formula
If Count(Split({Table.Field}, ' ')) >= 3 Then
      Split({Table.Field}, ' ')[3]
Else
      ''
it's probablu also a good idea to add the same test to the other 2 formulas as well, remembering to change teh test to >= 1 and >= 2

HTH
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Author Comment

by:carolannp
Comment Utility
Yes, you are correct in that some names don't have an initial, but your above example still isn't giving me the middle initial.  Example of names: Smith,John T.  There is a comma after Smith and a space after John.  Does this help?  Thanks.
0
 
LVL 19

Accepted Solution

by:
GJParker earned 250 total points
Comment Utility
Try these :

//@FirstName
If Count(Split({Table.Field}, ',')) >= 1 Then
      Split({Table.Field}, ',')[1]
Else
      ''

//@LastName
If Count(Split({Table.Field}, ',')) >= 2 Then
      Split(Split({Table.Field}, ',')[2], ' ')[1]
Else
      ''

//@Initial
If Count(Split({Table.Field}, ' ')) >= 2 Then
      Split({Table.Field}, ' ')[2]
Else
      ''
0
 

Author Comment

by:carolannp
Comment Utility
Still not quite right:
The above //@LastName and //@FirstName should be switched around.  I am getting the correct middle initial and the LastName, but the FirstName is containing the middle initial.
//@LastName
If Count(Split({staff_current_demographics.name},','))>=1 then
Split({staff_current_demographics.name},',')[1]
else
''
@FirstName
If Count(Split({staff_current_demographics.name},','))>=2 then
Split(Split({staff_current_demographics.name},',')[2],'')[1]
else
''
@Initial
if Count(Split({staff_current_demographics.name},' '))>=2 then
Split({staff_current_demographics.name}," ")[2]
else
''
Example FirstName: John T
Thanks.
0
 
LVL 19

Assisted Solution

by:GJParker
GJParker earned 250 total points
Comment Utility
You misse dth espace out on the second line, where I have put the % sign should be a space

@FirstName
If Count(Split({staff_current_demographics.name},','))>=2 then
Split(Split({staff_current_demographics.name},',')[2],'%')[1]
else
''
0
 

Author Comment

by:carolannp
Comment Utility
@FirstName I changed to:
If Count(Split({staff_current_demographics.name},','))>=2then
Split(Split({staff_current_demographics.name},",")[2])[1]
else
''
This works now.  All names are now separated correctly.  Thanks for your time.  I will close out this request.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now