ApplyMap is a lookup or mapping function in QlikView. This function takes one value as input and checks if that value exists in a mapping table and returns the corresponding values from the second column of the mapping table, if the value doesn’t exists it out puts the ‘Default value’.

Syntax of Applymap in QlikView:

Applymap (‘Mapping Table Name’,Mapping_Column,’Default value’).


In QlikView it is mandatory that the mapping table should have only two columns.


In HANA Graphical views we can implement this functionality by using ‘Outer Join’.


For this example we will take two tables Sales table (TBL_SALES) & ‘Customer table’ (MAP_TBL_CUSTOMER this will be our mapping table). In ‘MAP_TBL_CUSTOMER’ table all the information about the customer is stored, for this example we will take CUSTOMER_ID and CUSTOMER_NAME. In ‘TBL_SALES’ table we are having all the sales related details except in CUSTOMER_NAME column we don’t have data. Now we will see how to fill the CUSTOMER_NAME column in sales table based on CUSTOMER_ID using customer table as mapping table.


Sales data:

TBL_SALES

Note here customer name column wont have any data.

/wp-content/uploads/2015/09/image001_788797.png

Customer data:

MAP_TBL_CUSTOMER

/wp-content/uploads/2015/09/image003_788908.png

Step 1:

              Create a Graphical  view  (for this example Attribute view)and add both the sales and customer tables (TBL_SALES &                                      MAP_TABL_CUSTOMER) to the Data Foundation.

/wp-content/uploads/2015/09/image004_788907.png

Step2:

             Now create a join between  ‘TBL_SALES’ & MAP_TABL_CUSTOMER’ using CUSTOMER_ID attribute ,with Join type as ‘Left Outer ‘ .

             Then select the CUSTOMER_NAME field from the Right table ‘MAP_TBL_CUSTOMER’.

/wp-content/uploads/2015/09/image005_788909.png

Step3:

             Validate & Activate the view , do a data preview and you will find CUSTOMER_NAME column filed with data.

/wp-content/uploads/2015/09/image006_788910.png

Step4 (Optional):                              

                                 If you want to replace the  null values with some ‘default values’  then simply create a Calculated column using the if                                                condition as shown below.

/wp-content/uploads/2015/09/image008_788911.png

/wp-content/uploads/2015/09/image009_788912.png


/wp-content/uploads/2015/09/image011_788913.jpg

That’s it enjoy!.


Best Regards

Rafiq

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply