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

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Replace part of a string with another

Hello Friends,

I have the following scenario:

T0:

LOAD * INLINE [

A, B, D

a, b, xyz

a, b, uvw

a, b, rst

]

;

T1:

LOAD * INLINE [

A, B, C

a, b, abcdefg

a, b, abhijk

a, b, ablmno

]

;

I would like to replace dynamically in T1 with the values from T0 based on the couple A|B

My Output would look like:

T2:

LOAD * INLINE [

A,B,C

a, b, xyzcdefg

a, b, xyzhijk

a, b, xyzlmno

a, b, uvwcdefg

a, b, uvwhijk

a, b, uvwlmno

a, b, rstcdefg

a, b, rsthijk

a, b, rstlmno

]

;

I feel the answer to be simple, my brain is slightly tired

Thanks for your help,


Antoine

1 Solution

Accepted Solutions
Not applicable
Author

I didn't noticed that one. Please find the below:

T1:

LOAD A, B, C , A&B AS AB

INLINE [

A, B, C

a, b, abcdefg

a, b, abhijk

a, b, ablmno

]

;

Left Join

LOAD A&B AS AB, D INLINE [

A, B, D

a, b, xyz

a, b, uvw

a, b, rst

];

T2:

NoConcatenate

LOAD *, Replace(C,AB,D) AS NEW_C

Resident T1;

DROP Table T1;

View solution in original post

4 Replies
Not applicable
Author

Try MapSubString function like below:

MAP_SS:

MAPPING

LOAD A&B AS AB, D INLINE [

A, B, D

a, b, xyz

a, b, uvw

a, b, rst

]

;

T1:

LOAD A, B, C , MapSubString('MAP_SS',C) AS NEW_C INLINE [

A, B, C

a, b, abcdefg

a, b, abhijk

a, b, ablmno

]

;

Anonymous
Not applicable
Author

Thanks

If you notice, it gives only the first mapped field.

I need it to iterate for all combinations. Any idea how to ?


Not applicable
Author

I didn't noticed that one. Please find the below:

T1:

LOAD A, B, C , A&B AS AB

INLINE [

A, B, C

a, b, abcdefg

a, b, abhijk

a, b, ablmno

]

;

Left Join

LOAD A&B AS AB, D INLINE [

A, B, D

a, b, xyz

a, b, uvw

a, b, rst

];

T2:

NoConcatenate

LOAD *, Replace(C,AB,D) AS NEW_C

Resident T1;

DROP Table T1;

Anonymous
Not applicable
Author

Magic!

Thanks Dathu