Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi ,
I have data as below and am trying to use wildmatch function to check is field1 matches with field2. But, I am unable to get the result.
The Data and the result that I want is as
Field1 | Field2 | Result | Header 4 | |
---|---|---|---|---|
Y92.22 |
| Match | ||
W00.1 |
| Match | ||
S06.2 |
| Not Match | ||
X89.3 | X89.5 | Not Match | ||
Y97.8 | Y97.8 | Match | ||
W19.6 |
| Match |
I am using the below in the Load script
Temp:
Load
Field1,
Field2,
if(wildmatch(Field1,Field2) > 0 ,'Match','Not Match') as Result
from file1;
The wildmatch does not seem to work in the script and returns 'Not Match' for all rows.
I also tried Wildmatch(Field1,$(=Field2)) and this gives an error.
How can I get the desired result?Let me know if you need more info on this.
Thanks
Krish
Hi Krishnan,
Table:
LOAD *,WildMatch(Field1,PurgeChar(NField2,Chr(39))) as W;
LOAD *,PurgeChar(SubField(Field2,','),Chr(39)) as NField2;
LOAD * Inline [
Field1;Field2
Y92.22;"'Y92.23','Y92.24'"
W00.1;"'W0*','W1*'"
S06.2;"'W0*','W1*'"
X89.3; X89.5
Y97.8; Y97.8
W19.6;"'W0*','W1*'"
](delimiter is ';');
LOAD Field1,Only(Field2) as Field2,If(Max(W) > 0,'Match','Not Match') as Result
Resident Table
Group By Field1;
Drop Table Table;
Regards,
Antonio
From Field2 you have 2 strings by delimiter. Which one we need to consider from Field1. I know this is complex but you have to provide proper logic which is behind.
I want to check like below :-
row1 - wildmatch('y92.22','y92.23','y92.24') - Not match as y92.22 is not in field1
row2 - wildmatch('w00.1','w0*','W1*') - is Match as it is a wildcard search
Wildmatch(field1,field2) does not seem to work for the above case.
hope that clarifies.
Hi Krishnan,
You have to go for loop and compare those row by row using for loop.
Because your can't use field2 as wildmatch second input.
Regards,
Ravi
Hi Krishnan,
Table:
LOAD *,WildMatch(Field1,PurgeChar(NField2,Chr(39))) as W;
LOAD *,PurgeChar(SubField(Field2,','),Chr(39)) as NField2;
LOAD * Inline [
Field1;Field2
Y92.22;"'Y92.23','Y92.24'"
W00.1;"'W0*','W1*'"
S06.2;"'W0*','W1*'"
X89.3; X89.5
Y97.8; Y97.8
W19.6;"'W0*','W1*'"
](delimiter is ';');
LOAD Field1,Only(Field2) as Field2,If(Max(W) > 0,'Match','Not Match') as Result
Resident Table
Group By Field1;
Drop Table Table;
Regards,
Antonio
Hi Antonio,
Your solution works.
Thanks a lot.
Regards
Krish