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

x
?
Solved

Parsing multi-valued fields in Crystal Reports

Posted on 2008-10-14
5
Medium Priority
?
587 Views
Last Modified: 2012-06-21
I am pulling a multi-valued text string into Crystal Reports from a sql database.  The field is a comment field in which multiple values are entered into sql.  They are then stored in sql as a single text field, separated by: ý.
ie - teowtýCE.PHARM.TECH
I would like to take the text in this single Crystal Reports field and parse it out into two or more columns.
Column 1 = teowt
Column 2 = PHARM.TECH
Is there a way to do this in Crystal, or do I need to accomplish this via a SP on the SQL side?  I am not a promgrammer by any means, so dumb it down for me please !
Any help would be greatly appreciated.
0
Comment
Question by:cccpdavis
[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
  • 3
  • 2
5 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 22712953
Yes, use the SPLIT function

Add a formula
WhilePrintingRecords;
Global StringVar Array CommentPieces;

CommentPieces := Split({YourField},'ý');
''

You can then use formulas to display each value
WhilePrintingRecords;
Global StringVar Array CommentPieces;

CommentPieces[1]

mlmcc
0
 

Author Comment

by:cccpdavis
ID: 22715347
First off, thanks for the response.
I attempted to run this process in Crystal and it throws errors relating to returning array values.  Right clicked on the field in the report and selected Format Field, then selected the formula icon next to the Display String details.  Not sure if I was executing that incorrectly or not.  
I then went into sql and executed the following:
Declare @SEC_COMMENTS    VARCHAR(100)
SET @SEC_COMMENTS = 'blahýblah'

SELECT SUBSTRING(@SEC_COMMENTS,1, NULLIF(CHARINDEX('ý', @SEC_COMMENTS) - 1, -1)) AS [COMMENT1],
         SUBSTRING(@SEC_COMMENTS, CHARINDEX('ý', @SEC_COMMENTS) +1, LEN(@SEC_COMMENTS)) AS [COMMENT2]

and it returns the text string that I specified in the correct format ('blahýblah'), but I cant figure out how to apply it to an actual data field to use in a query. Would I use this formula to create a stored procedure from which to generate a subset of data, or pass it directly in the query?  I am very new to all this (sql training coming in Feb) so now I am just trying to muddle through it on my own.  Thanks for any and all input.
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 1000 total points
ID: 22715373
No.

In the Field Explorer
Right Click FORMULAS
Click NEW
Give it a NAME
Add the code
SAVE AND CLOSE

Use it like any other field from the database

mlmcc
0
 

Author Closing Comment

by:cccpdavis
ID: 31505942
Thanks a lot.
0
 

Author Comment

by:cccpdavis
ID: 22723986
Thanks a lot!  This worked great.  I figured out that the formula was one column, then I needed as many print columns as there were going to be delimiters.
Field 1 - WhilePrintingRecords;
Global StringVar Array CommentPieces;

CommentPieces := Split({YourField},'ý');
''

Field 2, etc........ -
WhilePrintingRecords;
Global StringVar Array CommentPieces;

CommentPieces[1]
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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 …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

670 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