Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Any one help me how to understand mapping function i.e Map Using?????
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
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`;
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
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
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
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 ..
Regards
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
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
Glad it's now working. And don't worry, your English is a lot lot better than my Spanish!
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.