Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
SunilChauhan
Champion II
Champion II

Want to comapare two string

I have two table

Name, flag

Neil T,1

Tom k,1

and

SName

Tom k wahis

Neil T

Neil T  katt

Tom k

now i want to compare and write flag value infront of sName.

if full string match or substring match .then i want  below


SName,Flag

Tom k wahis,1

Neil T,1

Neil T  katt,1

Tom k,1

ex: Neil T and substring of Neil T  katt in field Sname is matching with Neil T in Name.

hence the flag infront of Neil T in Name should assign to

Neil T

Neil T  katt

this is what i required.


Sunil Chauhan
1 Solution

Accepted Solutions
rbecher
MVP
MVP

Hi,

you could do this with MapSubstring() to build a lookup with substring matching (even if it looks a bit strange in code):

T1:

LOAD * INLINE [

    Name, flag

    Neil T, 1

    Tom k, 1

    Neil U, 2

    Tom l, 3

];

// added some more test cases:

T2:

NOCONCATENATE LOAD * INLINE [

    Name

    Tom k wahis

    Neil T

    Neil T  katt

    Tom k

    Neil U fre

    Tom l xy

    Neil V

    Tom m

];

MapName:

Mapping LOAD '#' & Name, flag & ';' Resident T1; // # = only match from left

SName:

NOCONCATENATE LOAD Name, if(left(flag,1)='#', Null(), flag) as flag;

LOAD Name, SubField(MapSubString('MapName', '#' & Name), ';', 1) as flag

Resident T2;

Drop Tables T1, T2;

- Ralf

Astrato.io Head of R&D

View solution in original post

2 Replies
rbecher
MVP
MVP

Hi,

you could do this with MapSubstring() to build a lookup with substring matching (even if it looks a bit strange in code):

T1:

LOAD * INLINE [

    Name, flag

    Neil T, 1

    Tom k, 1

    Neil U, 2

    Tom l, 3

];

// added some more test cases:

T2:

NOCONCATENATE LOAD * INLINE [

    Name

    Tom k wahis

    Neil T

    Neil T  katt

    Tom k

    Neil U fre

    Tom l xy

    Neil V

    Tom m

];

MapName:

Mapping LOAD '#' & Name, flag & ';' Resident T1; // # = only match from left

SName:

NOCONCATENATE LOAD Name, if(left(flag,1)='#', Null(), flag) as flag;

LOAD Name, SubField(MapSubString('MapName', '#' & Name), ';', 1) as flag

Resident T2;

Drop Tables T1, T2;

- Ralf

Astrato.io Head of R&D
SunilChauhan
Champion II
Champion II
Author

I salute your idea man

Sunil Chauhan