Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: I need a Formula Post Reply Post New Topic
Author Message
skreczko
Newbie
Newbie


Joined: 18 Oct 2010
Online Status: Offline
Posts: 7
Quote skreczko Replybullet Topic: I need a Formula
     Posted: 22 Feb 2011 at 4:00am

MEMBER_NBR=3333333|LOAN_NBR=168

MEMBER_NBR=33333|LOAN_NBR=169

MEMBER_NBR=3333|LOAN_NBR=169

MEMBER_NBR=333|LOAN_NBR=169

MEMBER_NBR=33|LOAN_NBR=169

MEMBER_NBR=3|LOAN_NBR=169

 

 

Hello Crystal Report Gods,

 

I just need to get the member number separated from this string. Does anyone know how to get the  3’s  from this sample data. Also, I need to convert it to a number format.

 

thanks

 

 

IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 22 Feb 2011 at 4:18am
There are several ways to do it, some of which are dependent on the input (easier) and some are in general (harder ones).

For instance, if all of your data is structured so that you have

MEMBER_NBR=(some numbers)|(other stuff)


Where you will always have numbers appearing after the string "MEMBER_NBR=" and ending with a pipe (|), then you can extract the numbers substring from each line by taking everything from index 12 to index of the pipe - 1 (to exclude the pipe).

My example has two formulas:

str, which holds the string ""MEMBER_NBR=333333|LOAN_NBR=168""
Display, which will display the numbers you want, as given by the following code


{@str1}[12 to InStr(9,{@str1} ,"|" ) - 1]


12 is the index of the first number

InStr(12,{@str1} ,"|" ) finds the index of the first pipe starting at index 12 of str1 (in case there may be pipes elsewhere)

If there is no pattern, then it will be harder to accomplish.


Edited by Keikoku - 22 Feb 2011 at 4:20am
IP IP Logged
skreczko
Newbie
Newbie


Joined: 18 Oct 2010
Online Status: Offline
Posts: 7
Quote skreczko Replybullet Posted: 22 Feb 2011 at 4:33am
{DATAAUDIT.KEY_REPRESENTATION}[12 to InStr(9,{DATAAUDIT.KEY_REPRESENTATION} ,"|" ) - 1]
LOLworked like a charm. Thanks again
IP IP Logged
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