Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

eruditio
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

Re: Replace part of a string with another

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;

4 Replies
Not applicable

Re: Replace part of a string with another

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

]

;

eruditio
Not applicable

Re: Replace part of a string with another

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

Re: Replace part of a string with another

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;

eruditio
Not applicable

Re: Replace part of a string with another

Magic!

Thanks Dathu