Crystal formula to string Values comparasion

Hi

Can someone advice me for below formula in crystal.

trying to match values of string values from one field 1 in other field 2 and flag as match if any string matches.

for example :

[field 1 --------- field 2 ----------- flag
abc, a, b -------- abc, bcd --------Match
k, s ------------- n ----------- no match
p, n, a ---------- a, n -----------Match

crystal reports version 11

Thanks


Murthy118 (BOB member since 2016-01-26)

I might try something like this in a formula:

StringVar Array field1 := split ({Mytable.Field1}, ‘,’);
StringVar Array field2 := split({Mytable.Field2}, ‘,’);
StringVar result = ‘No Match’;
NumberVar i;

For i := 1 to ubound(field1) Do
(
if field1[i] in field2 then (
result := ‘Match’;
Exit For;
)
)
result;

This will turn fields 1 and 2 into arrays based on where the commas are. It will then walk through each of the items in the array from field 1 to see if they’re in the field 2 array.

-Dell


hilfy :us: (BOB member since 2007-04-16)

Thanks for your inputs. I have solved with below formula

StringVar Array field2 := split(name of field), ‘,’);
stringVar field1 := {name of field};
NumberVar i;
i := 1 ;

if instr(field1,field2[i]) > 0 then ‘Match’ else ‘No match’ ;

Thanks


Murthy118 (BOB member since 2016-01-26)