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: 
Not applicable

ApplyMap

Hello All,

     Help me with ApplyMap, What is it ? how can we use it ? and why to use it? demo app would be great.

1 Solution
9 Replies
Not applicable
Author

The ApplyMap function is used for mapping any expression to a previously loaded mapping table. The syntax is:

applymap('mapname', expr [ , defaultexpr ] )

where:

mapname is the name of a mapping table that has previously been created through the mapping load or the mapping select statement (see Mapping). Its name must be enclosed by single, straight Quotation Marks in Scripting.

expr is the expression, the result of which should be mapped.

defaultexpr is an optional expression which will be used as a default mapping value if the mapping table does not contain a matching value for expr. If no default value is given, the value of expr will be returned as is.

Examples:

// 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'

Not applicable
Author

thanks felim ,but i am not getting actual use of it ,possibly provide with more example

sudeepkm
Specialist III
Specialist III

Please take a look at the example attached and please refer to the comments added in the script.

Not applicable
Author

Hi Rohit,

Mapping load works like a function/method in progrmming, first column acts as "input parameter" while second column acts as "return value". In below mapping load "x" acts as "input parameter" while "y" acts as "return value". if input value (x ) not found in table it returns same or third parameter of ApplyMap. ApplyMap is used to call mapping load and its syntax is applymap('mapname', expr  [,  defaultexpr ] ). After reload mapping load is not the part of data model.

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, 0 ) returns 0

Not applicable
Author

Sudeep i coudnt find the attached file

Not applicable
Author

Thank you HIC

sudeepkm
Specialist III
Specialist III

I'm attaching it again.