Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Highlighted
Partner
Partner

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;

View solution in original post

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

]

;

Partner
Partner

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;

View solution in original post

Partner
Partner

Re: Replace part of a string with another

Magic!

Thanks Dathu