Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Map and Mapping Difference?

Hi,

Any one please give me some idea with Map and Mapping...

@Sub2a

7 Replies
vardhancse
Specialist III
Specialist III

Mapping table

A:

Mapping

Load 1,

        2

From Table1;

in the main table:

will write as ApplyMap('1',Field_1) as Field_1

Not applicable
Author

Can you pls explain briefly...

vardhancse
Specialist III
Specialist III

Simply to say lookup of field and stamp the value.

Suppose if we have a field country code, and if we want to change the country code to country name

For that first will write mapping table(its a table will not be displayed in Data model and only reload)

Once the mapping table was loaded:

then we need to use that in maping table field in the main table to replace with country name

CC:

Mapping

Load Code,

        Name

From table1.xlsx;

Fact_Table:

Load

Agent_Name,

ApplyMap('CC',Country_Code) as Country_Name

From table1.xlsx

So now the output will be Agent_Name,Country_Name

phaneendra_kunc
Partner - Specialist III
Partner - Specialist III

Mapping Functions

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'

The MapSubstring function is used to map parts of any expression to a previously loaded mapping table. The mapping is case sensitive and non-iterative and substrings are mapped from left to right. The syntax is:

mapsubstring('mapname', expr)

This function can be used for mapping parts of any expression on a previously loaded mapping table. The mapping is case sensitive and non-recursive. The substrings are mapped from the left to the right. Mapname is the name of a mapping table previously read by a mapping load or a mapping select statement (see Mapping). The name must be enclosed by single straight quotation marks. Expr is the expression whose result should be mapped by substrings.

Examples:

// Assume the following mapping table:

map1:

mapping load * inline [

x, y

1, <one>

aa, XYZ

x, b ] ;

MapSubstring ('map1', 'A123') returns 'A<one>23'

MapSubstring ('map1', 'baaar') returns 'bXYZar'

MapSubstring ('map1', 'xaa1') returns 'bXYZ<one>'

Map ... using

The map ... using statement is used for mapping a certain field value or expression to the values of a specific mapping table. The mapping table is created through the Mapping statement.

The automatic mapping is done for fields loaded after the map ... using statement until the end of the script or until an unmap statement is encountered.

The mapping is done last in the chain of events leading up to the field being stored in the internal table in QlikView. This means that mapping is not done every time a field name is encountered as part of an expression, but rather when the value is stored under the field name in the internal table. If mapping on the expression level is required, the Applymap() function has to be used instead.

Note!
The map ... using statement does not work when loading QVD files in optimized Mode.

The syntax is:

map *fieldlist using mapname

*fieldlist is a comma separated list of the fields that should be mapped from this point in the script. Using * as field list indicates all fields. The wildcard characters * and ? are allowed in field names. Quoting of field names may be necessary when wildcards are used.

mapname is the name of a mapping table previously read in a mapping load or mapping select statement.

Examples:

   

map Country using Cmap;

Enables mapping of field Country using map Cmap.

map A, B, C using X;

Enables mapping of fields A, B and C using map X.

map * using GenMap;

Enables mapping of all fields using GenMap.

Not applicable
Author

Thank you Sasi and Phaneendra.

phaneendra_kunc
Partner - Specialist III
Partner - Specialist III

if you think you got what you are looking for please mark this thread answered so that others will be able to easily find it.

ZaahidG
Partner - Contributor II
Partner - Contributor II

Where in the statement map * using GenMap; are we stating where the field need to be mapped to? or appended to? How ill the mapping statement end up in the desired tabel?