Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
ivan_will
Partner - Creator II
Partner - Creator II

Replace strings in script - not working with Fields?!

Hi,

I want to replace the words in the following string with numbers.

Totaling = 'CASH_CARRY|HORECA|KIOSK|OTHER|TRADITION'

Code = CASH_CARRY, HORECA, .....

applymap gives the corresponding numbers for the Code

So I am using

Replace(Totaling,Code,ApplyMap('MAP_Codes', Code)) as ....

but without any success.

any ideas?

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

I'd use a SubStringMap() function along with the MAPPING LOAD you are already using, so:

NumericCodesMap:

MAPPING LOAD Code, Num INLINE [

Code, Num

CASH_CARRY, 1

HORECA, 2

KIOSK, 3

OTHER, 4

TRADITION, 5

];

Data:

LOAD MapSubString('NumericCodesMap', 'CASH_CARRY|HORECA|KIOSK|OTHER|TRADITION') AS Edit

AUTOGENERATE 1;

Hope that helps.

Miguel

View solution in original post

2 Replies
Miguel_Angel_Baeyens

Hi,

I'd use a SubStringMap() function along with the MAPPING LOAD you are already using, so:

NumericCodesMap:

MAPPING LOAD Code, Num INLINE [

Code, Num

CASH_CARRY, 1

HORECA, 2

KIOSK, 3

OTHER, 4

TRADITION, 5

];

Data:

LOAD MapSubString('NumericCodesMap', 'CASH_CARRY|HORECA|KIOSK|OTHER|TRADITION') AS Edit

AUTOGENERATE 1;

Hope that helps.

Miguel

Not applicable

You may also try

LOAD



concat(distinct CorrespondingNumbers,'|',index(Totaling,Code)) as TotalingReplacedWithNumbers

RESIDENT YourTable GROUP BY 1;