Hi! I loaded a field containing zip codes. To make it neat I would like them to be formated as 'xxx xx', and most of them are, but not all. My first thought was to do it while loading by manipulating the string BUT I also have zip codes for three other countrys (country_id stored in another field). Is it the best way to do a temp table and then map that to the main table? Twice actually since I have to do it for all other countries as well. In SQL i would just set a condition, WHERE country_id=1, but I can't do that in loading? Only when loading resident, right?
Solved! Go to Solution.
Omitted zip code from main, loaded zip, country_id and customer_id and then created MAPPING and ApplyMap. Switched the loading order so I create the mapping tables first and then I run the big one, with ApplyMap to get my clean swedish zip codes. Now I made another MAPPING for the other countries. I want them in the same field, naturally. So how do I merge the two MAPPINGS????
I would suggest to make mappings for each country. This would assure a separated treatment and no overlapping.
In the script you could try to use the mapping related to the country or make concatenated loads for each country with a Where Clause on country_code:
LOAD ApplyMap('zip_code_' & country_code, zip_code) as zip_code...
No, you need not to run the script twice in my solution.
Btw. you have an error in your nested ApplyMap, this should work:
ApplyMap('new_zip_sweden', ApplyMap('new_zip_not_sweden', SITE_ID)) as SITE_ZIPCODE