Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
gerhardl
Creator II
Creator II

Map Using

Hi,

I'm trying to replace all instance of the word "JJ" or "Jay Jays" with the word "Refinery" in my module. But these will not be the full field values, so the store name for instance may be "JJ - Cape Town" which I then want to change to "Refinery - Cape Town".

These are on multiple fields so I do NOT want to use the REPLACE function, I want to use the "MAP USING" function.

For some reason it's not working, and I think maybe because I need wildcard characters since I'm only replacing PART of the field values.

Currently I have the following:

RefineryMap:

Mapping LOAD

*

INLINE [

MapString, MapValue

JJ, Refinery];

MAP * using RefineryMap;

Data:

LOAD

*normal load script*

12 Replies
tresesco
MVP
MVP

MapSubString() - is the function that could help you here.

gerhardl
Creator II
Creator II
Author

Sorry, but where exactly?

Like this?

RefineryMap:

Mapping LOAD

*

INLINE [

MapString, MapValue

JJ, Refinery];

MapSubString * using RefineryMap;

Data:

LOAD

*normal load script*

sunilkumarqv
Specialist II
Specialist II

tresesco
MVP
MVP

Well, I see (carefully) your point now. Yes that way it doesn't work. If individual field mapping would be an option, then you could use that function.

tamilarasu
Champion
Champion

From help file.

Capture.PNG

tresesco
MVP
MVP

You could probably run a loop and use the MapSubstring() function as an alternative.

tamilarasu
Champion
Champion

Something Like below

Map1: 

Mapping load * inline [

x, y

1, one

2, Two

3, Three ] ;

Data:

LOAD [Employee #], 

    MapSubstring ('map1', [Employee #]) as NewEmployeeID

FROM

Book1.xlsx

(ooxml, embedded labels, table is Sheet1);

gerhardl
Creator II
Creator II
Author

Thanks, but as mentioned, I do not want to do this on every single field that may contain JJ - which is why I want to make use of the MAP...USING statement.

I just need to figure out how to use a wildcard in that function, something like this,

RefineryMap:

Mapping LOAD

*

INLINE [

MapString, MapValue

JJ, Refinery];

MAP '*Field1*', '*Field2*', '*Field3*' using RefineryMap;

Data:

LOAD

*normal load script*

jonathandienst
Partner - Champion III
Partner - Champion III

Your script with mapsubstring would be something like:

RefineryMap:

Mapping LOAD

*

INLINE [

MapString, MapValue

JJ, Refinery];

Data:

LOAD

  MapSubString('RefineryMap', Code) As Refinary,

  *normal load script*

Mapsubstring works like Applymap, except that it looks inside the string ("Code" in the example above) and replaces the substring.

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein