cancel
Showing results for 
Search instead for 
Did you mean: 

SPLIT Array Formula

Former Member
0 Kudos

In my data I have a field that holds three pieces of info seperated by a comma.

Im using SPLIT to split them out and that works just fine.

In this example the piece of data that I'm pulling out could be one of four things. Part [3] of my array in the code below could return:

In the host city

Under 50km

50-100km

Above 100km

I'm trying to have Crystal return either 'In the City' or 'Outside the city'. So if [3] = "In the city", then I want it to print "In the city". Otherwise I need the value to be "Outside the city".

Below is my chicken scratch formula that doesnt work, if someone could point out my failings and how to correct them I would be most appreciative.

Local stringvar x:= SPLIT ({TABLE.DATA}, ", ") [3]
If x = "In The Host City"
Then "In The City"
Else "Outside The City"

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

Try the following :

stringvar x:='This is my ciry';

if InStr(x,'This is my') = 1 then

"Inside city"

else "Outside City"

Thanks,

Sastry

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks a lot for the feedback guys.

After your pointers I eventually went with the below and the results are spot on.


stringvar x:= SPLIT ({DATA.TABLE}, ", ") [3];

if InStr(x,'In The Host City') = 1 
then "Inside The City"
else "Outside The City"

former_member292966
Active Contributor
0 Kudos

Hi,

Remember the string is case-sensitive so if there is a possibility of the string in a strange format also try using the Uppercase function before comparing.

The InStr as mentioned would also be a good idea. There could be spaces, etc.

Good luck,

Brian