Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

ERROR: Applymap with map_id as expression

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

];

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

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

];

View solution in original post

5 Replies
ChennaiahNallani
Creator III
Creator III

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

];

petter
Partner - Champion III
Partner - Champion III

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,

petter
Partner - Champion III
Partner - Champion III

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

];

Anonymous
Not applicable
Author

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?

petter
Partner - Champion III
Partner - Champion III

I don't know - I never tried to make it as an expression before.