Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Check if field1 matches with field2 in Load script.

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

Field1Field2ResultHeader 4
Y92.22
'Y92.23','Y92.24'
Match
W00.1
'W0*','W1*'
Match
S06.2
'W0*','W1*'
Not Match
X89.3X89.5Not Match
Y97.8Y97.8Match
W19.6
'W0*','W1*'
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

1 Solution

Accepted Solutions
antoniotiman
Master III
Master III

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

View solution in original post

5 Replies
Anil_Babu_Samineni

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.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Not applicable
Author

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.

balar025
Creator III
Creator III

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

antoniotiman
Master III
Master III

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

Not applicable
Author

Hi Antonio,

Your solution works.

Thanks a lot.

Regards

Krish