Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am using the below code and here I have used 'Mapping' with 'ApplyMap' , but when I am using this mapping in another ApplyMap(), it does not replace [Trn Key] with the channel name.
[Map_D_FIRM]:
Mapping
LOAD
ApplyMap('Map_F_SALES_TRN', "Firm ID") as [Trn Key],
"Firm Channel Desc" as "Channel Name"
resident [D_FIRM];
So can we use 'Mapping' with 'ApplyMap' in a single table mapping?
Thank,
Sandip
sandip,
there is no issue in using ApplyMap within a Mapping load. I'd suggest that if you are having issues with this final mapping table you try creating you mapping table initially as a normal table to make sure that it at least associates with the target table.
Marcus
Hi Sandip,
You Cant do like this. Qlik can not understand which fields should map. And What is your purpose behind it.
Thanks,
Arvind Patil
Arvind,
you're wrong. As long as your mapping tables are set up correctly, you can use a nested ApplyMap.
For example:
Map1:
MAPPING LOAD * INLINE
[From1, To1
A, AA
B, BB
];
Map2:
MAPPING LOAD
ApplyMap('Map1', From1) as From2,
Description
;
LOAD * INLINE [
From1, Description
A, ThisShouldBeMappedByAA
B, ThisShouldBeMappedByBB
C, ThisShouldBeMappedByC
]
;
FinalTable:
Load
From2,
ApplyMap('Map2', From2, 'Unmapped') as NestedMapResult,
Mapped;
LOAD * INLINE
[From2, Mapped
AA, Yes
BB, Yes
CC, No
C, Yes but via C
D, No
];
Hi Sandip,
Are you trying to do an ApplyMap when creating another MAPPING table, using a nested ApplyMap as Marcus suggests?
You can get a better picture of what ApplyMap is doing if you add a third parameter, something like:
ApplyMap('Map_F_SALES_TRN', "Firm ID", 'Not Found: ' & "Firm ID") as [Trn Key],
The extra parameter proves what is going on. If the map name is missing Trn Key will be null. If all values are prefixed with Not Found then the map exists but there is no match between the first field in the mapping table and the "Firm ID".
If there are no matches check for things like spaces and the case of the values (adding Trim and Upper can help),
This blog post on ApplyMap covers all kinds of scenarios, including nested ApplyMap:
https://www.quickintelligence.co.uk/applymap-is-it-so-wrong/
Hope that helps,
Steve
Hi Sandip
your code should work fine.
I would suggest that you make a copy of the map table as a normal table to see if the applymap is returning the correct key values in your final mapping table or not.
[Map_D_FIRM]:
Mapping
LOAD
ApplyMap('Map_F_SALES_TRN', "Firm ID") as [Trn Key],
"Firm Channel Desc" as "Channel Name"
resident [D_FIRM];
[Test Map_D_FIRM]:
LOAD
ApplyMap('Map_F_SALES_TRN', "Firm ID",'No match Found') as [Trn Key],
"Firm Channel Desc" as "Channel Name"
resident [D_FIRM];
exit script;
At this point you could inspect the contents of the table either using table viewer or chart/table box objects