Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Map..Using (mapping) fucntion Info please..

Any one help me how to understand mapping function i.e Map Using?????

22 Replies
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi Miguel,

Surely if you were modifying the value of every field with the same name in the load script it must by definition be a key field?  If there is a key in play like that then I would have thought you would more likely have the text dimension in just one of the tables - rather than swapping the key out for a value in all of them?

I'm not sure there would be many circumstances where MAP ... USING would actually be useful - and certainly not worth the potential confusion in the code of a field being given a different value with no code obviously affecting it (in the same way as QUALIFY does - which often causes confusion).

Steve

http://www.quickintelligence.co.uk/

Not applicable
Author

Hi, I'm trying to execute this mapping ... but it does not work ... the field 'Revenue_Type' always show the original values, (FOOD y BEV)

Thanks.


Rev_Type:

Mapping load * Inline
[food,Alimentos
bev,Bebidas]
;
map [Revenue_Type] using Rev_Type;
Rev_FB:
SQL SELECT
    Revenue_Type,
FROM `C:\DIR\BBDD`.`Query_MDB`;

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi there,

With the example code you have posted only Revenue_Type of bev will be replaced, in this case for Bebidas.

If you are just looking for a single value to be replaced you may be wanting a replace statement?

Replace(Revenue_Type, 'BEV', 'Bebidas') as Revenue_Type,

Steve

Not applicable
Author

Thanks Steve, but I'm looking for replace Revenue_Type field with the value "Bebidas" if the original value is 'Bev' or "Alimentos" in case the original value was 'Food'

Regards

José María

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

I see, the problem was with my Spanish!

The first line of an INLINE table is always the column headings, you want an extra row on the table:

Rev_Type:

Mapping load * Inline
[desde,a

food,Alimentos
bev,Bebidas]
;


That should then work.  You may also need to be careful of the case of the characters though.


-Steve

Not applicable
Author

Sorry, it does not work the code now is ...

Rev_Type:

Mapping load * Inline [
Short,Long
BEV, Bebidas
FOOD, Alimentos ]
;
map Revenue_Type using Rev_Type;

The result is ..

Snap28.jpg

Regards

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

You need to match the case of the fields:

Rev_Type:

Mapping load * Inline [
Short,Long
Bev, Bebidas
Food, Alimentos ]
;
map Revenue_Type using Rev_Type;

You may therefore need multiple lines in your mapping table to cater for a mix of case in your source data.  You would get more flexibility if you used the ApplyMap statement (rather than Map Using) as you could then mix in Upper and Capitalize statements with the solution.

Steve


Not applicable
Author

Now it works .... I've added Force case Mixed line ...

Thank you for your support ... and sorry for my English ....

Best regards

José María

Snap28.jpg

Snap30.jpg


stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Glad it's now working.  And don't worry, your English is a lot lot better than my Spanish!

adnan_rafiq
Partner - Creator II
Partner - Creator II

hi Steve, I have a supplementary question to the discussion please see the code below.

Rule_Key_Map:

Mapping

LOAD * INLINE [

    Old_Value, New_Value

    Rule-3, Rule-Z

    Rule-4, Rule-A

];

MAP RuleXXX using Rule_Key_Map;

Test2:

Load

RuleXXX

From

[Test1.qvd](qvd);

//While  Test1.qvd is this

Test1:

Load * Inline

[

RuleXXX,Rule_Key4

Rule-3,Rule-3

];

When I load this out of inline load the map works and changes the Rule-3 to Rule-Z,

But when i load out of QVD the map doesn't work.

You can store the Test1 inline table and give this code a try.