Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join us at the Cloud Data and Analytics Tour! REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
qvraj123
Creator II
Creator II

applymap with if condition


Hi - Thanks for your time,

can anyone guide me - I am trying to use an if with applymap but looks iam missing something

EmpMapping:

MAPPING LOAD

EMP_NBR,

EMPLEVEL

FROM abc.qvd

Testing:

EMPNO,

EMPLEVEL,

IF(EMPLEVEL <> 'Non-Employee' , APPLYMAP('EmpMapping',EMPNO,'Other'),EMPLEVEL AS TESTING

FROM XYZ

If the EMPNO is same as EMP_NBR then use the APPLYMAP to get the EMPLEVEL from abc else use the EMPLEVEL from xyz

but I see everything coming from xyz - any help

thanks a lot

13 Replies
sunny_talwar

Not sure if I completely understand, but you are def. missing a parenthesis ()) at the end of your If Statement, but that should have given you an error when you ran your script. So not sure what the exact problem is:

Testing:

EMPNO,

EMPLEVEL,

IF(EMPLEVEL <> 'Non-Employee' , APPLYMAP('EmpMapping',EMPNO,'Other'),EMPLEVEL) AS TESTING

FROM XYZ;

maxgro
MVP
MVP

Testing:

EMPNO,

EMPLEVEL,

//IF(EMPLEVEL <> 'Non-Employee' , APPLYMAP('EmpMapping',EMPNO,'Other'),EMPLEVEL AS TESTING

APPLYMAP('EmpMapping',EMPNO,EMPLEVEL) AS TESTING

FROM XYZ


sunny_talwar

I was thinking of proposing something similar, but my only concern is what if a non-employee also has a EMPNO in the mapping table? This completely doesn't make sense, but since I was not sure of the data behind this I was hesitant in proposing this.

Best,

Sunny

jonathandienst

Apart from a missing closing bracket on the applymap line (which I assume is a typo in your post) the logic looks fine. Have you checked that the data in EMP_NBR has the same values and data type as the date in EMPNO? Have you confirmed that there are values other than Non-Employee in EMPLEVEL from XYZ?

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
maxgro
MVP
MVP

well, mee too I wasn't sure to completely understand the question but I think sometimes it's better to provide an answer maybe incorrect but useful to clarify the question and then to find the right answer

qvraj123
Creator II
Creator II
Author

Thank you all of you for your time, yes the data types are same as I am reading from the QVD files

1) Non-Employee exists only in XYZ - majority of the Non-Employee level in xyz do not exist in abc, only few may be less than 10 exist in ABC (this is how the data is - actual EMPNO's considered as non-employee which is weird)

2). there are some employees who are terminated and exist in xyz but not in abc (again it is the data)

I tried this but still I see lot of emp levels from XYZ - APPLYMAP('EmpMapping',EMPNO,EMPLEVEL)

Thank you again for your time

sunny_talwar

So if I understand correctly, you are trying to bring in the employee level from abc.qvd into your testing table as a column name Testing. But your issue is that it is unable to map it from the abc.qvd and showing you the employee level from xyz.qvd only??? Have I understood your question?

One thing that comes to my mind is, do you have one to one mapping in your EmpMapping table? Because if a single employee number is mapped to multiple levels, the output may be not what you expect.

Best,

Sunny

maxgro
MVP
MVP

I think a (

Testing:

EMPNO,

EMPLEVEL,

FROM XYZ....

EmpNoMapping:

LOAD

EMP_NBR as EMPNO,

EMPLEVEL as EMPLEVEL2

FROM abc.qvd...

and a chart/table could help to understand the problem (as jonathan suggested)

qvraj123
Creator II
Creator II
Author

If expression with the applymap is working fine - but because of the data I get issues - like emp's existing in xyz do not exist in abc etc - attached sample for your reference - again thanks a lot for your help