Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Mapping Issue

Hi All,

I have a Mapping load table:

Product IDProduct Name
1MOBILE
2LAPTOP
3PRINTER

My Data is like:

Product IDProduct Category
1AAA
2BBB
3CCC
4DDD
5EEE

My Requirement is i need to map the Product Name based on the Product ID.If the Mapping table does not contain a particular Product ID then it should take Product Category as Product Name.

I am using Applymap('Mapping_load_Table_name',Product ID,Product Category).But could not succeed.

My Output should be like this:

Product IDProduct CategoryProduct Name
1AAAMOBILE
2BBBLAPTOP
3CCCPRINTER
4DDDDDD
5EEEEEE

Thanks in Advance.

Regards

Roopesh

3 Replies
Anonymous
Not applicable
Author

Try putting square brackets around the field names with spaces :

    Applymap('Mapping_load_Table_name',[Product ID],[Product Category]) as MappedField

JonnyPoole
Former Employee
Former Employee

Here is a sample. The first load is a mapping load (and won't be a part of the data model)

The 2nd load is your data.

The 3rd data, loads your data and applies the map. When no hit is found, it uses product category.

ProductMap:

mapping load * INLINE [

    Product ID, Product Name

    1, MOBILE

    2, LAPTOP

    3, PRINTER

];

Temp:

LOAD * INLINE [

    Product ID, Product Category

    1, AAA

    2, BBB

    3, CCC

    4, DDD

    5, EEE

];

Data:

Load

  *,

  ApplyMap('ProductMap',[Product ID],[Product Category])as [Product Name]

Resident Temp;

drop table Temp;

The outcome is a single table with the desired effect.

In your situation your probably won't need the 2nd load.. Just load from your data source and add a new calculated field using applymap() as you see in the 3rd load.

Capture.PNG

maxgro
MVP
MVP

1.png

Mapping_load_Table_name:

mapping load * inline [

Product ID, Product Name

1, MOBILE

2, LAPTOP

3, PRINTER

];

Table:

load

  *,

  Applymap('Mapping_load_Table_name',[Product ID],[Product Category]) as [Product Name]

inline [

Product ID, Product Category

1, AAA

2, BBB

3, CCC

4, DDD

5, EEE

];