Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

ApplyMap

The following is directly from the HELP MENU of Qlikview:

// Assume the following mapping table:

map1:

mapping load * inline [

x, y

1, one

2, two

3, three ] ;

ApplyMap ( 'map1', 2 )

 

returns

 

' two'

 

ApplyMap ( 'map1', 4 )

 

returns

 

4

 

ApplyMap ( 'map1', 5, 'xxx' )

 

returns

 

'xxx'

 

ApplyMap ( 'map1', 1, 'xxx' )

 

returns

 

'one'

 

ApplyMap ( 'map1', 5, null( ) )

 

returns

 

NULL

 

ApplyMap ( 'map1', 3, null( ) )

 

returns

 

'three'

 

WHY does the following return as 'xxx', or why does not return as NULL?

ApplyMap ( 'map1', 5, 'xxx' )

 

returns

 

'xxx'

 

Why does each of the ApplyMap only return a single value, such as the following? Will it always return the first value it reads or recognizes?

ApplyMap ( 'map1', 1, 'xxx' )

 

returns

 

'one'

 
1 Solution

Accepted Solutions
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     I just told default value as example.

     ApplyMap Syntax is

     ApplyMap(MapptableName,value to look up in table[,value if not match])

You have to specify the value here in the optional parameter(Bold part) it returns the optional value if there is no match.If not specified then it consider as null value so it returns null if no match found.

Example:

     ApplyMap ( 'map1', 5, 'xxx' ) returns 'xxx'

     ApplyMap ( 'map1', 5) returns NULL

     ApplyMap ( 'map1', 1, 'xxx' ) returns 'one'

     ApplyMap ( 'map1', 1 ) also returns 'one'

View solution in original post

6 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     1.ApplyMap ( 'map1', 5, 'xxx' ) returns 'xxx' only because you don't have the value 5 in the map1 mapping table.if you wrote the expression as ApplyMap ( 'map1', 5) then it returns null.

     2. Yes.It returns single value only.It look for the given value 1 in field x of the mapping table if matched then it returns the corresponding y field value.if not found it looks for the next parameter in applymap('map1',1,'xxx') (the bold one) which is optional.If you specified it returns the given value otherwise returns null.

Celambarasan

Anonymous
Not applicable
Author

'xxx' doesn't exist in the mapping table either, so why does it return instead of NULL?

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     Third parameter is not to look up in mapping table its to display if there is no match then return this value instead of null.Its like default value.

Celambarasan

Anonymous
Not applicable
Author

Will the default value be specified previously in the script? If not, where does it come from? How does the program recognize it as the default value?

can the default value be a numerical value (eg 8), or is it always a text value (eg (xzy) (abc)?

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     I just told default value as example.

     ApplyMap Syntax is

     ApplyMap(MapptableName,value to look up in table[,value if not match])

You have to specify the value here in the optional parameter(Bold part) it returns the optional value if there is no match.If not specified then it consider as null value so it returns null if no match found.

Example:

     ApplyMap ( 'map1', 5, 'xxx' ) returns 'xxx'

     ApplyMap ( 'map1', 5) returns NULL

     ApplyMap ( 'map1', 1, 'xxx' ) returns 'one'

     ApplyMap ( 'map1', 1 ) also returns 'one'

Anonymous
Not applicable
Author

Got it, Thanks so much for your help