Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Version:12.20.20200.0 Nov2017 SR1
Error: ApplyMap error:map_id not found
MAP_C1:
Mapping LOAD * INLINE [
Heading1, Heading2
Row1, 123
Row1, 321
];
MAP_C2:
Mapping LOAD * INLINE [
Heading1, Heading2
Row1, abc
Row2, cba
];
MAP_OUT:
Load
applymap('MAP_'&Security_ID,'Row1','no map') as MAP_Result,
Security_ID
;
LOAD * INLINE [
Security_ID
C1
C2
];
You could make a single mapping table and do this to achieve the same:
MAP_C:
Mapping LOAD * INLINE [
Heading1, Heading2
C1|Row1, 123
C1|Row2, 321
C2|Row1, abc
C2|Row2, cba
];
MAP_OUT:
Load
ApplyMap( 'MAP_C' , Security_ID & '|' & 'Row1' , 'no map' ) AS MAP_Result,
Security_ID
;
LOAD * INLINE [
Security_ID
C1
C2
];
Try below code
MAP_C1:
Mapping LOAD * INLINE [
Heading1, Heading2
Row1, 123
Row1, 321
];
MAP_C2:
Mapping LOAD * INLINE [
Heading1, Heading2
Row1, abc
Row2, cba
];
MAP_OUT:
Load
applymap('MAP_C1'&Security_ID,'Row1','no map') as MAP_Result,
Security_ID
;
LOAD * INLINE [
Security_ID
C1
C2
];
The ApplyMap()-function does not allow for an expression as the mapping table name - the first parameter. It has to be a constant string.
So you could change your code to this to get it to work:
Pick( Match( Security_ID , 'C1' , 'C2')
,ApplyMap( 'MAP_C1 ', 'Row1' , 'no map' )
,ApplyMap( MAP_C2' , 'Row1' , 'no map' )
) AS MAP_Result,
You could make a single mapping table and do this to achieve the same:
MAP_C:
Mapping LOAD * INLINE [
Heading1, Heading2
C1|Row1, 123
C1|Row2, 321
C2|Row1, abc
C2|Row2, cba
];
MAP_OUT:
Load
ApplyMap( 'MAP_C' , Security_ID & '|' & 'Row1' , 'no map' ) AS MAP_Result,
Security_ID
;
LOAD * INLINE [
Security_ID
C1
C2
];
Thank you, your solution is nice and elegant!
Creating two mapping tables did seem unnecessary.
I thought map_ids as expressions used to work. Was it removed recently?
I don't know - I never tried to make it as an expression before.