Solved

Split function in Crystal Reports

Posted on 2014-01-09
5
10,681 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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
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 …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

626 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