Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Searching for a specific string

Hi All,

I have a question regarding searching for a specific string.

Lets say I have data:

table1:

KEYCODE
ABCAB
DEFDE
XYZXY

table2:

KEYFIELD1
ABCG-H-G-H-G-A-B-AB-ABC
DEFAB-AB-DE-EF
XYZABC-XY-QYZ

In Key ABC, I have to find the CODE (AB) in FIELD1 (G-H-G-H-G-A-B-AB-ABC).

How do I do this?

Thanks,

Lyn

Tags (2)
1 Solution

Accepted Solutions
sudeepkm
Valued Contributor III

Re: Searching for a specific string

you can use like below. Please find the attachment.

if(SubStringCount(FIELD1,CODE)>0,'PRESENT','ABSENT') as CODEFLAG

T119445.png

5 Replies
rupe
Valued Contributor

Re: Searching for a specific string

How about:

FindOneOf(text , characterset [ , n])

so in your example,

FindOneOf('AB', FIELD1)

if zero is returned it cannot find it.

Re: Searching for a specific string

Try this code

TMP:

NoConcatenate

Load * resident Table1;

join

Load * resident Table2;

TABLE:

LOAD *, If(WildMatch(CODE, FIELD1) > 0, 'OK', 'NO') as is_in_field Resident TMP;

DROP Table TMP;

Not applicable

Re: Searching for a specific string

And how should your result look like? You need to show starting position of this CODE in FIELD1?

sudeepkm
Valued Contributor III

Re: Searching for a specific string

you can use like below. Please find the attachment.

if(SubStringCount(FIELD1,CODE)>0,'PRESENT','ABSENT') as CODEFLAG

T119445.png

Not applicable

Re: Searching for a specific string

Hi,

thanks this is what I'm looking for. My other question is, what if field1 contains ACB instead of ABC, how can I fix it in alphabetical order?

Thanks,

Lyn

Community Browser