6 Replies Latest reply: Feb 22, 2012 3:01 AM by chris goudy RSS

    ApplyMap

    chris goudy

      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'

       
        • ApplyMap
          Celambarasan Adhimulam

          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

            • ApplyMap
              chris goudy

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

                • Re: ApplyMap
                  Celambarasan Adhimulam

                  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

                    • ApplyMap
                      chris goudy

                      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)?

                        • ApplyMap
                          Celambarasan Adhimulam

                          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'