Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi I am new to qlikview. Can anyone help me the use of Apply map function and where exactly we use this function.
from QlikView help
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'
and also
from QlikView help
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'
and also
Hi,
Check these links. It will help you. Thank you.
Don't join - use Applymap instead
Mapping Load and Applymap()
Mapping Load helps you to look up a single value from another table. By using Mapping Load
we can avoid the Joins, sometimes joins cause the records duplication and performance problems. A
mapping table consists of two columns; a comparison field (input) and a mapping value field (output).
In this example we have a table of orders (Orders), and need to know the country of the
customer, which is stored in the customer table (Customers).
Orders Table:
OrderID OrderDate ShipperID Freight CustomerID
1 10/24/2014 100 75 1
2 10/25/2014 101 65 2
Customers Table:
CustomerID Customer
1 IBM
2 TCS
Script:
//Load Customer master table with Mapping keyword
CustomersMapping:
Mapping Load
CustomerID,
Customer
FROM Customers;
//Load Orders table using ApplyMap() to look up Customer name by using CustomerID
Orders:
LOAD
*,
ApplyMap(‘CustomerMapping’, CustomerID, ‘N/A’) AS Customer
FROM Orders;
Result Table:
OrderID OrderDate ShipperID Freight CustomerID Customer
1 10/24/2014 100 75 1 IBM
2 10/25/2014 101 65 2 TCS
main use of apply map function is mapp the field names from mapping table from mapped table and mapping table must having the 2 fields only one field must be key field this is the disadvantage of mapping... by using mapping we avoid the joins in datamodel
Thank you everyone for the valuable information. Much appreciated.