Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Split function in Crystal Reports

Posted on 2014-01-09
5
Medium Priority
?
10,993 Views
Last Modified: 2014-01-20
Hi,

I have a field that holds a string of data separated by a semi-colon ';'.  I need to split this string between 1 and 5 fields.  Once the string is split I will need to show each field that contains data in the report.  

Example of the strings:

Accelerations; Early
Accelerations; Early; Late
Accelerations; Early; Late; Recurrent
Early; Late; Variable; Recurrent

I want to display the split fields as:  
Field 1                                   Field 2                      Field 3                 Field 4
Accelerations                       Early                        
Accelerations                       Early                         Late                      
Accelerations                       Early                         Late                     Recurrent
Early                                      Late                          Variable              Recurrent
0
Comment
Question by:jul_to_cool
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 18

Expert Comment

by:vasto
ID: 39768711
What is your database ?
The best way to handle this is on database side.
Here is an example hot to do this with SQLServer
http://www.codeproject.com/Questions/400165/how-to-split-in-sql-server

You may also use SQLExpressions to get each part of the string
0
 

Author Comment

by:jul_to_cool
ID: 39768772
I'm using Crystal Reports 2008.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 39769753
You can use SPLIT to separate them into an array

HOw many might there be?

Formulas to do this
Formula1 - Name - DispField1
WhilePrintingRecords;
Global StringVar Array myStrings;

myStrings:= Split({YourField},';');
If UBound(myStrings) >= 1 then
     myStrings[1]

Open in new window


One formula for each string - Just change the 2 to 3, 4, 5, etc

Formula2 - Name - DispField2
WhilePrintingRecords;
Global StringVar Array myStrings;

If UBound(myStrings) >= 2 then
     myStrings[2]

Open in new window


mlmcc
0
 
LVL 35

Expert Comment

by:James0628
ID: 39770670
If you use formulas like the ones that mlmcc posted, you would also want to add the following line to the beginning of every formula except the first one:

 EvaluateAfter ({@DispField1});

 That's to make sure that each of the other formulas is evaluated after DispField1, because it sets the myStrings variable, and the other formulas get their values from myStrings.

 James
0
 

Author Closing Comment

by:jul_to_cool
ID: 39794742
Thanks guys!!!
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

722 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