0

# Extract a specific data from a string in Crystal Reports

Dec 05, 2017 at 11:17 PM

72

Former Member

Suppose the data is in this format

----------------------------

Variable 7.5% codes

Temporary 10.5% codes

codes 58.5%

10%

20%

----------------------------

How to extract numeric part from the string like

7.5

10.5

58.5

10

20

Brian Dong Dec 12, 2017 at 07:30 PM
0

Hi Tanmay,

I guess you didn't see my solution in your comment:

Hi Tanmay,

Change your formula to check if the result is a number like:

```stringvar myText := {YourTable.YourStringColumn};
stringVar Array myResultArray := Split(Split(myText, "%")[1], " ");

If NumericText (myResultArray[UBound(myResultArray)]) Then
myResultArray[UBound(myResultArray)]
Else "-";```

This will display a "-" if there are no numbers to extract.

Brian

Share
Brian Dong Dec 06, 2017 at 07:00 PM
1

Hi Tanmay,

Change your formula to check if the result is a number like:

```stringvar myText := {YourTable.YourStringColumn};
stringVar Array myResultArray := Split(Split(myText, "%")[1], " ");

If NumericText (myResultArray[UBound(myResultArray)]) Then
myResultArray[UBound(myResultArray)]
Else "-";```

This will display a "-" if there are no numbers to extract.

Brian

Share
Ido Millet Dec 06, 2017 at 03:03 AM
0

stringvar myText := {YourTable.YourStringColumn};
stringVar Array myResultArray := Split(Split(myText, "%")[1], " ");
myResultArray[UBound(myResultArray)];

Share
Former Member Dec 12, 2017 at 11:15 AM
0

Hi Millet,

Thanks it worked but somehow

my data also include only the string like

------------------------

Not Eligible - temp

Eligible - Temp

Variable %

Private based

--------------------------

Note like the line Variable % contains no numbers so the output for this rows should be '-'

right now it's outputting the

-------------

Temp
temp

based

--------------

Share
Former Member Dec 06, 2017 at 04:29 PM
0

Hi Millet,

Thanks it worked but somehow

my data also include only the string like

------------------------

Not Eligible - temp

Eligible - Temp

Variable %

Private based

--------------------------

Note like the line Variable % contains no numbers so the output for this rows should be '-'

right now it's outputting the

-------------

Temp
temp

based

--------------

Share
Former Member Dec 14, 2017 at 09:20 AM
0
Share