Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2022, LIVE in Denver CO., May 16-19, 2022. REGISTER NOW TO RECEIVE EARLY BIRD PRICING
cancel
Showing results for 
Search instead for 
Did you mean: 
shiveshsingh
Master
Master

ApplyMap function

Hi

please let me know the error in below script

Score :mapping LOAD * INLINE [

    Name, Gender

    A, M

    B, F];

   

   

Gender: load *, ApplyMap('Score',Gender,'NA') as x

inline [Name,Score

A,20

b,50] where x='M';

6 Replies
hector_munoz
Specialist
Specialist

Hi Singh,

Try:

Score:

mapping LOAD * INLINE [

    Name, Gender

    A, M

    B, F];

Gender:

load *

where x ='M';

load *,

     ApplyMap('Score',Name,'NA') as x;

LOAD * inline

[Name,Score

A,20

b,50];

Take into account that QlikView is case sensitive... Hope it serves!

Regards,
H

MK_QSL
MVP
MVP

Instead of Gender in ApplyMap, you have to use field which is similar to the 1st Field of Mapping Load table.

So here, you have to use Name

shiveshsingh
Master
Master
Author

Hi

plz confirm one thing, how can you define the same x as variable and as field name

load *

where x ='M';

load *,

     ApplyMap('Score',Name,'NA') as x;

hector_munoz
Specialist
Specialist

Hi Singh,

Here you are making nested LOAD sentences starting in the bottom one until the top one, so you are playing with the fields you are creating:

Gender:

load *     // 3rd level: we have all the previous fields ('x', 'Name' and 'Score') but we filter by 'x' field

where x ='M';

load *,

     ApplyMap('Score',Name,'NA') as x; // 2nd level: We add 'x' field to previous 'Name' and 'Score'

LOAD * inline     // 1st level: 'Name' and 'Score' fields

[Name,Score

A,20

b,50];

Hope it is useful!

Regards,

H

shiveshsingh
Master
Master
Author

Hi Hector

Could you please let me know what is the exact error in below statement?

Score :mapping LOAD * INLINE [

    Name, Gender

    A, M

    B, F];

   

   

Gender: load *, ApplyMap('Score',Name,'NA') as x

inline [Name,Score

A,20

B,50] where x='M';

hector_munoz
Specialist
Specialist

HI,

The problem is in 'Gender' table and in its nested loads. The sentences of 'Gender' table should be:

Gender:

load *

where x='M';

load *,

ApplyMap('Score',Name,'NA') as x;

LOAD * inline

[Name,Score

A,20

B,50];

1st LOAD:

LOAD * inline

[Name,Score

A,20

B,50];


Creation of Gender table from an inline table with 'Name' and 'Score' fields.

2nd LOAD:

load *,

ApplyMap('Score',Name,'NA') as x;

B,50];


Creation of 'x' field from an ApplyMap.

3rd LOAD:

load *

where x='M';


Filtering records with 'x'= "M". This step has to be in this LOAD as in the preceding one we created X field.

Jope it is useful!

Regards,

H